1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 describe('Create workflow tests', function () {
10 cy.getUser('admin', 'Admin', 'User', true, true)
11 .as('adminUser').then(function () {
12 adminUser = this.adminUser;
15 cy.getUser('collectionuser1', 'Collection', 'User', false, true)
16 .as('activeUser').then(function () {
17 activeUser = this.activeUser;
22 beforeEach(function () {
24 cy.clearLocalStorage();
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)})`,
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,
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,
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}",
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"
61 .as('testCollection');
64 cy.get('@testWorkflow').then(() => {
65 cy.loginAs(adminUser);
67 cy.get('[data-cy=side-panel-button]').click();
68 cy.get('[data-cy=side-panel-run-process]').click();
70 cy.get('.layout-pane')
71 .contains(this.testWorkflow.name)
74 cy.get('[data-cy=run-process-next-button]').click();
76 cy.get('[data-cy=new-process-panel]').contains('Run workflow').should('be.disabled');
78 cy.get('[data-cy=new-process-panel]')
80 cy.get('[name=name]').type(`Workflow name (${Math.floor(Math.random() * 999999)})`);
81 cy.contains('input').next().click();
84 cy.get('[data-cy=choose-a-file-dialog]').as('chooseFileDialog');
85 cy.get('@chooseFileDialog').contains('Home Projects').closest('ul').find('i').click();
87 cy.get('@project1').then((project1) => {
88 cy.get('@chooseFileDialog').find(`[data-id=${project1.uuid}]`).find('i').click();
91 cy.get('@project2').then((project2) => {
92 cy.get('@chooseFileDialog').find(`[data-id=${project2.uuid}]`).find('i').click();
95 cy.get('@project3').then((project3) => {
96 cy.get('@chooseFileDialog').find(`[data-id=${project3.uuid}]`).find('i').click();
99 cy.get('@testCollection').then((testCollection) => {
100 cy.get('@chooseFileDialog').find(`[data-id=${testCollection.uuid}]`).find('i').click();
103 cy.get('@chooseFileDialog').contains('baz').click();
105 cy.get('@chooseFileDialog').find('button').contains('Ok').click();
107 cy.get('[data-cy=new-process-panel]')
108 .find('button').contains('Run workflow').should('not.be.disabled');
112 ['workflow_with_array_fields.yaml', 'workflow_with_default_array_fields.yaml'].forEach((yamlfile) =>
113 it('can select multi files when creating workflow '+yamlfile, () => {
115 owningUser: activeUser,
116 projectName: 'myProject1',
120 cy.createCollection(adminUser.token, {
121 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
122 owner_uuid: activeUser.user.uuid,
123 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:baz\n"
125 .as('testCollection');
127 cy.createCollection(adminUser.token, {
128 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
129 owner_uuid: activeUser.user.uuid,
130 manifest_text: `. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:buz\n`
132 .as('testCollection2');
134 cy.getAll('@myProject1', '@testCollection', '@testCollection2')
135 .then(function ([myProject1, testCollection, testCollection2]) {
136 cy.readFile('cypress/fixtures/'+yamlfile).then(workflow => {
137 cy.createWorkflow(adminUser.token, {
138 name: `TestWorkflow${Math.floor(Math.random() * 999999)}.cwl`,
139 definition: workflow,
140 owner_uuid: myProject1.uuid,
145 cy.loginAs(activeUser);
147 cy.get('main').contains(myProject1.name).click();
149 cy.get('[data-cy=side-panel-button]').click();
151 cy.get('#aside-menu-list').contains('Run a workflow').click();
153 cy.get('@testWorkflow')
154 .then((testWorkflow) => {
155 cy.get('main').contains(testWorkflow.name).click();
156 cy.get('[data-cy=run-process-next-button]').click();
158 cy.get('label').contains('foo').parent('div').find('input').click();
159 cy.get('div[role=dialog]')
161 // must use .then to avoid selecting instead of expanding https://github.com/cypress-io/cypress/issues/5529
162 cy.get('p').contains('Home Projects').closest('ul')
164 .then(el => el.click());
166 cy.get(`[data-id=${testCollection.uuid}]`)
170 cy.contains('bar').closest('[data-action=TOGGLE_ACTIVE]').parent().find('input[type=checkbox]').click();
171 cy.contains('baz').closest('[data-action=TOGGLE_ACTIVE]').parent().find('input[type=checkbox]').click();
173 cy.get('[data-cy=ok-button]').click();
176 cy.get('label').contains('bar').parent('div').find('input').click();
177 cy.get('div[role=dialog]')
179 // must use .then to avoid selecting instead of expanding https://github.com/cypress-io/cypress/issues/5529
180 cy.get('p').contains('Home Projects').closest('ul')
182 .then(el => el.click());
184 cy.get(`[data-id=${testCollection.uuid}]`)
185 .find('input[type=checkbox]').click();
187 cy.get(`[data-id=${testCollection2.uuid}]`)
188 .find('input[type=checkbox]').click();
190 cy.get('[data-cy=ok-button]').click();
194 cy.get('label').contains('foo').parent('div')
200 cy.get('label').contains('bar').parent('div')
202 cy.contains(testCollection.name);
203 cy.contains(testCollection2.name);
208 it('allows selecting collection subdirectories and reselects existing selections', () => {
210 owningUser: activeUser,
211 projectName: 'myProject1',
215 cy.createCollection(adminUser.token, {
216 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
217 owner_uuid: activeUser.user.uuid,
218 manifest_text: "./subdir/dir1 d41d8cd98f00b204e9800998ecf8427e+0 0:0:\\056\n./subdir/dir2 d41d8cd98f00b204e9800998ecf8427e+0 0:0:\\056\n"
220 .as('testCollection');
222 cy.getAll('@myProject1', '@testCollection')
223 .then(function ([myProject1, testCollection]) {
224 cy.readFile('cypress/fixtures/workflow_directory_array.yaml').then(workflow => {
225 cy.createWorkflow(adminUser.token, {
226 name: `TestWorkflow${Math.floor(Math.random() * 999999)}.cwl`,
227 definition: workflow,
228 owner_uuid: myProject1.uuid,
233 cy.loginAs(activeUser);
235 cy.get('main').contains(myProject1.name).click();
237 cy.get('[data-cy=side-panel-button]').click();
239 cy.get('#aside-menu-list').contains('Run a workflow').click();
241 cy.get('@testWorkflow')
242 .then((testWorkflow) => {
243 cy.get('main').contains(testWorkflow.name).click();
244 cy.get('[data-cy=run-process-next-button]').click();
246 cy.get('label').contains('directoryInputName').parent('div').find('input').click();
247 cy.get('div[role=dialog]')
249 // must use .then to avoid selecting instead of expanding https://github.com/cypress-io/cypress/issues/5529
250 cy.get('p').contains('Home Projects').closest('ul')
252 .then(el => el.click());
254 cy.get(`[data-id=${testCollection.uuid}]`)
257 cy.get(`[data-id="${testCollection.uuid}/subdir"]`)
260 cy.contains('dir1').closest('[data-action=TOGGLE_ACTIVE]').parent().find('input[type=checkbox]').click();
261 cy.contains('dir2').closest('[data-action=TOGGLE_ACTIVE]').parent().find('input[type=checkbox]').click();
263 cy.get('[data-cy=ok-button]').click();
266 // Verify subdirectories were selected
267 cy.get('label').contains('directoryInputName').parent('div')
273 // Reopen tree picker and verify subdirectories are preselected
274 cy.get('label').contains('directoryInputName').parent('div').find('input').click();
275 cy.waitForDom().get('div[role=dialog]')
277 cy.contains('dir1').closest('[data-action=TOGGLE_ACTIVE]').parent().find('input[type=checkbox]').should('be.checked');
278 cy.contains('dir2').closest('[data-action=TOGGLE_ACTIVE]').parent().find('input[type=checkbox]').should('be.checked');