17306: Added configurable options for favorite tree
[arvados-workbench2.git] / cypress / integration / favorites.spec.js
index 695812ca1abbcd9e9fa8d452ca33f56bd957cf92..a7ff4d6e63cb65499fea1b5ceff9343dd240ca9a 100644 (file)
@@ -51,19 +51,18 @@ describe('Favorites tests', function () {
         });
     });
 
-    it.only('can copy collection to favorites', () => {
+    it('can copy collection to favorites', () => {
         cy.loginAs(adminUser);
 
         cy.createGroup(adminUser.token, {
             name: `my-shared-writable-project ${Math.floor(Math.random() * 999999)}`,
             group_class: 'project',
-        }).as('mySharedProject1').then(function () {
+        }).as('mySharedProject1').then(function (mySharedProject1) {
             cy.contains('Refresh').click();
-            cy.get('main').contains(this.mySharedProject1.name).rightclick();
+            cy.get('main').contains(mySharedProject1.name).rightclick();
             cy.get('[data-cy=context-menu]').within(() => {
                 cy.contains('Share').click();
             });
-            cy.wait(1000);
             cy.get('[id="select-permissions"]').as('selectPermissions');
             cy.get('@selectPermissions').click();
             cy.contains('Write').click();
@@ -76,13 +75,12 @@ describe('Favorites tests', function () {
         cy.createGroup(adminUser.token, {
             name: `my-shared-readonly-project ${Math.floor(Math.random() * 999999)}`,
             group_class: 'project',
-        }).as('mySharedProject2').then(function () {
+        }).as('mySharedProject2').then(function (mySharedProject2) {
             cy.contains('Refresh').click();
-            cy.get('main').contains(this.mySharedProject2.name).rightclick();
+            cy.get('main').contains(mySharedProject2.name).rightclick();
             cy.get('[data-cy=context-menu]').within(() => {
                 cy.contains('Share').click();
             });
-            cy.wait(1000);
             cy.get('.sharing-dialog').as('sharingDialog');
             cy.get('@sharingDialog').find('input').first().type(activeUser.user.email);
             cy.get('[role=tooltip]').click();
@@ -94,51 +92,48 @@ describe('Favorites tests', function () {
             group_class: 'project',
         }).as('myProject1');
 
-        cy.get('@mySharedProject1').then(function () {
-            cy.get('@mySharedProject2').then(function () {
-                cy.get('@myProject1').then(function () {
-                    cy.createCollection(adminUser.token, {
-                        name: `Test collection ${Math.floor(Math.random() * 999999)}`,
-                        owner_uuid: activeUser.user.uuid,
-                        manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
-                    })
-                        .as('testCollection').then(function () {
-                            cy.loginAs(activeUser);
-
-                            cy.contains('Shared with me').click();
-
-                            cy.get('main').contains(this.mySharedProject1.name).rightclick();
-                            cy.get('[data-cy=context-menu]').within(() => {
-                                cy.contains('Add to favorites').click();
-                            });
-
-                            cy.get('main').contains(this.mySharedProject2.name).rightclick();
-                            cy.get('[data-cy=context-menu]').within(() => {
-                                cy.contains('Add to favorites').click();
-                            });
-
-                            cy.doSearch(`${activeUser.user.uuid}`);
-
-                            cy.get('main').contains(this.myProject1.name).rightclick();
-                            cy.get('[data-cy=context-menu]').within(() => {
-                                cy.contains('Add to favorites').click();
-                            });    
-
-                            cy.contains(this.testCollection.name).rightclick();
-                            cy.get('[data-cy=context-menu]').within(() => {
-                                cy.contains('Move to').click();
-                            });
-
-                            cy.get('[data-cy=form-dialog]').within(function() {
-                                cy.get('ul').last().find('i').click();
-                                cy.contains(this.myProject1.name);
-                                cy.contains(this.mySharedProject1.name);
-                                cy.get('ul').last()
-                                    .should('not.contain', this.mySharedProject2.name);
-                            });
-                        });
+        cy.createCollection(adminUser.token, {
+            name: `Test collection ${Math.floor(Math.random() * 999999)}`,
+            owner_uuid: activeUser.user.uuid,
+            manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
+        })
+            .as('testCollection');
+
+        cy.getAll('@mySharedProject1', '@mySharedProject2', '@myProject1', '@testCollection')
+            .then(function ([mySharedProject1, mySharedProject2, myProject1, testCollection]) {
+                cy.loginAs(activeUser);
+
+                cy.contains('Shared with me').click();
+
+                cy.get('main').contains(mySharedProject1.name).rightclick();
+                cy.get('[data-cy=context-menu]').within(() => {
+                    cy.contains('Add to favorites').click();
+                });
+
+                cy.get('main').contains(mySharedProject2.name).rightclick();
+                cy.get('[data-cy=context-menu]').within(() => {
+                    cy.contains('Add to favorites').click();
+                });
+
+                cy.doSearch(`${activeUser.user.uuid}`);
+
+                cy.get('main').contains(myProject1.name).rightclick();
+                cy.get('[data-cy=context-menu]').within(() => {
+                    cy.contains('Add to favorites').click();
+                });
+
+                cy.contains(testCollection.name).rightclick();
+                cy.get('[data-cy=context-menu]').within(() => {
+                    cy.contains('Move to').click();
+                });
+
+                cy.get('[data-cy=form-dialog]').within(function () {
+                    cy.get('ul').last().find('i').click();
+                    cy.contains(myProject1.name);
+                    cy.contains(mySharedProject1.name);
+                    cy.get('ul').last()
+                        .should('not.contain', mySharedProject2.name);
                 });
             });
-        });
     });
-})
+});
\ No newline at end of file