16971: Fixed failing tests
[arvados-workbench2.git] / cypress / integration / create-workflow.spec.js
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 describe('Multi-file deletion tests', function () {
6     let activeUser;
7     let adminUser;
8
9     before(function () {
10         cy.getUser('admin', 'Admin', 'User', true, true)
11             .as('adminUser').then(function () {
12                 adminUser = this.adminUser;
13             }
14             );
15         cy.getUser('collectionuser1', 'Collection', 'User', false, true)
16             .as('activeUser').then(function () {
17                 activeUser = this.activeUser;
18             }
19             );
20     });
21
22     beforeEach(function () {
23         cy.clearCookies();
24         cy.clearLocalStorage();
25     });
26
27     it('can create project with nested data', function () {
28         cy.createGroup(adminUser.token, {
29             group_class: "project",
30             name: `Test project (${Math.floor(Math.random() * 999999)})`,
31         }).as('project1');
32
33         cy.get('@project1').then(() => {
34             cy.createGroup(adminUser.token, {
35                 group_class: "project",
36                 name: `Test project (${Math.floor(Math.random() * 999999)})`,
37                 owner_uuid: this.project1.uuid,
38             }).as('project2');
39         })
40
41         cy.get('@project2').then(() => {
42             cy.createGroup(adminUser.token, {
43                 group_class: "project",
44                 name: `Test project (${Math.floor(Math.random() * 999999)})`,
45                 owner_uuid: this.project2.uuid,
46             }).as('project3');
47         });
48
49         cy.get('@project3').then(() => {
50             cy.createWorkflow(adminUser.token, {
51                 name: `TestWorkflow${Math.floor(Math.random() * 999999)}.cwl`,
52                 definition: "{\n    \"$graph\": [\n        {\n            \"class\": \"Workflow\",\n            \"doc\": \"Reverse the lines in a document, then sort those lines.\",\n            \"hints\": [\n                {\n                    \"acrContainerImage\": \"99b0201f4cade456b4c9d343769a3b70+261\",\n                    \"class\": \"http://arvados.org/cwl#WorkflowRunnerResources\"\n                }\n            ],\n            \"id\": \"#main\",\n            \"inputs\": [\n                {\n                    \"default\": null,\n                    \"doc\": \"The input file to be processed.\",\n                    \"id\": \"#main/input\",\n                    \"type\": \"File\"\n                },\n                {\n                    \"default\": true,\n                    \"doc\": \"If true, reverse (decending) sort\",\n                    \"id\": \"#main/reverse_sort\",\n                    \"type\": \"boolean\"\n                }\n            ],\n            \"outputs\": [\n                {\n                    \"doc\": \"The output with the lines reversed and sorted.\",\n                    \"id\": \"#main/output\",\n                    \"outputSource\": \"#main/sorted/output\",\n                    \"type\": \"File\"\n                }\n            ],\n            \"steps\": [\n                {\n                    \"id\": \"#main/rev\",\n                    \"in\": [\n                        {\n                            \"id\": \"#main/rev/input\",\n                            \"source\": \"#main/input\"\n                        }\n                    ],\n                    \"out\": [\n                        \"#main/rev/output\"\n                    ],\n                    \"run\": \"#revtool.cwl\"\n                },\n                {\n                    \"id\": \"#main/sorted\",\n                    \"in\": [\n                        {\n                            \"id\": \"#main/sorted/input\",\n                            \"source\": \"#main/rev/output\"\n                        },\n                        {\n                            \"id\": \"#main/sorted/reverse\",\n                            \"source\": \"#main/reverse_sort\"\n                        }\n                    ],\n                    \"out\": [\n                        \"#main/sorted/output\"\n                    ],\n                    \"run\": \"#sorttool.cwl\"\n                }\n            ]\n        },\n        {\n            \"baseCommand\": \"rev\",\n            \"class\": \"CommandLineTool\",\n            \"doc\": \"Reverse each line using the `rev` command\",\n            \"hints\": [\n                {\n                    \"class\": \"ResourceRequirement\",\n                    \"ramMin\": 8\n                }\n            ],\n            \"id\": \"#revtool.cwl\",\n            \"inputs\": [\n                {\n                    \"id\": \"#revtool.cwl/input\",\n                    \"inputBinding\": {},\n                    \"type\": \"File\"\n                }\n            ],\n            \"outputs\": [\n                {\n                    \"id\": \"#revtool.cwl/output\",\n                    \"outputBinding\": {\n                        \"glob\": \"output.txt\"\n                    },\n                    \"type\": \"File\"\n                }\n            ],\n            \"stdout\": \"output.txt\"\n        },\n        {\n            \"baseCommand\": \"sort\",\n            \"class\": \"CommandLineTool\",\n            \"doc\": \"Sort lines using the `sort` command\",\n            \"hints\": [\n                {\n                    \"class\": \"ResourceRequirement\",\n                    \"ramMin\": 8\n                }\n            ],\n            \"id\": \"#sorttool.cwl\",\n            \"inputs\": [\n                {\n                    \"id\": \"#sorttool.cwl/reverse\",\n                    \"inputBinding\": {\n                        \"position\": 1,\n                        \"prefix\": \"-r\"\n                    },\n                    \"type\": \"boolean\"\n                },\n                {\n                    \"id\": \"#sorttool.cwl/input\",\n                    \"inputBinding\": {\n                        \"position\": 2\n                    },\n                    \"type\": \"File\"\n                }\n            ],\n            \"outputs\": [\n                {\n                    \"id\": \"#sorttool.cwl/output\",\n                    \"outputBinding\": {\n                        \"glob\": \"output.txt\"\n                    },\n                    \"type\": \"File\"\n                }\n            ],\n            \"stdout\": \"output.txt\"\n        }\n    ],\n    \"cwlVersion\": \"v1.0\"\n}",
53             })
54                 .as('testWorkflow');
55
56             cy.createCollection(adminUser.token, {
57                 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
58                 owner_uuid: this.project3.uuid,
59                 manifest_text: "./subdir 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo\n. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:baz\n"
60             })
61                 .as('testCollection');
62         });
63
64         cy.get('@testWorkflow').then(() => {
65             cy.loginAs(adminUser);
66
67             cy.get('[data-cy=linear-progress]').should('exist');
68             cy.get('[data-cy=linear-progress]').should('not.exist');
69
70             cy.get('[data-cy=side-panel-button]').click();
71             cy.get('[data-cy=side-panel-run-process]').click();
72
73             cy.get('.layout-pane')
74                 .contains(this.testWorkflow.name)
75                 .click();
76
77             cy.get('[data-cy=run-process-next-button]').click();
78
79             cy.get('[data-cy=new-process-panel]').contains('Run Process').should('be.disabled');
80
81             cy.get('[data-cy=new-process-panel]')
82                 .within(() => {
83                     cy.get('[name=name]').type(`Workflow name (${Math.floor(Math.random() * 999999)})`);
84                     cy.get('[readonly]').click();
85                 });
86
87             cy.get('[data-cy=choose-a-file-dialog]').as('chooseFileDialog');
88             cy.get('@chooseFileDialog').contains('Projects').closest('ul').find('i').click();
89
90             cy.get('@project1').then((project1) => {
91                 cy.get('@chooseFileDialog').find(`[data-id=${project1.uuid}]`).find('i').click();
92             });
93
94             cy.get('@project2').then((project2) => {
95                 cy.get('@chooseFileDialog').find(`[data-id=${project2.uuid}]`).find('i').click();
96             });
97
98             cy.get('@project3').then((project3) => {
99                 cy.get('@chooseFileDialog').find(`[data-id=${project3.uuid}]`).find('i').click();
100             });
101
102             cy.get('@testCollection').then((testCollection) => {
103                 cy.get('@chooseFileDialog').find(`[data-id=${testCollection.uuid}]`).find('i').click();
104             });
105
106             cy.get('@chooseFileDialog').contains('baz').click();
107
108             cy.get('@chooseFileDialog').find('button').contains('Ok').click();
109
110             cy.get('[data-cy=new-process-panel]')
111                 .find('button').contains('Run Process').should('not.be.disabled');
112         });
113     });
114
115     ['workflow_with_array_fields.yaml', 'workflow_with_default_array_fields.yaml'].forEach((yamlfile) =>
116     it('can select multi files when creating workflow '+yamlfile, () => {
117         cy.createProject({
118             owningUser: activeUser,
119             projectName: 'myProject1',
120             addToFavorites: true
121         });
122
123         cy.createCollection(adminUser.token, {
124             name: `Test collection ${Math.floor(Math.random() * 999999)}`,
125             owner_uuid: activeUser.user.uuid,
126             manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:baz\n"
127         })
128             .as('testCollection');
129
130         cy.createCollection(adminUser.token, {
131             name: `Test collection ${Math.floor(Math.random() * 999999)}`,
132             owner_uuid: activeUser.user.uuid,
133             manifest_text: `. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:buz\n`
134         })
135             .as('testCollection2');
136
137         cy.getAll('@myProject1', '@testCollection', '@testCollection2')
138             .then(function ([myProject1, testCollection, testCollection2]) {
139                 cy.readFile('cypress/fixtures/'+yamlfile).then(workflow => {
140                     cy.createWorkflow(adminUser.token, {
141                         name: `TestWorkflow${Math.floor(Math.random() * 999999)}.cwl`,
142                         definition: workflow,
143                         owner_uuid: myProject1.uuid,
144                     })
145                         .as('testWorkflow');
146                 });
147
148                 cy.loginAs(activeUser);
149
150                 cy.get('main').contains(myProject1.name).click();
151
152                 cy.get('[data-cy=side-panel-button]').click();
153
154                 cy.get('#aside-menu-list').contains('Run a process').click();
155
156                 cy.get('@testWorkflow')
157                     .then((testWorkflow) => {
158                         cy.get('main').contains(testWorkflow.name).click();
159                         cy.get('[data-cy=run-process-next-button]').click();
160
161                         cy.get('label').contains('#main/foo').parent('div').find('input').click();
162                         cy.get('div[role=dialog]')
163                             .within(() => {
164                                 cy.get('p').contains('Projects').closest('div[role=button]')
165                                     .within(() => {
166                                         cy.get('svg[role=presentation]')
167                                             .click({ multiple: true });
168                                     });
169
170                                 cy.get(`[data-id=${testCollection.uuid}]`)
171                                     .find('i').click();
172
173                                 cy.contains('bar').closest('[data-action=TOGGLE_ACTIVE]').parent().find('input[type=checkbox]').click();
174
175                                 cy.contains('baz').closest('[data-action=TOGGLE_ACTIVE]').parent().find('input[type=checkbox]').click();
176
177                                 cy.get('[data-cy=ok-button]').click();
178                             });
179
180                         cy.get('label').contains('#main/bar').parent('div').find('input').click();
181                         cy.get('div[role=dialog]')
182                             .within(() => {
183                                 cy.get('p').contains('Projects').closest('div[role=button]')
184                                     .within(() => {
185                                         cy.get('svg[role=presentation]')
186                                             .click({ multiple: true });
187                                     });
188
189                                 cy.get(`[data-id=${testCollection.uuid}]`)
190                                     .find('input[type=checkbox]').click();
191
192                                 cy.get(`[data-id=${testCollection2.uuid}]`)
193                                     .find('input[type=checkbox]').click();
194
195                                 cy.get('[data-cy=ok-button]').click();
196                             });
197                     });
198
199                 cy.get('label').contains('#main/foo').parent('div')
200                     .within(() => {
201                         cy.contains('baz');
202                         cy.contains('bar');
203                     });
204
205                 cy.get('label').contains('#main/bar').parent('div')
206                     .within(() => {
207                         cy.contains(testCollection.name);
208                         cy.contains(testCollection2.name);
209                     });
210             });
211     }));
212 })