@@ -164,7 +164,6 @@ const renderIndexList = (
164164 rollingIndexes = { [ ] }
165165 serverVersion = "4.4.0"
166166 isWritable = { true }
167- readOnly = { false }
168167 onHideIndexClick = { ( ) => { } }
169168 onUnhideIndexClick = { ( ) => { } }
170169 onDeleteIndexClick = { ( ) => { } }
@@ -190,7 +189,7 @@ describe('RegularIndexesTable Component', function () {
190189 afterEach ( cleanup ) ;
191190
192191 it ( 'renders regular indexes' , function ( ) {
193- renderIndexList ( { isWritable : true , readOnly : false , indexes : indexes } ) ;
192+ renderIndexList ( { isWritable : true , indexes : indexes } ) ;
194193
195194 const indexesList = screen . getByTestId ( 'indexes-list' ) ;
196195 expect ( indexesList ) . to . exist ;
@@ -202,19 +201,7 @@ describe('RegularIndexesTable Component', function () {
202201
203202 // Renders index fields (table cells)
204203 for ( const indexCell of indexFields ) {
205- let mustExist = true ;
206-
207- // For _id index we always hide hide/drop index field buttons
208- if ( index . name === '_id_' && indexCell === 'indexes-actions-field' ) {
209- mustExist = false ;
210- }
211-
212- if ( mustExist ) {
213- expect ( within ( indexRow ) . getByTestId ( indexCell ) ) . to . exist ;
214- } else {
215- // TODO
216- //expect(within(indexRow).queryByTestId(indexCell)).to.not.exist;
217- }
204+ expect ( within ( indexRow ) . getByTestId ( indexCell ) ) . to . exist ;
218205 }
219206
220207 if ( index . name === '_id_' ) {
@@ -260,7 +247,6 @@ describe('RegularIndexesTable Component', function () {
260247 it ( 'renders in-progress indexes' , function ( ) {
261248 renderIndexList ( {
262249 isWritable : true ,
263- readOnly : false ,
264250 inProgressIndexes : inProgressIndexes ,
265251 } ) ;
266252
@@ -287,7 +273,6 @@ describe('RegularIndexesTable Component', function () {
287273 it ( 'renders rolling indexes' , function ( ) {
288274 renderIndexList ( {
289275 isWritable : true ,
290- readOnly : false ,
291276 rollingIndexes : rollingIndexes ,
292277 } ) ;
293278
@@ -342,7 +327,6 @@ describe('RegularIndexesTable Component', function () {
342327 // index if it didn't also exist as a rolling index
343328 renderIndexList ( {
344329 isWritable : true ,
345- readOnly : false ,
346330 indexes : indexesWithRollingIndex ,
347331 } ) ;
348332
@@ -358,7 +342,6 @@ describe('RegularIndexesTable Component', function () {
358342 // up as a regular index too
359343 renderIndexList ( {
360344 isWritable : true ,
361- readOnly : false ,
362345 indexes : indexesWithRollingIndex ,
363346 rollingIndexes,
364347 } ) ;
@@ -371,7 +354,6 @@ describe('RegularIndexesTable Component', function () {
371354 it ( 'does not render the list if there is an error' , function ( ) {
372355 renderIndexList ( {
373356 isWritable : true ,
374- readOnly : false ,
375357 indexes : indexes ,
376358 error : 'moo' ,
377359 } ) ;
@@ -382,39 +364,32 @@ describe('RegularIndexesTable Component', function () {
382364 } ) ;
383365
384366 it ( 'renders the delete and hide/unhide button when a user can modify indexes' , function ( ) {
385- renderIndexList ( { isWritable : true , readOnly : false , indexes : indexes } ) ;
367+ renderIndexList ( { isWritable : true , indexes : indexes } ) ;
386368 const indexesList = screen . getByTestId ( 'indexes-list' ) ;
387369 expect ( indexesList ) . to . exist ;
388370 indexes . forEach ( ( index ) => {
389371 const indexRow = screen . getByTestId ( `indexes-row-${ index . name } ` ) ;
390- expect ( within ( indexRow ) . getByTestId ( 'indexes-actions-field' ) ) . to . exist ;
372+ const buttons = within ( indexRow )
373+ . getByTestId ( 'indexes-actions-field' )
374+ . querySelectorAll ( 'button' ) ;
375+ if ( index . name === '_id_' ) {
376+ // you can't delete or hide the _id index
377+ expect ( buttons ) . to . be . empty ;
378+ } else {
379+ expect ( buttons ) . to . not . be . empty ;
380+ }
391381 } ) ;
392382 } ) ;
393383
394384 it ( 'does not render delete and hide/unhide button when a user can not modify indexes (!isWritable)' , function ( ) {
395- renderIndexList ( { isWritable : false , readOnly : false , indexes : indexes } ) ;
396- const indexesList = screen . getByTestId ( 'indexes-list' ) ;
397- expect ( indexesList ) . to . exist ;
398- // TODO
399- /*
400- indexes.forEach((index) => {
401- const indexRow = screen.getByTestId(`indexes-row-${index.name}`);
402- expect(within(indexRow).queryByTestId('indexes-actions-field')).to.not.exist;
403- });
404- */
405- } ) ;
406-
407- it ( 'does not render delete and hide/unhide button when a user can not modify indexes (isWritable, readOnly)' , function ( ) {
408- renderIndexList ( { isWritable : true , readOnly : true , indexes : indexes } ) ;
385+ renderIndexList ( { isWritable : false , indexes : indexes } ) ;
409386 const indexesList = screen . getByTestId ( 'indexes-list' ) ;
410387 expect ( indexesList ) . to . exist ;
411- // TODO
412- /*
413388 indexes . forEach ( ( index ) => {
414389 const indexRow = screen . getByTestId ( `indexes-row-${ index . name } ` ) ;
415- expect(within(indexRow).queryByTestId('indexes-actions-field')).to.not.exist;
390+ expect ( within ( indexRow ) . queryByTestId ( 'indexes-actions-field' ) ) . to . not
391+ . exist ;
416392 } ) ;
417- */
418393 } ) ;
419394
420395 describe ( 'sorting' , function ( ) {
0 commit comments