@@ -113,27 +113,49 @@ describe('IndexesToolbar Component', function () {
113113 } ) ;
114114 } ) ;
115115 } ) ;
116-
117- it ( 'should not render a warning' , function ( ) {
118- expect ( screen . queryByText ( 'Readonly views may not contain indexes' ) ) . to
119- . not . exist ;
120- } ) ;
121116 } ) ;
122117
123118 describe ( 'when it is a readonly view' , function ( ) {
124- beforeEach ( function ( ) {
125- renderIndexesToolbar ( {
126- isReadonlyView : true ,
119+ describe ( 'and server version is < 8.1+' , function ( ) {
120+ beforeEach ( function ( ) {
121+ renderIndexesToolbar ( {
122+ isReadonlyView : true ,
123+ indexView : 'search-indexes' ,
124+ } ) ;
127125 } ) ;
128- } ) ;
129126
130- it ( 'should not render the create index button' , function ( ) {
131- expect ( screen . queryByText ( 'Create Index' ) ) . to . not . exist ;
127+ it ( 'should not render the create index button' , function ( ) {
128+ expect ( screen . queryByText ( 'Create Index' ) ) . to . not . exist ;
129+ } ) ;
130+
131+ it ( 'should not render the create search index button' , function ( ) {
132+ expect ( screen . queryByText ( 'Create Search Index' ) ) . to . not . exist ;
133+ } ) ;
134+
135+ it ( 'should not render the refresh button' , function ( ) {
136+ expect ( screen . queryByText ( 'Refresh' ) ) . to . not . exist ;
137+ } ) ;
132138 } ) ;
139+ describe ( 'and server version is > 8.1+' , function ( ) {
140+ beforeEach ( function ( ) {
141+ renderIndexesToolbar ( {
142+ isReadonlyView : true ,
143+ serverVersion : '8.1.0' ,
144+ indexView : 'search-indexes' ,
145+ } ) ;
146+ } ) ;
147+
148+ it ( 'should not render the create index button' , function ( ) {
149+ expect ( screen . queryByText ( 'Create Index' ) ) . to . not . exist ;
150+ } ) ;
133151
134- it ( 'should render a warning' , function ( ) {
135- expect ( screen . getByText ( 'Readonly views may not contain indexes.' ) ) . to . be
136- . visible ;
152+ it ( 'should render the create search index button <8.1' , function ( ) {
153+ expect ( screen . getByText ( 'Create Search Index' ) ) . to . be . visible ;
154+ } ) ;
155+
156+ it ( 'should not render the refresh button' , function ( ) {
157+ expect ( screen . queryByText ( 'Refresh' ) ) . to . be . visible ;
158+ } ) ;
137159 } ) ;
138160 } ) ;
139161
@@ -332,5 +354,27 @@ describe('IndexesToolbar Component', function () {
332354 expect ( segmentControl . closest ( 'button' ) ) . to . have . attr ( 'disabled' ) ;
333355 expect ( onChangeViewCallback ) . to . not . have . been . calledOnce ;
334356 } ) ;
357+
358+ describe ( 'and readonly view >8.1' , function ( ) {
359+ beforeEach ( function ( ) {
360+ renderIndexesToolbar ( {
361+ isReadonlyView : true ,
362+ onIndexViewChanged : onChangeViewCallback ,
363+ serverVersion : '8.1.0' ,
364+ } ) ;
365+ } ) ;
366+
367+ it ( 'it renders tabs with Indexes disabled and automatically selects Search Indexes' , function ( ) {
368+ const indexesTab = screen . getByText ( 'Indexes' ) ;
369+ expect ( indexesTab ) . to . be . visible ;
370+ expect ( indexesTab . closest ( 'button' ) ) . to . have . attr ( 'disabled' ) ;
371+
372+ expect ( screen . getByText ( 'Search Indexes' ) ) . to . be . visible ;
373+ expect ( onChangeViewCallback ) . to . have . been . calledOnce ;
374+ expect ( onChangeViewCallback . firstCall . args [ 0 ] ) . to . equal (
375+ 'search-indexes'
376+ ) ;
377+ } ) ;
378+ } ) ;
335379 } ) ;
336380} ) ;
0 commit comments