From ee9dac4509683f2fbe5fda146bd9c18f4b765337 Mon Sep 17 00:00:00 2001 From: Lucas Di Pentima Date: Mon, 11 May 2020 16:50:21 -0300 Subject: [PATCH] 16118: Adds collection's integration test suite (WIP) Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- cypress/integration/collection-panel.spec.js | 48 ++++++++++++++++++++ cypress/support/commands.js | 22 +++++++++ 2 files changed, 70 insertions(+) create mode 100644 cypress/integration/collection-panel.spec.js diff --git a/cypress/integration/collection-panel.spec.js b/cypress/integration/collection-panel.spec.js new file mode 100644 index 00000000..287bfe10 --- /dev/null +++ b/cypress/integration/collection-panel.spec.js @@ -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 diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 68ce6870..8c6fd462 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -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 -- 2.30.2