16118: Adds collection's integration test suite (WIP)
authorLucas Di Pentima <lucas@di-pentima.com.ar>
Mon, 11 May 2020 19:50:21 +0000 (16:50 -0300)
committerLucas Di Pentima <lucas@di-pentima.com.ar>
Mon, 11 May 2020 19:50:21 +0000 (16:50 -0300)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas@di-pentima.com.ar>

cypress/integration/collection-panel.spec.js [new file with mode: 0644]
cypress/support/commands.js

diff --git a/cypress/integration/collection-panel.spec.js b/cypress/integration/collection-panel.spec.js
new file mode 100644 (file)
index 0000000..287bfe1
--- /dev/null
@@ -0,0 +1,48 @@
+// 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('shows a collection by URL', function() {
+        cy.loginAs(activeUser);
+        cy.createCollection(adminUser.token, {
+            name: 'Test collection',
+            owner_uuid: activeUser.user.uuid,
+            manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"})
+        .as('testCollection').then(function() {
+            cy.visit(`/collections/${this.testCollection.uuid}`);
+            cy.get('[data-cy=collection-info-panel]')
+                .should('contain', this.testCollection.name)
+                .and('contain', this.testCollection.uuid);
+            cy.get('[data-cy=collection-files-panel]')
+                .should('contain', 'bar');
+        })
+    })
+
+    // it('')
+})
\ No newline at end of file
index 68ce687059d6feb3553d4a3b671deb589de889ab..8c6fd46293860ea52cf326cb56c87b6df045070e 100644 (file)
@@ -92,3 +92,25 @@ Cypress.Commands.add(
         })
     }
 )
+
+Cypress.Commands.add(
+    "createCollection", (token, collection) => {
+        return cy.do_request('POST', '/arvados/v1/collections', {
+            collection: JSON.stringify(collection),
+            ensure_unique_name: true
+        }, null, token, true)
+        .its('body').as('collection')
+        .then(function() {
+            return this.collection;
+        })
+    }
+)
+
+Cypress.Commands.add(
+    "loginAs", (user) => {
+        cy.visit(`/token/?api_token=${user.token}`);
+        cy.url().should('contain', '/projects/');
+        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