File tree Expand file tree Collapse file tree 3 files changed +62
-10
lines changed
src/internal-packages/indexes/lib/component Expand file tree Collapse file tree 3 files changed +62
-10
lines changed Original file line number Diff line number Diff line change 1
1
const React = require ( 'react' ) ;
2
+ const _ = require ( 'lodash' ) ;
3
+
4
+ // const debug = require('debug')('mongodb-compass:indexes:usage-column');
2
5
3
6
/**
4
7
* No usage stats constant.
@@ -16,10 +19,24 @@ class UsageColumn extends React.Component {
16
19
* @returns {String } The tooltip.
17
20
*/
18
21
tooltip ( ) {
19
- if ( this . props . usage ) {
20
- return `${ this . props . usage } index hits since index creation or last\n server restart` ;
22
+ if ( _ . isUndefined ( this . props . usage ) ) {
23
+ return NO_USAGE_STATS ;
24
+ }
25
+ return `${ this . props . usage } index hits since index creation or last\n server restart` ;
26
+ }
27
+
28
+ renderSince ( ) {
29
+ if ( _ . isUndefined ( this . props . since ) ) {
30
+ return null ;
21
31
}
22
- return NO_USAGE_STATS ;
32
+ return (
33
+ < div className = "usage-since" >
34
+ since
35
+ < span >
36
+ { this . props . since ? this . props . since . toDateString ( ) : 'N/A' }
37
+ </ span >
38
+ </ div >
39
+ ) ;
23
40
}
24
41
25
42
/**
@@ -28,18 +45,14 @@ class UsageColumn extends React.Component {
28
45
* @returns {React.Component } The usage column.
29
46
*/
30
47
render ( ) {
48
+ const usage = _ . isUndefined ( this . props . usage ) ? 'N/A' : this . props . usage ;
31
49
return (
32
50
< td className = "usage-column" >
33
51
< span className = "usage" >
34
52
< div className = "quantity" title = { this . tooltip ( ) } >
35
- { this . props . usage || 'N/A' }
36
- </ div >
37
- < div className = "usage-since" >
38
- since
39
- < span >
40
- { this . props . since ? this . props . since . toDateString ( ) : 'N/A' }
41
- </ span >
53
+ { usage }
42
54
</ div >
55
+ { this . renderSince ( ) }
43
56
</ span >
44
57
</ td >
45
58
) ;
Original file line number Diff line number Diff line change @@ -182,6 +182,32 @@ describe('Compass #spectron', function() {
182
182
. eventually
183
183
. include ( '_id_' ) ;
184
184
} ) ;
185
+ it ( 'shows a number in the usage column' , function ( ) {
186
+ return client
187
+ . getText ( 'span.usage div.quantity' )
188
+ . should
189
+ . eventually
190
+ . match ( / \d + / ) ;
191
+ } ) ;
192
+ it ( 'open create index' , function ( ) {
193
+ return client . selectCreateIndex ( )
194
+ . getText ( 'h4.modal-title' )
195
+ . should
196
+ . eventually
197
+ . include ( 'Create Index' ) ;
198
+ } ) ;
199
+ it ( 'try empty create index' , function ( ) {
200
+ return client . submitCreateIndexForm ( )
201
+ . getText ( '.modal-status-error-message' )
202
+ . should
203
+ . eventually
204
+ . include ( 'You must select a field name and type' ) ;
205
+ } ) ;
206
+ // @KeyboardTsundoku it would be great to have test that creates an
207
+ // index here
208
+ it ( 'close create index' , function ( ) {
209
+ return client . cancelCreateIndexForm ( ) ; // test required here
210
+ } ) ;
185
211
} ) ;
186
212
} ) ;
187
213
} ) ;
Original file line number Diff line number Diff line change @@ -225,6 +225,19 @@ function addCommands(client) {
225
225
. waitForVisible ( '#statusbar' , ms )
226
226
. waitForVisible ( '#statusbar' , ms , true ) ;
227
227
} ) ;
228
+
229
+ client . addCommand ( 'selectCreateIndex' , function ( ) {
230
+ return this . click ( '.create-index-btn button' ) . waitForVisible ( 'h4.modal-title' , 15000 ) ;
231
+ } ) ;
232
+
233
+ client . addCommand ( 'submitCreateIndexForm' , function ( ) {
234
+ this . click ( '#field-name-select-dropdown' ) ;
235
+ return this . submitForm ( '.modal-body form' ) ;
236
+ } ) ;
237
+
238
+ client . addCommand ( 'cancelCreateIndexForm' , function ( ) {
239
+ return this . click ( '.create-index-confirm-buttons-cancel' ) ;
240
+ } ) ;
228
241
}
229
242
230
243
/**
You can’t perform that action at this time.
0 commit comments