X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/ce0ff64f2b49090e595bf1a614d811b161fbbfbb..04721847d0d2d5607999df598aed355d3ae6c6bc:/cypress/integration/collection-panel.spec.js diff --git a/cypress/integration/collection-panel.spec.js b/cypress/integration/collection-panel.spec.js index ff55e050..19a28c88 100644 --- a/cypress/integration/collection-panel.spec.js +++ b/cypress/integration/collection-panel.spec.js @@ -21,12 +21,12 @@ describe('Collection panel tests', function() { activeUser = this.activeUser; } ); - }) + }); beforeEach(function() { - cy.clearCookies() - cy.clearLocalStorage() - }) + cy.clearCookies(); + cy.clearLocalStorage(); + }); it('shows collection by URL', function() { cy.loginAs(activeUser); @@ -54,8 +54,9 @@ describe('Collection panel tests', function() { // Check that name & uuid are correct. cy.get('[data-cy=collection-info-panel]') .should('contain', this.testCollection.name) - .and(`${isWritable ? 'not.': ''}contain`, 'Read-only') .and('contain', this.testCollection.uuid); + // 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 // the 'More options' menu. cy.get('[data-cy=collection-panel-options-btn]') @@ -102,8 +103,8 @@ describe('Collection panel tests', function() { cy.get('[data-cy=collection-files-panel-options-btn]') .click() cy.get('[data-cy=context-menu]') - .should('contain', 'Download selected') - .and(`${isWritable ? '' : 'not.'}contain`, 'Remove selected') + // .should('contain', 'Download selected') + .should(`${isWritable ? '' : 'not.'}contain`, 'Remove selected') .type('{esc}'); // Collapse the options menu // File item 'more options' button cy.get('[data-cy=file-item-options-btn') @@ -116,4 +117,60 @@ describe('Collection panel tests', function() { }) }) }) -}) \ No newline at end of file + + 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'); + }); + }); + }); +})