@@ -190,14 +190,17 @@ describe('<ReferenceArrayInputController />', () => {
190
190
expect ( queryByText ( 'ra.input.references.all_missing' ) ) . toBeNull ( ) ;
191
191
} ) ;
192
192
193
- it ( 'should set warning if references fetch fails but selected references are not empty' , ( ) => {
193
+ it ( 'should set warning if references fetch fails but selected references are not empty' , async ( ) => {
194
194
const children = jest . fn ( ( { warning } ) => < div > { warning } </ div > ) ;
195
195
const { queryByText } = renderWithRedux (
196
196
< Form
197
197
onSubmit = { jest . fn ( ) }
198
198
render = { ( ) => (
199
199
< ReferenceArrayInputController
200
200
{ ...defaultProps }
201
+ // Avoid global collision in useGetMany with queriesToCall
202
+ basePath = "/articles"
203
+ resource = "articles"
201
204
input = { { value : [ 1 , 2 ] } }
202
205
>
203
206
{ children }
@@ -220,23 +223,30 @@ describe('<ReferenceArrayInputController />', () => {
220
223
} ,
221
224
references : {
222
225
possibleValues : {
223
- 'posts @tag_ids' : { error : 'boom' } ,
226
+ 'articles @tag_ids' : { error : 'boom' } ,
224
227
} ,
225
228
} ,
226
229
} ,
227
230
}
228
231
) ;
229
- expect ( queryByText ( 'ra.input.references.many_missing' ) ) . not . toBeNull ( ) ;
232
+ await waitFor ( ( ) => {
233
+ expect (
234
+ queryByText ( 'ra.input.references.many_missing' )
235
+ ) . not . toBeNull ( ) ;
236
+ } ) ;
230
237
} ) ;
231
238
232
- it ( 'should set warning if references were found but selected references are not complete' , ( ) => {
239
+ it ( 'should set warning if references were found but selected references are not complete' , async ( ) => {
233
240
const children = jest . fn ( ( { warning } ) => < div > { warning } </ div > ) ;
234
241
const { queryByText } = renderWithRedux (
235
242
< Form
236
243
onSubmit = { jest . fn ( ) }
237
244
render = { ( ) => (
238
245
< ReferenceArrayInputController
239
246
{ ...defaultProps }
247
+ // Avoid global collision in useGetMany with queriesToCall
248
+ basePath = "/products"
249
+ resource = "products"
240
250
input = { { value : [ 1 , 2 ] } }
241
251
>
242
252
{ children }
@@ -259,13 +269,17 @@ describe('<ReferenceArrayInputController />', () => {
259
269
} ,
260
270
references : {
261
271
possibleValues : {
262
- 'posts @tag_ids' : [ ] ,
272
+ 'products @tag_ids' : [ ] ,
263
273
} ,
264
274
} ,
265
275
} ,
266
276
}
267
277
) ;
268
- expect ( queryByText ( 'ra.input.references.many_missing' ) ) . not . toBeNull ( ) ;
278
+ await waitFor ( ( ) => {
279
+ expect (
280
+ queryByText ( 'ra.input.references.many_missing' )
281
+ ) . not . toBeNull ( ) ;
282
+ } ) ;
269
283
} ) ;
270
284
271
285
it ( 'should set warning if references were found but selected references are empty' , ( ) => {
@@ -276,6 +290,9 @@ describe('<ReferenceArrayInputController />', () => {
276
290
render = { ( ) => (
277
291
< ReferenceArrayInputController
278
292
{ ...defaultProps }
293
+ // Avoid global collision in useGetMany with queriesToCall
294
+ basePath = "/posters"
295
+ resource = "posters"
279
296
input = { { value : [ 1 , 2 ] } }
280
297
>
281
298
{ children }
@@ -287,7 +304,7 @@ describe('<ReferenceArrayInputController />', () => {
287
304
resources : { tags : { data : { 5 : { } , 6 : { } } } } ,
288
305
references : {
289
306
possibleValues : {
290
- 'posts @tag_ids' : [ ] ,
307
+ 'posters @tag_ids' : [ ] ,
291
308
} ,
292
309
} ,
293
310
} ,
@@ -296,7 +313,7 @@ describe('<ReferenceArrayInputController />', () => {
296
313
expect ( queryByText ( 'ra.input.references.many_missing' ) ) . not . toBeNull ( ) ;
297
314
} ) ;
298
315
299
- it ( 'should not set warning if all references were found' , ( ) => {
316
+ it ( 'should not set warning if all references were found' , async ( ) => {
300
317
const children = jest . fn ( ( { warning } ) => < div > { warning } </ div > ) ;
301
318
const { queryByText } = renderWithRedux (
302
319
< Form
@@ -335,7 +352,9 @@ describe('<ReferenceArrayInputController />', () => {
335
352
} ,
336
353
}
337
354
) ;
338
- expect ( queryByText ( 'ra.input.references.many_missing' ) ) . toBeNull ( ) ;
355
+ await waitFor ( ( ) => {
356
+ expect ( queryByText ( 'ra.input.references.many_missing' ) ) . toBeNull ( ) ;
357
+ } ) ;
339
358
} ) ;
340
359
341
360
it ( 'should call crudGetMatching on mount with default fetch values' , async ( ) => {
0 commit comments