Merge branch '21128-toolbar-context-menu'
[arvados-workbench2.git] / cypress / integration / create-workflow.spec.js
index 4da747578c8aad449e490b3466d6e8a66c1bae63..e6469039348338873aef4df1337556ffe3397cd5 100644 (file)
@@ -2,7 +2,7 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-describe('Multi-file deletion tests', function () {
+describe('Create workflow tests', function () {
     let activeUser;
     let adminUser;
 
@@ -64,9 +64,6 @@ describe('Multi-file deletion tests', function () {
         cy.get('@testWorkflow').then(() => {
             cy.loginAs(adminUser);
 
-            cy.get('[data-cy=linear-progress]').should('exist');
-            cy.get('[data-cy=linear-progress]').should('not.exist');
-
             cy.get('[data-cy=side-panel-button]').click();
             cy.get('[data-cy=side-panel-run-process]').click();
 
@@ -76,16 +73,16 @@ describe('Multi-file deletion tests', function () {
 
             cy.get('[data-cy=run-process-next-button]').click();
 
-            cy.get('[data-cy=new-process-panel]').contains('Run Process').should('be.disabled');
+            cy.get('[data-cy=new-process-panel]').contains('Run workflow').should('be.disabled');
 
             cy.get('[data-cy=new-process-panel]')
                 .within(() => {
                     cy.get('[name=name]').type(`Workflow name (${Math.floor(Math.random() * 999999)})`);
-                    cy.get('[readonly]').click();
+                    cy.contains('input').next().click();
                 });
 
             cy.get('[data-cy=choose-a-file-dialog]').as('chooseFileDialog');
-            cy.get('@chooseFileDialog').contains('Projects').closest('ul').find('i').click();
+            cy.get('@chooseFileDialog').contains('Home Projects').closest('ul').find('i').click();
 
             cy.get('@project1').then((project1) => {
                 cy.get('@chooseFileDialog').find(`[data-id=${project1.uuid}]`).find('i').click();
@@ -108,7 +105,7 @@ describe('Multi-file deletion tests', function () {
             cy.get('@chooseFileDialog').find('button').contains('Ok').click();
 
             cy.get('[data-cy=new-process-panel]')
-                .find('button').contains('Run Process').should('not.be.disabled');
+                .find('button').contains('Run workflow').should('not.be.disabled');
         });
     });
 
@@ -151,40 +148,38 @@ describe('Multi-file deletion tests', function () {
 
                 cy.get('[data-cy=side-panel-button]').click();
 
-                cy.get('#aside-menu-list').contains('Run a process').click();
+                cy.get('#aside-menu-list').contains('Run a workflow').click();
 
                 cy.get('@testWorkflow')
                     .then((testWorkflow) => {
                         cy.get('main').contains(testWorkflow.name).click();
                         cy.get('[data-cy=run-process-next-button]').click();
 
-                        cy.get('label').contains('#main/foo').parent('div').find('input').click();
+                        cy.get('label').contains('foo').parent('div').find('input').click();
                         cy.get('div[role=dialog]')
                             .within(() => {
-                                cy.get('p').contains('Projects').closest('div[role=button]')
-                                    .within(() => {
-                                        cy.get('svg[role=presentation]')
-                                            .click({ multiple: true });
-                                    });
+                                // must use .then to avoid selecting instead of expanding https://github.com/cypress-io/cypress/issues/5529
+                                cy.get('p').contains('Home Projects').closest('ul')
+                                    .find('i')
+                                    .then(el => el.click());
 
                                 cy.get(`[data-id=${testCollection.uuid}]`)
                                     .find('i').click();
 
+                                cy.wait(1000);
                                 cy.contains('bar').closest('[data-action=TOGGLE_ACTIVE]').parent().find('input[type=checkbox]').click();
-
                                 cy.contains('baz').closest('[data-action=TOGGLE_ACTIVE]').parent().find('input[type=checkbox]').click();
 
                                 cy.get('[data-cy=ok-button]').click();
                             });
 
-                        cy.get('label').contains('#main/bar').parent('div').find('input').click();
+                        cy.get('label').contains('bar').parent('div').find('input').click();
                         cy.get('div[role=dialog]')
                             .within(() => {
-                                cy.get('p').contains('Projects').closest('div[role=button]')
-                                    .within(() => {
-                                        cy.get('svg[role=presentation]')
-                                            .click({ multiple: true });
-                                    });
+                                // must use .then to avoid selecting instead of expanding https://github.com/cypress-io/cypress/issues/5529
+                                cy.get('p').contains('Home Projects').closest('ul')
+                                    .find('i')
+                                    .then(el => el.click());
 
                                 cy.get(`[data-id=${testCollection.uuid}]`)
                                     .find('input[type=checkbox]').click();
@@ -196,17 +191,94 @@ describe('Multi-file deletion tests', function () {
                             });
                     });
 
-                cy.get('label').contains('#main/foo').parent('div')
+                cy.get('label').contains('foo').parent('div')
                     .within(() => {
                         cy.contains('baz');
                         cy.contains('bar');
                     });
 
-                cy.get('label').contains('#main/bar').parent('div')
+                cy.get('label').contains('bar').parent('div')
                     .within(() => {
                         cy.contains(testCollection.name);
                         cy.contains(testCollection2.name);
                     });
             });
     }));
+
+    it('allows selecting collection subdirectories and reselects existing selections', () => {
+        cy.createProject({
+            owningUser: activeUser,
+            projectName: 'myProject1',
+            addToFavorites: true
+        });
+
+        cy.createCollection(adminUser.token, {
+            name: `Test collection ${Math.floor(Math.random() * 999999)}`,
+            owner_uuid: activeUser.user.uuid,
+            manifest_text: "./subdir/dir1 d41d8cd98f00b204e9800998ecf8427e+0 0:0:\\056\n./subdir/dir2 d41d8cd98f00b204e9800998ecf8427e+0 0:0:\\056\n"
+        })
+            .as('testCollection');
+
+        cy.getAll('@myProject1', '@testCollection')
+            .then(function ([myProject1, testCollection]) {
+                cy.readFile('cypress/fixtures/workflow_directory_array.yaml').then(workflow => {
+                    cy.createWorkflow(adminUser.token, {
+                        name: `TestWorkflow${Math.floor(Math.random() * 999999)}.cwl`,
+                        definition: workflow,
+                        owner_uuid: myProject1.uuid,
+                    })
+                        .as('testWorkflow');
+                });
+
+                cy.loginAs(activeUser);
+
+                cy.get('main').contains(myProject1.name).click();
+
+                cy.get('[data-cy=side-panel-button]').click();
+
+                cy.get('#aside-menu-list').contains('Run a workflow').click();
+
+                cy.get('@testWorkflow')
+                    .then((testWorkflow) => {
+                        cy.get('main').contains(testWorkflow.name).click();
+                        cy.get('[data-cy=run-process-next-button]').click();
+
+                        cy.get('label').contains('directoryInputName').parent('div').find('input').click();
+                        cy.get('div[role=dialog]')
+                            .within(() => {
+                                // must use .then to avoid selecting instead of expanding https://github.com/cypress-io/cypress/issues/5529
+                                cy.get('p').contains('Home Projects').closest('ul')
+                                    .find('i')
+                                    .then(el => el.click());
+
+                                cy.get(`[data-id=${testCollection.uuid}]`)
+                                    .find('i').click();
+
+                                cy.get(`[data-id="${testCollection.uuid}/subdir"]`)
+                                    .find('i').click();
+
+                                cy.contains('dir1').closest('[data-action=TOGGLE_ACTIVE]').parent().find('input[type=checkbox]').click();
+                                cy.contains('dir2').closest('[data-action=TOGGLE_ACTIVE]').parent().find('input[type=checkbox]').click();
+
+                                cy.get('[data-cy=ok-button]').click();
+                            });
+
+                        // Verify subdirectories were selected
+                        cy.get('label').contains('directoryInputName').parent('div')
+                            .within(() => {
+                                cy.contains('dir1');
+                                cy.contains('dir2');
+                            });
+
+                        // Reopen tree picker and verify subdirectories are preselected
+                        cy.get('label').contains('directoryInputName').parent('div').find('input').click();
+                        cy.waitForDom().get('div[role=dialog]')
+                            .within(() => {
+                                cy.contains('dir1').closest('[data-action=TOGGLE_ACTIVE]').parent().find('input[type=checkbox]').should('be.checked');
+                                cy.contains('dir2').closest('[data-action=TOGGLE_ACTIVE]').parent().find('input[type=checkbox]').should('be.checked');
+                            });
+                    });
+
+            });
+    })
 })