From: Lucas Di Pentima Date: Fri, 6 Nov 2020 16:01:44 +0000 (-0300) Subject: 15685: Merge branch 'master' into 15685-file-renaming-empty-name X-Git-Tag: 2.1.1~1^2~11 X-Git-Url: https://git.arvados.org/arvados-workbench2.git/commitdiff_plain/df5bb74b46652b2e0a73a0e9ef2c09a63314e409?hp=-c 15685: Merge branch 'master' into 15685-file-renaming-empty-name Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- df5bb74b46652b2e0a73a0e9ef2c09a63314e409 diff --combined cypress/integration/collection-panel.spec.js index 19a28c88,404d1c5b..466d7433 --- a/cypress/integration/collection-panel.spec.js +++ b/cypress/integration/collection-panel.spec.js @@@ -21,12 -21,12 +21,12 @@@ describe('Collection panel tests', func activeUser = this.activeUser; } ); - }) + }); beforeEach(function() { - cy.clearCookies() - cy.clearLocalStorage() - }) + cy.clearCookies(); + cy.clearLocalStorage(); + }); it('shows collection by URL', function() { cy.loginAs(activeUser); @@@ -54,7 -54,8 +54,8 @@@ // Check that name & uuid are correct. cy.get('[data-cy=collection-info-panel]') .should('contain', this.testCollection.name) - .and('contain', this.testCollection.uuid); + .and('contain', this.testCollection.uuid) + .and('not.contain', 'This is an old version'); // Check for the read-only icon cy.get('[data-cy=read-only-icon]').should(`${isWritable ? 'not.' : ''}exist`); // Check that both read and write operations are available on @@@ -63,8 -64,8 +64,8 @@@ .click() cy.get('[data-cy=context-menu]') .should('contain', 'Add to favorites') - .and(`${isWritable ? '' : 'not.'}contain`, 'Edit collection') - .type('{esc}'); // Collapse the options menu + .and(`${isWritable ? '' : 'not.'}contain`, 'Edit collection'); + cy.get('body').click(); // Collapse the menu avoiding details panel expansion cy.get('[data-cy=collection-properties-panel]') .should('contain', 'someKey') .and('contain', 'someValue') @@@ -94,6 -95,15 +95,15 @@@ cy.get('[data-cy=upload-button]') .should(`${isWritable ? '' : 'not.'}contain`, 'Upload data'); }); + cy.get('[data-cy=collection-files-panel]') + .contains('bar').rightclick(); + cy.get('[data-cy=context-menu]') + .should('contain', 'Download') + .and('contain', 'Open in new tab') + .and('contain', 'Copy to clipboard') + .and(`${isWritable ? '' : 'not.'}contain`, 'Rename') + .and(`${isWritable ? '' : 'not.'}contain`, 'Remove'); + cy.get('body').click(); // Collapse the menu // Hamburger 'more options' menu button cy.get('[data-cy=collection-files-panel-options-btn]') .click() @@@ -105,72 -115,66 +115,122 @@@ cy.get('[data-cy=context-menu]') // .should('contain', 'Download selected') .should(`${isWritable ? '' : 'not.'}contain`, 'Remove selected') - .type('{esc}'); // Collapse the options menu + cy.get('body').click(); // Collapse the menu // File item 'more options' button cy.get('[data-cy=file-item-options-btn') .click() cy.get('[data-cy=context-menu]') .should('contain', 'Download') - .and(`${isWritable ? '' : 'not.'}contain`, 'Remove') - .type('{esc}'); // Collapse + .and(`${isWritable ? '' : 'not.'}contain`, 'Remove'); + cy.get('body').click(); // Collapse the menu }) }) }) }) + it('renames a file', function() { + // Creates the collection using the admin token so we can set up + // a bogus manifest text without block signatures. + 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.visit(`/collections/${this.testCollection.uuid}`); + cy.get('[data-cy=collection-files-panel]') + .contains('bar').rightclick(); + cy.get('[data-cy=context-menu]') + .contains('Rename') + .click(); + cy.get('[data-cy=form-dialog]') + .should('contain', 'Rename') + .within(() => { + cy.get('input').type('{backspace}{backspace}{backspace}foo'); + }); + cy.get('[data-cy=form-submit-btn]').click(); + cy.get('[data-cy=collection-files-panel]') + .should('not.contain', 'bar') + .and('contain', 'foo'); + }); + }); + + it('tries to rename a file with an illegal name', function() { + // Creates the collection using the admin token so we can set up + // a bogus manifest text without block signatures. + 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.visit(`/collections/${this.testCollection.uuid}`); + cy.get('[data-cy=collection-files-panel]') + .contains('bar').rightclick(); + cy.get('[data-cy=context-menu]') + .contains('Rename') + .click(); + cy.get('[data-cy=form-dialog]') + .should('contain', 'Rename') + .within(() => { + cy.get('input').type('{backspace}{backspace}{backspace}'); + }); + cy.get('[data-cy=form-submit-btn]').click(); + cy.get('[data-cy=form-dialog]') + .should('contain', 'Rename') + .within(() => { + cy.contains('Could not rename'); + }); + }); + }); ++ + it('can correctly display old versions', function() { - const colName = `Versioned Collection ${Math.floor(Math.random() * Math.floor(999999))}`; ++ const colName = `Versioned Collection ${Math.floor(Math.random() * 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; + } + }); + // Check the old version displays as what it is. + cy.loginAs(activeUser) + cy.visit(`/collections/${oldVersionUuid}`); + cy.get('[data-cy=collection-info-panel]').should('contain', 'This is an old version'); + cy.get('[data-cy=read-only-icon]').should('exist'); + cy.get('[data-cy=collection-info-panel]').should('contain', colName); + cy.get('[data-cy=collection-files-panel]').should('contain', 'bar'); + }); + }); }) diff --combined cypress/integration/login.spec.js index 7a6f7160,25c8cd4b..aeea01cd --- a/cypress/integration/login.spec.js +++ b/cypress/integration/login.spec.js @@@ -28,7 -28,7 +28,7 @@@ describe('Login tests', function() inactiveUser = this.inactiveUser; } ); - randomUser.username = `randomuser${Math.floor(Math.random() * Math.floor(999999))}`; + randomUser.username = `randomuser${Math.floor(Math.random() * 999999)}`; randomUser.password = { crypt: 'zpAReoZzPnwmQ', clear: 'topsecret', @@@ -89,11 -89,11 +89,11 @@@ cy.doRequest('PUT', `/arvados/v1/api_client_authorizations/${tokenUuid}`, { id: tokenUuid, api_client_authorization: JSON.stringify({ - api_token: `randomToken${Math.floor(Math.random() * Math.floor(999999))}` + api_token: `randomToken${Math.floor(Math.random() * 999999)}` }) }, null, activeUser.token, true); // Should log the user out. - cy.get('[data-cy=breadcrumb-first]').click(); + cy.visit('/'); cy.get('div#root').should('contain', 'Please log in'); })