16811: Add cypress test for setting/unsetting public favorite
authorPeter Amstutz <peter.amstutz@curii.com>
Fri, 18 Sep 2020 22:35:38 +0000 (18:35 -0400)
committerPeter Amstutz <peter.amstutz@curii.com>
Fri, 18 Sep 2020 22:35:38 +0000 (18:35 -0400)
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz@curii.com>

README.md
cypress/integration/favorites.js [new file with mode: 0644]
cypress/support/commands.js

index 38a26e54bf6a39399a3a46c349abdeb028c73ca6..55e96af3c14e2d764dac391a2c632137567e293d 100644 (file)
--- a/README.md
+++ b/README.md
@@ -31,6 +31,17 @@ make integration-tests
 make integration-tests-in-docker
 </pre>
 
 make integration-tests-in-docker
 </pre>
 
+### Run tests interactively in container
+
+<pre>
+$ xhost +local:root
+$ ARVADOS_DIR=/path/to/arvados
+$ docker run -ti -v$PWD:$PWD -v$ARVADOS_DIR:/usr/src/arvados -w$PWD --env="DISPLAY" --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" workbench2-build /bin/bash
+(inside container)
+# yarn run cypress install
+# tools/run-integration-tests.sh -i -a /usr/src/arvados
+</pre>
+
 ### Production build
 <pre>
 yarn install
 ### Production build
 <pre>
 yarn install
diff --git a/cypress/integration/favorites.js b/cypress/integration/favorites.js
new file mode 100644 (file)
index 0000000..8ef4899
--- /dev/null
@@ -0,0 +1,47 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+describe('Collection panel tests', function() {
+    let activeUser;
+    let adminUser;
+
+    before(function() {
+        // Only set up common users once. These aren't set up as aliases because
+        // aliases are cleaned up after every test. Also it doesn't make sense
+        // to set the same users on beforeEach() over and over again, so we
+        // separate a little from Cypress' 'Best Practices' here.
+        cy.getUser('admin', 'Admin', 'User', true, true)
+            .as('adminUser').then(function() {
+                adminUser = this.adminUser;
+            }
+        );
+        cy.getUser('collectionuser1', 'Collection', 'User', false, true)
+            .as('activeUser').then(function() {
+                activeUser = this.activeUser;
+            }
+        );
+    })
+
+    beforeEach(function() {
+        cy.clearCookies()
+        cy.clearLocalStorage()
+    })
+
+    it('creates and removes a public favorite', function() {
+        cy.loginAs(adminUser);
+            cy.createGroup(adminUser.token, {
+                name: `my-favorite-project`,
+                group_class: 'project',
+            }).as('myFavoriteProject').then(function() {
+                cy.contains('Refresh').click();
+                cy.get('main').contains('my-favorite-project').rightclick();
+                cy.contains('Add to public favorites').click();
+                cy.contains('Public Favorites').click();
+                cy.get('main').contains('my-favorite-project').rightclick();
+                cy.contains('Remove from public favorites').click();
+                cy.get('main').contains('my-favorite-project').should('not.exist');
+                cy.trashGroup(adminUser.token, this.myFavoriteProject.uuid);
+            });
+    })
+})
index 8baa2db6e58398b969ecd97fdb3bc6a481ef5d3e..fd5139981fc421cf4304548c8c9980841b273710 100644 (file)
@@ -110,6 +110,12 @@ Cypress.Commands.add(
     }
 )
 
     }
 )
 
+Cypress.Commands.add(
+    "trashGroup", (token, uuid) => {
+        return cy.deleteResource(token, 'groups', uuid);
+    }
+)
+
 Cypress.Commands.add(
     "createCollection", (token, data) => {
         return cy.createResource(token, 'collections', {
 Cypress.Commands.add(
     "createCollection", (token, data) => {
         return cy.createResource(token, 'collections', {
@@ -129,6 +135,16 @@ Cypress.Commands.add(
     }
 )
 
     }
 )
 
+Cypress.Commands.add(
+    "deleteResource", (token, suffix, uuid) => {
+        return cy.doRequest('DELETE', '/arvados/v1/'+suffix+'/'+uuid)
+        .its('body').as('resource')
+        .then(function() {
+            return this.resource;
+        })
+    }
+)
+
 Cypress.Commands.add(
     "loginAs", (user) => {
         cy.visit(`/token/?api_token=${user.token}`);
 Cypress.Commands.add(
     "loginAs", (user) => {
         cy.visit(`/token/?api_token=${user.token}`);
@@ -136,4 +152,4 @@ Cypress.Commands.add(
         cy.get('div#root').should('contain', 'Arvados Workbench (zzzzz)');
         cy.get('div#root').should('not.contain', 'Your account is inactive');
     }
         cy.get('div#root').should('contain', 'Arvados Workbench (zzzzz)');
         cy.get('div#root').should('not.contain', 'Your account is inactive');
     }
-)
\ No newline at end of file
+)