From 492f4792b8d590b82410270dd297876574401b65 Mon Sep 17 00:00:00 2001 From: KeyboardTsundoku Date: Fri, 20 Jan 2017 17:26:28 +1100 Subject: [PATCH 1/2] add missing onSubmit's --- .../lib/components/create-collection-dialog.jsx | 11 +++++++++-- .../lib/components/drop-collection-dialog.jsx | 14 ++++++++++++-- .../lib/component/create-database-dialog.jsx | 9 +++++++-- .../lib/component/drop-database-dialog.jsx | 14 ++++++++++++-- 4 files changed, 40 insertions(+), 8 deletions(-) diff --git a/src/internal-packages/database/lib/components/create-collection-dialog.jsx b/src/internal-packages/database/lib/components/create-collection-dialog.jsx index 90d15e0d1bc..99963b55612 100644 --- a/src/internal-packages/database/lib/components/create-collection-dialog.jsx +++ b/src/internal-packages/database/lib/components/create-collection-dialog.jsx @@ -73,8 +73,12 @@ class CreateCollectionDialog extends React.Component { /** * Initiate the attempt to create a collection. + * @param {Object} evt - The event object */ - onCreateCollectionButtonClicked() { + onCreateCollectionButtonClicked(evt) { + evt.preventDefault(); + evt.stopPropagation(); + this.setState({ inProgress: true, error: false, errorMessage: '' }); Actions.createCollection( this.state.databaseName, @@ -168,7 +172,10 @@ class CreateCollectionDialog extends React.Component { -
+ - +
- +
- +
Date: Sun, 22 Jan 2017 09:20:07 +1100 Subject: [PATCH 2/2] added functional tests --- test/functional/compass-functional.test.js | 75 +++++++++++++++++++++ test/functional/support/spectron-support.js | 11 +++ 2 files changed, 86 insertions(+) diff --git a/test/functional/compass-functional.test.js b/test/functional/compass-functional.test.js index 11ad8cd4036..134d87f4a5e 100644 --- a/test/functional/compass-functional.test.js +++ b/test/functional/compass-functional.test.js @@ -340,6 +340,32 @@ describe('Compass Functional Test Suite #spectron', function() { .should.not.eventually.include('temp'); }); + context('when enter key is pressed on drop database dialog', function() { + it('does nothing when incorrect database name is entered', function() { + return client + .clickCreateDatabaseButton() + .waitForCreateDatabaseModal() + .inputCreateDatabaseDetails({ name: 'temp', collectionName: 'temp' }) + .clickCreateDatabaseModalButton() + .waitForDatabaseCreation('temp') + .clickDeleteDatabaseButton('temp') + .waitForDropDatabaseModal() + .inputDropDatabaseName('xkcd') + .pressEnter() + .waitForDropDatabaseModal() + .should.eventually.be.true; + }); + + it('removes the database on press', function() { + return client + .inputDropDatabaseName('temp') + .pressEnter() + .waitForDatabaseDeletion('temp') + .getHomeViewDatabaseNames() + .should.not.eventually.include('temp'); + }); + }); + it('removes the database from the sidebar', function() { return client .getSidebarDatabaseNames() @@ -383,6 +409,24 @@ describe('Compass Functional Test Suite #spectron', function() { .getModalErrorMessage() .should.eventually.equal('invalid collection name'); }); + + it('closes create collection dialog on escape press', function() { + return client + .pressEscape() + .waitForCreateCollectionModalHidden() + .should.eventually.be.true; + }); + + it('displays error on enter press', function() { + return client + .clickCreateCollectionButton() + .waitForCreateCollectionModal() + .inputCreateCollectionDetails({ name: '$test' }) + .pressEnter() + .waitForModalError() + .getModalErrorMessage() + .should.eventually.equal('invalid collection name'); + }); }); context('when the collection name is valid', function() { @@ -407,6 +451,17 @@ describe('Compass Functional Test Suite #spectron', function() { .getSidebarCollectionCount() .should.eventually.equal(String(collCount + 1)); }); + + it('creates a collection with enter press', function() { + return client + .clickCreateCollectionButton() + .waitForCreateCollectionModal() + .inputCreateCollectionDetails({name: 'bands' }) + .pressEnter() + .waitForCollectionCreation('bands') + .getDatabaseViewCollectionNames() + .should.eventually.include('bands'); + }); }); context('when deleting a collection', function() { @@ -421,6 +476,26 @@ describe('Compass Functional Test Suite #spectron', function() { .should.not.eventually.include('labels'); }); + it('pressing enter on incorrect collection name does nothing', function() { + return client + .clickDeleteCollectionButton('bands') + .waitForDropCollectionModal() + .inputDropCollectionName('robot-hugs') + .pressEnter() + .waitForDropCollectionModal() + .should.eventually.be.true; + }); + + it('pressing enter on correct collection name removes collection', function() { + return client + .inputDropCollectionName('bands') + .pressEnter() + .waitForDropCollectionModal() + .waitForCollectionDeletion('bands') + .getDatabaseViewCollectionNames() + .should.not.eventually.include('bands'); + }); + it('removes the collection from the sidebar', function() { return client .waitForInstanceRefresh() diff --git a/test/functional/support/spectron-support.js b/test/functional/support/spectron-support.js index 884f9f2e481..6359410f8a4 100644 --- a/test/functional/support/spectron-support.js +++ b/test/functional/support/spectron-support.js @@ -356,6 +356,10 @@ function addWaitCommands(client) { return this.waitForVisibleInCompass(selector('drop-database-modal'), true); }); + client.addCommand('waitForCreateCollectionModalHidden', function() { + return this.waitForVisibleInCompass(selector('create-collection-modal'), true); + }); + client.addCommand('waitForInsertDocumentModalHidden', function() { return this.waitForVisibleInCompass(selector('insert-document-modal'), true); }); @@ -761,6 +765,13 @@ function addKeyPressCommands(client) { client.addCommand('pressEscape', function() { return this.keys(['Escape']); }); + + /** + * Press enter + */ + client.addCommand('pressEnter', function() { + return this.keys(['Enter']); + }); } /**