19482: Cypress tests WIP
[arvados-workbench2.git] / cypress / integration / workflow.spec.js
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 describe('Registered workflow panel tests', function() {
6     let activeUser;
7     let adminUser;
8
9     before(function() {
10         // Only set up common users once. These aren't set up as aliases because
11         // aliases are cleaned up after every test. Also it doesn't make sense
12         // to set the same users on beforeEach() over and over again, so we
13         // separate a little from Cypress' 'Best Practices' here.
14         cy.getUser('admin', 'Admin', 'User', true, true)
15             .as('adminUser').then(function() {
16                 adminUser = this.adminUser;
17             }
18         );
19         cy.getUser('user', 'Active', 'User', false, true)
20             .as('activeUser').then(function() {
21                 activeUser = this.activeUser;
22             }
23         );
24     });
25
26     it('should handle null definition', function() {
27         cy.createResource(activeUser.token, "workflows", {workflow: {name: "Test wf"}})
28             .then(function(workflowResource) {
29                 cy.loginAs(activeUser);
30                 cy.goToPath(`/workflows/${workflowResource.uuid}`);
31                 cy.get('[data-cy=registered-workflow-info-panel]').should('contain', workflowResource.name);
32                 cy.get('[data-cy=workflow-details-attributes-modifiedby-user]').contains(`Active User (${activeUser.user.uuid})`);
33             });
34     });
35
36     it('should handle malformed definition', function() {
37         cy.createResource(activeUser.token, "workflows", {workflow: {name: "Test wf", definition: "zap:"}})
38             .then(function(workflowResource) {
39                 cy.loginAs(activeUser);
40                 cy.goToPath(`/workflows/${workflowResource.uuid}`);
41                 cy.get('[data-cy=registered-workflow-info-panel]').should('contain', workflowResource.name);
42                 cy.get('[data-cy=workflow-details-attributes-modifiedby-user]').contains(`Active User (${activeUser.user.uuid})`);
43             });
44     });
45
46     it('shows workflow details', function() {
47         cy.createResource(activeUser.token, "workflows", {workflow: {
48             name: "Test wf",
49             definition: JSON.stringify({
50                 cwlVersion: "v1.2",
51                 $graph: [
52                     {
53                         "class": "Workflow",
54                         "hints": [
55                             {
56                                 "class": "DockerRequirement",
57                                 "dockerPull": "python:2-slim"
58                             }
59                         ],
60                         "id": "#main",
61                         "inputs": [
62                             {
63                                 "id": "#main/file1",
64                                 "type": "File"
65                             },
66                             {
67                                 "id": "#main/numbering",
68                                 "type": [
69                                     "null",
70                                     "boolean"
71                                 ]
72                             },
73                             {
74                                 "default": {
75                                     "basename": "args.py",
76                                     "class": "File",
77                                     "location": "keep:de738550734533c5027997c87dc5488e+53/args.py",
78                                     "nameext": ".py",
79                                     "nameroot": "args",
80                                     "size": 179
81                                 },
82                                 "id": "#main/args.py",
83                                 "type": "File"
84                             }
85                         ],
86                         "outputs": [
87                             {
88                                 "id": "#main/args",
89                                 "outputSource": "#main/step/args",
90                                 "type": {
91                                     "items": "string",
92                                     "name": "_:b0adccc1-502d-476f-8a5b-c8ef7119e2dc",
93                                     "type": "array"
94                                 }
95                             }
96                         ],
97                         "requirements": [
98                             {
99                                 "class": "SubworkflowFeatureRequirement"
100                             }
101                         ],
102                         "steps": [
103                             {
104                                 "id": "#main/cat1-testcli.cwl (v1.2.0-109-g9b091ed)",
105                                 "in": [
106                                     {
107                                         "id": "#main/step/file1",
108                                         "source": "#main/file1"
109                                     },
110                                     {
111                                         "id": "#main/step/numbering",
112                                         "source": "#main/numbering"
113                                     },
114                                     {
115                                         "id": "#main/step/args.py",
116                                         "source": "#main/args.py"
117                                     }
118                                 ],
119                                 "label": "cat1-testcli.cwl (v1.2.0-109-g9b091ed)",
120                                 "out": [
121                                     {
122                                         "id": "#main/step/args"
123                                     }
124                                 ],
125                                 "run": "keep:6b2f3b54194acf69476f22ae52c8ceaf+62/cat1-testcli.cwl"
126                             }
127                         ]
128                     }
129                 ],
130                 "cwlVersion": "v1.2",
131                 "http://arvados.org/cwl#gitBranch": "1.2.1_proposed",
132                 "http://arvados.org/cwl#gitCommit": "9b091ed7e0bef98b3312e9478c52b89ba25792de",
133                 "http://arvados.org/cwl#gitCommitter": "GitHub <noreply@github.com>",
134                 "http://arvados.org/cwl#gitDate": "Sun, 11 Sep 2022 21:24:42 +0200",
135                 "http://arvados.org/cwl#gitDescribe": "v1.2.0-109-g9b091ed",
136                 "http://arvados.org/cwl#gitOrigin": "git@github.com:common-workflow-language/cwl-v1.2",
137                 "http://arvados.org/cwl#gitPath": "tests/cat1-testcli.cwl",
138                 "http://arvados.org/cwl#gitStatus": ""
139             })
140         }}).then(function() {
141             cy.createCollection(adminUser.token, {
142                 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
143                 owner_uuid: activeUser.user.uuid,
144                 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
145             })
146         })
147             .then(function(workflowResource) {
148                 cy.loginAs(activeUser);
149                 cy.goToPath(`/workflows/${workflowResource.uuid}`);
150                 cy.get('[data-cy=registered-workflow-info-panel]').should('contain', workflowResource.name);
151                 cy.get('[data-cy=workflow-details-attributes-modifiedby-user]').contains(`Active User (${activeUser.user.uuid})`);
152             });
153     });
154 });