X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/df5bb74b46652b2e0a73a0e9ef2c09a63314e409..0ccb88b9580a664bb55f081f92bc090ec6f41d66:/cypress/integration/collection-panel.spec.js?ds=inline diff --git a/cypress/integration/collection-panel.spec.js b/cypress/integration/collection-panel.spec.js index 466d7433..63a25a25 100644 --- a/cypress/integration/collection-panel.spec.js +++ b/cypress/integration/collection-panel.spec.js @@ -128,7 +128,7 @@ describe('Collection panel tests', function() { }) }) - it('renames a file', function() { + it('renames a file using valid names', function() { // Creates the collection using the admin token so we can set up // a bogus manifest text without block signatures. cy.createCollection(adminUser.token, { @@ -138,24 +138,33 @@ describe('Collection panel tests', function() { .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'); + const nameTransitions = [ + ['bar', '&'], + ['&', 'foo'], + ['foo', '&'], + ['&', 'I ❤️ ⛵️'], + ['I ❤️ ⛵️', '...'] + ]; + nameTransitions.forEach(([from, to]) => { + cy.get('[data-cy=collection-files-panel]') + .contains(`${from}`).rightclick(); + cy.get('[data-cy=context-menu]') + .contains('Rename') + .click(); + cy.get('[data-cy=form-dialog]') + .should('contain', 'Rename') + .within(() => { + cy.get('input').type(`{selectall}{backspace}${to}`); + }); + cy.get('[data-cy=form-submit-btn]').click(); + cy.get('[data-cy=collection-files-panel]') + .should('not.contain', `${from}`) + .and('contain', `${to}`); + }) }); }); - it('tries to rename a file with an illegal name', function() { + it('renames a file to a different directory', function() { // Creates the collection using the admin token so we can set up // a bogus manifest text without block signatures. cy.createCollection(adminUser.token, { @@ -165,6 +174,7 @@ describe('Collection panel tests', function() { .as('testCollection').then(function() { cy.loginAs(activeUser); cy.visit(`/collections/${this.testCollection.uuid}`); + // Rename 'bar' to 'subdir/foo' cy.get('[data-cy=collection-files-panel]') .contains('bar').rightclick(); cy.get('[data-cy=context-menu]') @@ -173,14 +183,71 @@ describe('Collection panel tests', function() { cy.get('[data-cy=form-dialog]') .should('contain', 'Rename') .within(() => { - cy.get('input').type('{backspace}{backspace}{backspace}'); + cy.get('input').type(`{selectall}{backspace}subdir/foo`); }); cy.get('[data-cy=form-submit-btn]').click(); + cy.get('[data-cy=collection-files-panel]') + .should('not.contain', 'bar') + .and('contain', 'subdir'); + // Look for the "arrow icon" and expand the "subdir" directory. + cy.get('[data-cy=virtual-file-tree] > div > i').click(); + // Rename 'subdir/foo' to 'baz' + cy.get('[data-cy=collection-files-panel]') + .contains('foo').rightclick(); + cy.get('[data-cy=context-menu]') + .contains('Rename') + .click(); cy.get('[data-cy=form-dialog]') .should('contain', 'Rename') .within(() => { - cy.contains('Could not rename'); + cy.get('input') + .should('have.value', 'subdir/foo') + .type(`{selectall}{backspace}baz`); }); + cy.get('[data-cy=form-submit-btn]').click(); + cy.get('[data-cy=collection-files-panel]') + .should('contain', 'subdir') // empty dir kept + .and('contain', 'baz'); + }); + }); + + it('tries to rename a file with an illegal names', 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}`); + const illegalNamesFromUI = [ + ['.', "Name cannot be '.' or '..'"], + ['..', "Name cannot be '.' or '..'"], + ['', 'This field is required'], + [' ', 'Leading/trailing whitespaces not allowed'], + [' foo', 'Leading/trailing whitespaces not allowed'], + ['foo ', 'Leading/trailing whitespaces not allowed'], + ['//foo', 'Empty dir name not allowed'] + ] + illegalNamesFromUI.forEach(([name, errMsg]) => { + 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(`{selectall}{backspace}${name}`); + }); + cy.get('[data-cy=form-dialog]') + .should('contain', 'Rename') + .within(() => { + cy.contains(`${errMsg}`); + }); + cy.get('[data-cy=form-cancel-btn]').click(); + }) }); });