From f7a762377deec90174f43d4d08471be240100957 Mon Sep 17 00:00:00 2001 From: KeyboardTsundoku Date: Wed, 23 Nov 2016 14:48:45 +1100 Subject: [PATCH 1/3] replaced 'NA' with '0' --- src/internal-packages/indexes/lib/component/usage-column.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/internal-packages/indexes/lib/component/usage-column.jsx b/src/internal-packages/indexes/lib/component/usage-column.jsx index 72729a72704..2432c7d6b36 100644 --- a/src/internal-packages/indexes/lib/component/usage-column.jsx +++ b/src/internal-packages/indexes/lib/component/usage-column.jsx @@ -32,7 +32,7 @@ class UsageColumn extends React.Component {
- {this.props.usage || 'N/A'} + {this.props.usage || '0'}
since  From 1c344c6f2fc193ec9211ad8797fe96f52781b52e Mon Sep 17 00:00:00 2001 From: KeyboardTsundoku Date: Thu, 24 Nov 2016 15:40:13 +1100 Subject: [PATCH 2/3] COMPASS-397 added some test cases around indexes --- test/compass-functional.test.js | 19 +++++++++++++++++++ test/support/spectron-support.js | 13 +++++++++++++ 2 files changed, 32 insertions(+) diff --git a/test/compass-functional.test.js b/test/compass-functional.test.js index e1503370e90..0bb6d631966 100644 --- a/test/compass-functional.test.js +++ b/test/compass-functional.test.js @@ -182,6 +182,25 @@ describe('Compass #spectron', function() { .eventually .include('_id_'); }); + it('open create index', function() { + return client.selectCreateIndex() + .getText('h4.modal-title') + .should + .eventually + .include('Create Index'); + }); + it('try empty create index', function() { + return client.submitCreateIndexForm() + .getText('.modal-status-error-message') + .should + .eventually + .include('You must select a field name and type'); + }); + // @KeyboardTsundoku it would be great to have test that creates an + // index here + it('close create index', function() { + return client.cancelCreateIndexForm(); // test required here + }); }); }); }); diff --git a/test/support/spectron-support.js b/test/support/spectron-support.js index a758bbee392..07f2c9c20d7 100644 --- a/test/support/spectron-support.js +++ b/test/support/spectron-support.js @@ -225,6 +225,19 @@ function addCommands(client) { .waitForVisible('#statusbar', ms) .waitForVisible('#statusbar', ms, true); }); + + client.addCommand('selectCreateIndex', function() { + return this.click('.create-index-btn button').waitForVisible('h4.modal-title', 15000); + }); + + client.addCommand('submitCreateIndexForm', function() { + this.click('#field-name-select-dropdown'); + return this.submitForm('.modal-body form'); + }); + + client.addCommand('cancelCreateIndexForm', function() { + return this.click('.create-index-confirm-buttons-cancel'); + }); } /** From 9796753a6af174ae99504950e52df463a2696608 Mon Sep 17 00:00:00 2001 From: Thomas Rueckstiess Date: Fri, 25 Nov 2016 11:55:51 +1100 Subject: [PATCH 3/3] Only show N/A when $indexStats not available, otherwise 0 --- .../indexes/lib/component/usage-column.jsx | 33 +++++++++++++------ test/compass-functional.test.js | 7 ++++ 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/internal-packages/indexes/lib/component/usage-column.jsx b/src/internal-packages/indexes/lib/component/usage-column.jsx index 2432c7d6b36..ff3c1b7f661 100644 --- a/src/internal-packages/indexes/lib/component/usage-column.jsx +++ b/src/internal-packages/indexes/lib/component/usage-column.jsx @@ -1,4 +1,7 @@ const React = require('react'); +const _ = require('lodash'); + +// const debug = require('debug')('mongodb-compass:indexes:usage-column'); /** * No usage stats constant. @@ -16,10 +19,24 @@ class UsageColumn extends React.Component { * @returns {String} The tooltip. */ tooltip() { - if (this.props.usage) { - return `${this.props.usage} index hits since index creation or last\n server restart`; + if (_.isUndefined(this.props.usage)) { + return NO_USAGE_STATS; + } + return `${this.props.usage} index hits since index creation or last\n server restart`; + } + + renderSince() { + if (_.isUndefined(this.props.since)) { + return null; } - return NO_USAGE_STATS; + return ( +
+ since  + + {this.props.since ? this.props.since.toDateString() : 'N/A'} + +
+ ); } /** @@ -28,18 +45,14 @@ class UsageColumn extends React.Component { * @returns {React.Component} The usage column. */ render() { + const usage = _.isUndefined(this.props.usage) ? 'N/A' : this.props.usage; return (
- {this.props.usage || '0'} -
-
- since  - - {this.props.since ? this.props.since.toDateString() : 'N/A'} - + {usage}
+ {this.renderSince()}
); diff --git a/test/compass-functional.test.js b/test/compass-functional.test.js index 0bb6d631966..95b18b7cf7c 100644 --- a/test/compass-functional.test.js +++ b/test/compass-functional.test.js @@ -182,6 +182,13 @@ describe('Compass #spectron', function() { .eventually .include('_id_'); }); + it('shows a number in the usage column', function() { + return client + .getText('span.usage div.quantity') + .should + .eventually + .match(/\d+/); + }); it('open create index', function() { return client.selectCreateIndex() .getText('h4.modal-title')