From 96626db04a7dcb11b21d92203a6ddd81577191bf Mon Sep 17 00:00:00 2001 From: Lucas Di Pentima Date: Thu, 15 Oct 2020 15:25:17 -0300 Subject: [PATCH] 16719: Adds integration test for collection's old version searching. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- cypress/integration/search.spec.js | 83 +++++++++++++++++++ .../search-bar/search-bar-view.tsx | 1 + .../search-results-panel-view.tsx | 4 +- 3 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 cypress/integration/search.spec.js diff --git a/cypress/integration/search.spec.js b/cypress/integration/search.spec.js new file mode 100644 index 00000000..0fba64cd --- /dev/null +++ b/cypress/integration/search.spec.js @@ -0,0 +1,83 @@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + +describe('Search 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('can search for old collection versions', function() { + const colName = `Versioned Collection ${Math.floor(Math.random() * Math.floor(999999))}`; + let colUuid = ''; + let oldVersionUuid = ''; + // Make sure no other collections with this name exist + cy.doRequest('GET', '/arvados/v1/collections', null, { + filters: `[["name", "=", "${colName}"]]`, + include_old_versions: true + }) + .its('body.items').as('collections') + .then(function() { + expect(this.collections).to.be.empty; + }); + // Creates the collection using the admin token so we can set up + // a bogus manifest text without block signatures. + cy.createCollection(adminUser.token, { + name: colName, + owner_uuid: activeUser.user.uuid, + manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"}) + .as('originalVersion').then(function() { + // Change the file name to create a new version. + cy.updateCollection(adminUser.token, this.originalVersion.uuid, { + manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo\n" + }) + colUuid = this.originalVersion.uuid; + }); + // Confirm that there are 2 versions of the collection + cy.doRequest('GET', '/arvados/v1/collections', null, { + filters: `[["name", "=", "${colName}"]]`, + include_old_versions: true + }) + .its('body.items').as('collections') + .then(function() { + expect(this.collections).to.have.lengthOf(2); + this.collections.map(function(aCollection) { + expect(aCollection.current_version_uuid).to.equal(colUuid); + if (aCollection.uuid !== aCollection.current_version_uuid) { + oldVersionUuid = aCollection.uuid; + } + }); + cy.loginAs(activeUser); + const searchQuery = `${colName} type:arvados#collection`; + // Search for only collection's current version + cy.visit(`/search-results?q=${encodeURIComponent(searchQuery)}`); + cy.get('[data-cy=search-results]').should('contain', 'current'); + cy.get('[data-cy=search-results]').should('not.contain', 'old version'); + // ...and then, include old versions. + cy.visit(`/search-results?q=${encodeURIComponent(searchQuery + ' is:pastVersion')}`); + cy.get('[data-cy=search-results]').should('contain', 'current'); + cy.get('[data-cy=search-results]').should('contain', 'old version'); + }); + }); +}); \ No newline at end of file diff --git a/src/views-components/search-bar/search-bar-view.tsx b/src/views-components/search-bar/search-bar-view.tsx index 49a8ba62..20536fd7 100644 --- a/src/views-components/search-bar/search-bar-view.tsx +++ b/src/views-components/search-bar/search-bar-view.tsx @@ -177,6 +177,7 @@ export const SearchBarView = compose(connectVocabulary, withStyles(styles))(
) => { const homeCluster = props.user.uuid.substr(0, 5); const loggedIn = props.sessions.filter((ss) => ss.loggedIn && ss.userIsActive); - return Use Site Manager to manage which clusters will be searched.} } - />; + />; }); -- 2.30.2