@@ -12,11 +12,12 @@ import mockResult from '../__mocks__/collection-search.json';
12
12
import {
13
13
mockContentLibrary , mockLibraryBlockTypes , mockXBlockFields ,
14
14
} from '../data/api.mocks' ;
15
- import { mockContentSearchConfig } from '../../search-manager/data/api.mock' ;
15
+ import { mockContentSearchConfig , mockGetBlockTypes } from '../../search-manager/data/api.mock' ;
16
16
import { mockBroadcastChannel } from '../../generic/data/api.mock' ;
17
17
import { LibraryLayout } from '..' ;
18
18
19
19
mockContentSearchConfig . applyMock ( ) ;
20
+ mockGetBlockTypes . applyMock ( ) ;
20
21
mockContentLibrary . applyMock ( ) ;
21
22
mockLibraryBlockTypes . applyMock ( ) ;
22
23
mockXBlockFields . applyMock ( ) ;
@@ -87,8 +88,7 @@ describe('<LibraryCollectionPage />', () => {
87
88
} ) ;
88
89
89
90
if ( colId !== mockCollection . collectionNeverLoads ) {
90
- // TODO: Check why the search endpoint is called 3 times
91
- await waitFor ( ( ) => { expect ( fetchMock ) . toHaveFetchedTimes ( 3 , searchEndpoint , 'post' ) ; } ) ;
91
+ await waitFor ( ( ) => { expect ( fetchMock ) . toHaveFetchedTimes ( 1 , searchEndpoint , 'post' ) ; } ) ;
92
92
}
93
93
} ;
94
94
@@ -112,8 +112,6 @@ describe('<LibraryCollectionPage />', () => {
112
112
expect ( ( await screen . findAllByText ( libraryTitle ) ) [ 0 ] ) . toBeInTheDocument ( ) ;
113
113
expect ( ( await screen . findAllByText ( mockCollection . title ) ) [ 0 ] ) . toBeInTheDocument ( ) ;
114
114
115
- expect ( screen . queryByText ( 'This collection is currently empty.' ) ) . not . toBeInTheDocument ( ) ;
116
-
117
115
// "Recently Modified" sort shown
118
116
expect ( screen . getAllByText ( 'Recently Modified' ) . length ) . toEqual ( 1 ) ;
119
117
expect ( ( await screen . findAllByText ( 'Introduction to Testing' ) ) [ 0 ] ) . toBeInTheDocument ( ) ;
@@ -128,7 +126,8 @@ describe('<LibraryCollectionPage />', () => {
128
126
expect ( ( await screen . findAllByText ( libraryTitle ) ) [ 0 ] ) . toBeInTheDocument ( ) ;
129
127
expect ( ( await screen . findAllByText ( mockCollection . title ) ) [ 0 ] ) . toBeInTheDocument ( ) ;
130
128
131
- expect ( screen . getAllByText ( 'This collection is currently empty.' ) [ 0 ] ) . toBeInTheDocument ( ) ;
129
+ // In the collection page and in the sidebar
130
+ expect ( screen . getAllByText ( 'This collection is currently empty.' ) . length ) . toEqual ( 2 ) ;
132
131
133
132
const addComponentButton = screen . getAllByRole ( 'button' , { name : / n e w / i } ) [ 1 ] ;
134
133
fireEvent . click ( addComponentButton ) ;
@@ -151,7 +150,8 @@ describe('<LibraryCollectionPage />', () => {
151
150
await renderLibraryCollectionPage ( mockCollection . collectionNoComponents , libraryId ) ;
152
151
153
152
expect ( await screen . findByText ( 'All Collections' ) ) . toBeInTheDocument ( ) ;
154
- expect ( screen . getAllByText ( 'This collection is currently empty.' ) [ 0 ] ) . toBeInTheDocument ( ) ;
153
+ // In the collection page and in the sidebar
154
+ expect ( screen . getAllByText ( 'This collection is currently empty.' ) . length ) . toEqual ( 2 ) ;
155
155
expect ( screen . queryByRole ( 'button' , { name : / n e w / i } ) ) . not . toBeInTheDocument ( ) ;
156
156
expect ( screen . getByText ( 'Read Only' ) ) . toBeInTheDocument ( ) ;
157
157
} ) ;
0 commit comments