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('activeuser', 'Active', 'User', false, true)
16 .as('activeUser').then(function () {
17 activeUser = this.activeUser;
22 function createNestedHelper(testRemainder) {
23 cy.createGroup(adminUser.token, {
24 group_class: "project",
25 name: `Test project (${Math.floor(Math.random() * 999999)})`,
28 cy.get('@project1').then(() => {
29 cy.createGroup(adminUser.token, {
30 group_class: "project",
31 name: `Test project (${Math.floor(Math.random() * 999999)})`,
32 owner_uuid: this.project1.uuid,
36 cy.get('@project2').then(() => {
37 cy.createGroup(adminUser.token, {
38 group_class: "project",
39 name: `Test project (${Math.floor(Math.random() * 999999)})`,
40 owner_uuid: this.project2.uuid,
44 cy.get('@project3').then(() => {
45 cy.createWorkflow(adminUser.token, {
46 name: `TestWorkflow${Math.floor(Math.random() * 999999)}.cwl`,
47 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}",
51 cy.createCollection(adminUser.token, {
52 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
53 owner_uuid: this.project3.uuid,
54 manifest_text: "./subdir 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo\n. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:baz\n"
56 .as('testCollection');
59 cy.get('@testWorkflow').then(() => {
60 cy.loginAs(adminUser);
62 cy.get('[data-cy=side-panel-button]').click();
63 cy.get('[data-cy=side-panel-run-process]').click();
65 cy.get('.layout-pane')
66 .contains(this.testWorkflow.name)
69 cy.get('[data-cy=run-process-next-button]').click();
71 cy.get('[data-cy=new-process-panel]').contains('Run workflow').should('be.disabled');
73 cy.get('[data-cy=new-process-panel]')
75 cy.get('[name=name]').type(`Workflow name (${Math.floor(Math.random() * 999999)})`);
76 cy.contains('input').next().click();
81 cy.get('[data-cy=new-process-panel]')
82 .find('button').contains('Run workflow').should('not.be.disabled');
86 it.only('can create project with nested data', function () {
87 this.createNestedHelper = createNestedHelper;
88 this.createNestedHelper(() => {
89 cy.get('[data-cy=choose-a-file-dialog]').as('chooseFileDialog');
90 cy.get('@chooseFileDialog').contains('Home Projects')
91 .parents('[data-cy=tree-li]')
92 .find('[data-cy=side-panel-arrow-icon]')
95 cy.get('@project1').then((project1) => {
96 cy.get('@chooseFileDialog').find(`[data-id=${project1.uuid}]`);
97 cy.get('@chooseFileDialog')
98 .find(`[data-id=${project1.uuid}]`)
99 .find('[data-action=TOGGLE_ACTIVE]')
101 cy.get('[data-cy=picker-dialog-details]')
102 .contains("Project");
103 cy.get('[data-cy=picker-dialog-details]')
104 .contains(project1.uuid);
105 cy.get('@chooseFileDialog')
106 .find(`[data-id=${project1.uuid}]`)
107 .find('[data-action=TOGGLE_OPEN]')
111 cy.get('@project2').then((project2) => {
112 cy.get('@chooseFileDialog').find(`[data-id=${project2.uuid}]`);
113 cy.get('@chooseFileDialog')
114 .find(`[data-id=${project2.uuid}]`)
115 .find('[data-action=TOGGLE_ACTIVE]')
117 cy.get('[data-cy=picker-dialog-details]')
118 .contains("Project");
119 cy.get('[data-cy=picker-dialog-details]')
120 .contains(project2.uuid);
121 cy.get('@chooseFileDialog')
122 .find(`[data-id=${project2.uuid}]`)
123 .find('[data-action=TOGGLE_OPEN]')
127 cy.get('@project3').then((project3) => {
128 cy.get('@chooseFileDialog').find(`[data-id=${project3.uuid}]`);
129 cy.get('@chooseFileDialog')
130 .find(`[data-id=${project3.uuid}]`)
131 .find('[data-action=TOGGLE_ACTIVE]')
133 cy.get('[data-cy=picker-dialog-details]')
134 .contains("Project");
135 cy.get('[data-cy=picker-dialog-details]')
136 .contains(project3.uuid);
137 cy.get('@chooseFileDialog')
138 .find(`[data-id=${project3.uuid}]`)
139 .find('[data-action=TOGGLE_OPEN]')
143 cy.get('@testCollection').then((testCollection) => {
144 cy.get('@chooseFileDialog').find(`[data-id=${testCollection.uuid}]`);
145 cy.get('@chooseFileDialog')
146 .find(`[data-id=${testCollection.uuid}]`)
147 .find('[data-action=TOGGLE_ACTIVE]')
149 cy.get('[data-cy=picker-dialog-details]')
150 .contains("Collection");
151 cy.get('[data-cy=picker-dialog-details]')
152 .contains(testCollection.uuid);
153 cy.get('@chooseFileDialog')
154 .find(`[data-id=${testCollection.uuid}]`)
155 .find('[data-action=TOGGLE_OPEN]')
159 cy.get('@chooseFileDialog').contains('baz').click();
160 cy.get('[data-cy=picker-dialog-details]')
163 cy.get('@chooseFileDialog').find('button').contains('Ok').click();
167 it('can search for nested project by name', function () {
168 this.createNestedHelper = createNestedHelper;
169 this.createNestedHelper(() => {
170 cy.get('[data-cy=choose-a-file-dialog]').as('chooseFileDialog');
172 cy.get('@project3').then((project3) => {
173 cy.get('[data-cy=picker-dialog-project-search]')
174 .find('[data-cy=search-input]')
179 cy.get('@chooseFileDialog').find(`[data-id=${project3.uuid}]`).find('i').click();
181 cy.get('@testCollection').then((testCollection) => {
182 cy.get('@chooseFileDialog').find(`[data-id=${testCollection.uuid}]`).find('i').click();
185 cy.get('@chooseFileDialog').contains('baz').click();
187 cy.get('@chooseFileDialog').find('button').contains('Ok').click();
192 it('can search for nested project by uuid', function () {
193 this.createNestedHelper = createNestedHelper;
194 this.createNestedHelper(() => {
195 cy.get('[data-cy=choose-a-file-dialog]').as('chooseFileDialog');
197 cy.get('@project3').then((project3) => {
198 cy.get('[data-cy=picker-dialog-project-search]')
199 .find('[data-cy=search-input]')
204 cy.get('@chooseFileDialog').find(`[data-id=${project3.uuid}]`).find('i').click();
206 cy.get('@testCollection').then((testCollection) => {
207 cy.get('@chooseFileDialog').find(`[data-id=${testCollection.uuid}]`).find('i').click();
210 cy.get('@chooseFileDialog').contains('baz').click();
212 cy.get('@chooseFileDialog').find('button').contains('Ok').click();
218 it('can search for collection by name', function () {
219 this.createNestedHelper = createNestedHelper;
220 this.createNestedHelper(() => {
221 cy.get('[data-cy=choose-a-file-dialog]').as('chooseFileDialog');
223 cy.get('@testCollection').then((testCollection) => {
224 cy.get('[data-cy=picker-dialog-collection-search]')
225 .find('[data-cy=search-input]')
226 .type(testCollection.name)
230 cy.get('@testCollection').then((testCollection) => {
231 cy.get('@chooseFileDialog').find(`[data-id=${testCollection.uuid}]`).find('i').click();
234 cy.get('@chooseFileDialog').contains('baz').click();
236 cy.get('@chooseFileDialog').find('button').contains('Ok').click();
241 it('can search for collection by uuid', function () {
242 this.createNestedHelper = createNestedHelper;
243 this.createNestedHelper(() => {
244 cy.get('[data-cy=choose-a-file-dialog]').as('chooseFileDialog');
246 cy.get('@testCollection').then((testCollection) => {
247 cy.get('[data-cy=picker-dialog-collection-search]')
248 .find('[data-cy=search-input]')
249 .type(testCollection.uuid)
253 cy.get('@testCollection').then((testCollection) => {
254 cy.get('@chooseFileDialog').find(`[data-id=${testCollection.uuid}]`).find('i').click();
257 cy.get('@chooseFileDialog').contains('baz').click();
259 cy.get('@chooseFileDialog').find('button').contains('Ok').click();
264 it('can search for collection by PDH', function () {
265 this.createNestedHelper = createNestedHelper;
266 this.createNestedHelper(() => {
267 cy.get('[data-cy=choose-a-file-dialog]').as('chooseFileDialog');
269 cy.get('@testCollection').then((testCollection) => {
270 cy.get('[data-cy=picker-dialog-collection-search]')
271 .find('[data-cy=search-input]')
272 .type(testCollection.portable_data_hash)
276 cy.get('@testCollection').then((testCollection) => {
277 cy.get('@chooseFileDialog').find(`[data-id=${testCollection.uuid}]`).find('i').click();
280 cy.get('@chooseFileDialog').contains('baz').click();
282 cy.get('@chooseFileDialog').find('button').contains('Ok').click();
287 ['workflow_with_array_fields.yaml', 'workflow_with_default_array_fields.yaml'].forEach((yamlfile) =>
288 it('can select multi files when creating workflow '+yamlfile, () => {
290 owningUser: activeUser,
291 projectName: 'myProject1',
295 cy.createCollection(adminUser.token, {
296 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
297 owner_uuid: activeUser.user.uuid,
298 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:baz\n"
300 .as('testCollection');
302 cy.createCollection(adminUser.token, {
303 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
304 owner_uuid: activeUser.user.uuid,
305 manifest_text: `. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:buz\n`
307 .as('testCollection2');
309 cy.getAll('@myProject1', '@testCollection', '@testCollection2')
310 .then(function ([myProject1, testCollection, testCollection2]) {
311 cy.readFile('cypress/fixtures/'+yamlfile).then(workflow => {
312 cy.createWorkflow(adminUser.token, {
313 name: `TestWorkflow${Math.floor(Math.random() * 999999)}.cwl`,
314 definition: workflow,
315 owner_uuid: myProject1.uuid,
320 cy.loginAs(activeUser);
322 cy.get('main').contains(myProject1.name).click();
326 cy.get('[data-cy=side-panel-button]').click();
328 cy.get('#aside-menu-list').contains('Run a workflow').click();
330 cy.get('@testWorkflow')
331 .then((testWorkflow) => {
332 cy.get('main').contains(testWorkflow.name).click();
333 cy.get('[data-cy=run-process-next-button]').click();
335 cy.get('label').contains('foo').parent('div').find('input').click();
336 cy.get('div[role=dialog]')
338 // must use .then to avoid selecting instead of expanding https://github.com/cypress-io/cypress/issues/5529
339 cy.get('p').contains('Home Projects').closest('ul')
341 .then(el => el.click());
343 cy.get(`[data-id=${testCollection.uuid}]`)
347 cy.contains('bar').closest('[data-action=TOGGLE_ACTIVE]').parent().find('input[type=checkbox]').click();
348 cy.contains('baz').closest('[data-action=TOGGLE_ACTIVE]').parent().find('input[type=checkbox]').click();
350 cy.get('[data-cy=ok-button]').click();
353 cy.get('label').contains('bar').parent('div').find('input').click();
354 cy.get('div[role=dialog]')
356 // must use .then to avoid selecting instead of expanding https://github.com/cypress-io/cypress/issues/5529
357 cy.get('p').contains('Home Projects').closest('ul')
359 .then(el => el.click());
361 cy.get(`[data-id=${testCollection.uuid}]`)
362 .find('input[type=checkbox]').click();
364 cy.get(`[data-id=${testCollection2.uuid}]`)
365 .find('input[type=checkbox]').click();
367 cy.get('[data-cy=ok-button]').click();
371 cy.get('label').contains('foo').parent('div')
377 cy.get('label').contains('bar').parent('div')
379 cy.contains(testCollection.name);
380 cy.contains(testCollection2.name);
385 it('allows selecting collection subdirectories and reselects existing selections', () => {
387 owningUser: activeUser,
388 projectName: 'myProject1',
392 cy.createCollection(adminUser.token, {
393 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
394 owner_uuid: activeUser.user.uuid,
395 manifest_text: "./subdir/dir1 d41d8cd98f00b204e9800998ecf8427e+0 0:0:\\056\n./subdir/dir2 d41d8cd98f00b204e9800998ecf8427e+0 0:0:\\056\n"
397 .as('testCollection');
399 cy.getAll('@myProject1', '@testCollection')
400 .then(function ([myProject1, testCollection]) {
401 cy.readFile('cypress/fixtures/workflow_directory_array.yaml').then(workflow => {
402 cy.createWorkflow(adminUser.token, {
403 name: `TestWorkflow${Math.floor(Math.random() * 999999)}.cwl`,
404 definition: workflow,
405 owner_uuid: myProject1.uuid,
410 cy.loginAs(activeUser);
412 cy.get('main').contains(myProject1.name).click();
414 cy.get('[data-cy=side-panel-button]').click();
416 cy.get('#aside-menu-list').contains('Run a workflow').click();
418 cy.get('@testWorkflow')
419 .then((testWorkflow) => {
420 cy.get('main').contains(testWorkflow.name).click();
421 cy.get('[data-cy=run-process-next-button]').click();
423 cy.get('label').contains('directoryInputName').parent('div').find('input').click();
424 cy.get('div[role=dialog]')
426 // must use .then to avoid selecting instead of expanding https://github.com/cypress-io/cypress/issues/5529
427 cy.get('p').contains('Home Projects').closest('ul')
429 .then(el => el.click());
431 cy.get(`[data-id=${testCollection.uuid}]`)
434 cy.get(`[data-id="${testCollection.uuid}/subdir"]`)
437 cy.contains('dir1').closest('[data-action=TOGGLE_ACTIVE]').parent().find('input[type=checkbox]').click();
438 cy.contains('dir2').closest('[data-action=TOGGLE_ACTIVE]').parent().find('input[type=checkbox]').click();
440 cy.get('[data-cy=ok-button]').click();
443 // Verify subdirectories were selected
444 cy.get('label').contains('directoryInputName').parent('div')
450 // Reopen tree picker and verify subdirectories are preselected
451 cy.get('label').contains('directoryInputName').parent('div').find('input').click();
452 cy.waitForDom().get('div[role=dialog]')
454 cy.contains('dir1').closest('[data-action=TOGGLE_ACTIVE]').parent().find('input[type=checkbox]').should('be.checked');
455 cy.contains('dir2').closest('[data-action=TOGGLE_ACTIVE]').parent().find('input[type=checkbox]').should('be.checked');
462 it('handles secret inputs', () => {
464 owningUser: activeUser,
465 projectName: 'myProject1',
469 cy.setupDockerImage("arvados/jobs").as("dockerImg");
471 cy.getAll('@myProject1').then(function ([myProject1]) {
472 cy.readFile('cypress/fixtures/workflow_with_secret_input.yaml').then(workflow => {
473 cy.createWorkflow(adminUser.token, {
474 name: `TestWorkflow${Math.floor(Math.random() * 999999)}.cwl`,
475 definition: workflow,
476 owner_uuid: myProject1.uuid,
481 cy.loginAs(activeUser);
483 cy.get('main').contains(myProject1.name).click();
485 cy.get('[data-cy=side-panel-button]').click();
487 cy.get('#aside-menu-list').contains('Run a workflow').click();
489 cy.get('@testWorkflow')
490 .then((testWorkflow) => {
491 cy.get('main').contains(testWorkflow.name).click();
492 cy.get('[data-cy=run-process-next-button]').click();
494 var foo = cy.get('label').contains('foo').parent('div').find('input');
495 foo.type("secret_value_xyz");
496 foo.should('have.attr', 'type').and('equal', 'password');
498 var bar = cy.get('label').contains('bar').parent('div').find('input');
499 bar.type("exposed_value_xyz");
500 bar.should('have.attr', 'type').and('equal', 'text');
502 cy.get('[data-cy=new-process-panel]').contains('Run workflow').click();
504 cy.get('[data-cy=process-io-card]').should('contain', 'exposed_value_xyz');
505 cy.get('[data-cy=process-io-card]').should('contain', 'Cannot display secret');
506 cy.get('[data-cy=process-io-card]').should('not.contain', 'secret_value_xyz');
508 cy.url().then((url) => {
509 let uuid = url.split('/').pop();
510 cy.getResource(activeUser.token, "container_requests", uuid).then((res) => {
511 expect(res.mounts["/var/lib/cwl/cwl.input.json"].content.bar).to.equal('exposed_value_xyz');
512 expect(res.mounts["/var/lib/cwl/cwl.input.json"].content.foo).to.deep.equal({$include: '/secrets/s0'});