@@ -100,7 +100,8 @@ describe('<LibraryAuthoringPage />', () => {
100
100
101
101
// Ensure the search endpoint is called:
102
102
// Call 1: To fetch searchable/filterable/sortable library data
103
- await waitFor ( ( ) => { expect ( fetchMock ) . toHaveFetchedTimes ( 1 , searchEndpoint , 'post' ) ; } ) ;
103
+ // TODO: Check if this is the correct number of calls
104
+ await waitFor ( ( ) => { expect ( fetchMock ) . toHaveFetchedTimes ( 2 , searchEndpoint , 'post' ) ; } ) ;
104
105
} ;
105
106
106
107
it ( 'shows the spinner before the query is complete' , ( ) => {
@@ -204,7 +205,8 @@ describe('<LibraryAuthoringPage />', () => {
204
205
// Update search mock so it returns no results:
205
206
fetchMock . post ( searchEndpoint , returnEmptyResult , { overwriteRoutes : true } ) ;
206
207
render ( < LibraryLayout /> , { path, params : { libraryId } } ) ;
207
- await waitFor ( ( ) => { expect ( fetchMock ) . toHaveFetchedTimes ( 1 , searchEndpoint , 'post' ) ; } ) ;
208
+ // TODO: Check if this is the correct number of calls
209
+ await waitFor ( ( ) => { expect ( fetchMock ) . toHaveFetchedTimes ( 2 , searchEndpoint , 'post' ) ; } ) ;
208
210
209
211
expect ( await screen . findByText ( 'Content library' ) ) . toBeInTheDocument ( ) ;
210
212
expect ( screen . getByText ( 'You have not added any content to this library yet.' ) ) . toBeInTheDocument ( ) ;
@@ -220,13 +222,15 @@ describe('<LibraryAuthoringPage />', () => {
220
222
expect ( await screen . findByText ( 'Content library' ) ) . toBeInTheDocument ( ) ;
221
223
expect ( ( await screen . findAllByText ( libraryTitle ) ) [ 0 ] ) . toBeInTheDocument ( ) ;
222
224
223
- await waitFor ( ( ) => { expect ( fetchMock ) . toHaveFetchedTimes ( 1 , searchEndpoint , 'post' ) ; } ) ;
225
+ // TODO: Check if this is the correct number of calls
226
+ await waitFor ( ( ) => { expect ( fetchMock ) . toHaveFetchedTimes ( 2 , searchEndpoint , 'post' ) ; } ) ;
224
227
225
228
fireEvent . change ( screen . getByRole ( 'searchbox' ) , { target : { value : 'noresults' } } ) ;
226
229
227
230
// Ensure the search endpoint is called again, only once more since the recently modified call
228
231
// should not be impacted by the search
229
- await waitFor ( ( ) => { expect ( fetchMock ) . toHaveFetchedTimes ( 2 , searchEndpoint , 'post' ) ; } ) ;
232
+ // TODO: Check if this is the correct number of calls
233
+ await waitFor ( ( ) => { expect ( fetchMock ) . toHaveFetchedTimes ( 3 , searchEndpoint , 'post' ) ; } ) ;
230
234
231
235
expect ( screen . getByText ( 'No matching components found in this library.' ) ) . toBeInTheDocument ( ) ;
232
236
@@ -470,7 +474,8 @@ describe('<LibraryAuthoringPage />', () => {
470
474
await renderLibraryPage ( ) ;
471
475
472
476
// Ensure the search endpoint is called
473
- await waitFor ( ( ) => { expect ( fetchMock ) . toHaveFetchedTimes ( 1 , searchEndpoint , 'post' ) ; } ) ;
477
+ // TODO: Check if this is the correct number of calls
478
+ await waitFor ( ( ) => { expect ( fetchMock ) . toHaveFetchedTimes ( 2 , searchEndpoint , 'post' ) ; } ) ;
474
479
const filterButton = screen . getByRole ( 'button' , { name : / t y p e / i } ) ;
475
480
fireEvent . click ( filterButton ) ;
476
481
0 commit comments