@wordpress/core-data 7.9.0 → 7.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/actions.js +13 -9
  3. package/build/actions.js.map +1 -1
  4. package/build/batch/create-batch.js +1 -0
  5. package/build/batch/create-batch.js.map +1 -1
  6. package/build/entities.js +1 -63
  7. package/build/entities.js.map +1 -1
  8. package/build/entity-types/attachment.js.map +1 -1
  9. package/build/fetch/__experimental-fetch-url-data.js.map +1 -1
  10. package/build/hooks/use-entity-block-editor.js +4 -5
  11. package/build/hooks/use-entity-block-editor.js.map +1 -1
  12. package/build/hooks/use-entity-record.js.map +1 -1
  13. package/build/hooks/use-entity-records.js.map +1 -1
  14. package/build/hooks/use-resource-permissions.js.map +1 -1
  15. package/build/resolvers.js +56 -24
  16. package/build/resolvers.js.map +1 -1
  17. package/build/selectors.js.map +1 -1
  18. package/build-module/actions.js +14 -10
  19. package/build-module/actions.js.map +1 -1
  20. package/build-module/batch/create-batch.js +1 -0
  21. package/build-module/batch/create-batch.js.map +1 -1
  22. package/build-module/entities.js +0 -61
  23. package/build-module/entities.js.map +1 -1
  24. package/build-module/entity-types/attachment.js.map +1 -1
  25. package/build-module/fetch/__experimental-fetch-url-data.js.map +1 -1
  26. package/build-module/hooks/use-entity-block-editor.js +4 -5
  27. package/build-module/hooks/use-entity-block-editor.js.map +1 -1
  28. package/build-module/hooks/use-entity-record.js.map +1 -1
  29. package/build-module/hooks/use-entity-records.js.map +1 -1
  30. package/build-module/hooks/use-resource-permissions.js.map +1 -1
  31. package/build-module/resolvers.js +55 -24
  32. package/build-module/resolvers.js.map +1 -1
  33. package/build-module/selectors.js.map +1 -1
  34. package/build-types/actions.d.ts +8 -4
  35. package/build-types/actions.d.ts.map +1 -1
  36. package/build-types/entities.d.ts +0 -1
  37. package/build-types/entities.d.ts.map +1 -1
  38. package/build-types/entity-types/attachment.d.ts +36 -1
  39. package/build-types/entity-types/attachment.d.ts.map +1 -1
  40. package/build-types/hooks/use-entity-block-editor.d.ts.map +1 -1
  41. package/build-types/index.d.ts +8 -4
  42. package/build-types/index.d.ts.map +1 -1
  43. package/build-types/resolvers.d.ts +13 -5
  44. package/build-types/resolvers.d.ts.map +1 -1
  45. package/package.json +20 -19
  46. package/src/actions.js +10 -10
  47. package/src/entities.js +0 -64
  48. package/src/entity-types/attachment.ts +35 -1
  49. package/src/hooks/test/use-entity-record.js +9 -2
  50. package/src/hooks/use-entity-block-editor.js +4 -9
  51. package/src/resolvers.js +59 -29
  52. package/src/test/actions.js +24 -39
  53. package/src/test/entities.js +0 -80
  54. package/src/test/resolvers.js +89 -35
  55. package/tsconfig.tsbuildinfo +1 -1
@@ -68,8 +68,7 @@ describe( 'deleteEntityRecord', () => {
68
68
  __unstableAcquireStoreLock: jest.fn(),
69
69
  __unstableReleaseStoreLock: jest.fn(),
70
70
  } );
71
- // Provide entities
72
- dispatch.mockReturnValueOnce( configs );
71
+ const resolveSelect = { getEntitiesConfig: jest.fn( () => configs ) };
73
72
 
74
73
  // Provide response
75
74
  apiFetch.mockImplementation( () => deletedRecord );
@@ -78,7 +77,7 @@ describe( 'deleteEntityRecord', () => {
78
77
  'postType',
79
78
  'post',
80
79
  deletedRecord.id
81
- )( { dispatch } );
80
+ )( { dispatch, resolveSelect } );
82
81
 
83
82
  expect( apiFetch ).toHaveBeenCalledTimes( 1 );
84
83
  expect( apiFetch ).toHaveBeenCalledWith( {
@@ -86,7 +85,7 @@ describe( 'deleteEntityRecord', () => {
86
85
  method: 'DELETE',
87
86
  } );
88
87
 
89
- expect( dispatch ).toHaveBeenCalledTimes( 4 );
88
+ expect( dispatch ).toHaveBeenCalledTimes( 3 );
90
89
  expect( dispatch ).toHaveBeenCalledWith( {
91
90
  type: 'DELETE_ENTITY_RECORD_START',
92
91
  kind: 'postType',
@@ -120,8 +119,7 @@ describe( 'deleteEntityRecord', () => {
120
119
  __unstableAcquireStoreLock: jest.fn(),
121
120
  __unstableReleaseStoreLock: jest.fn(),
122
121
  } );
123
- // Provide entities
124
- dispatch.mockReturnValueOnce( entities );
122
+ const resolveSelect = { getEntitiesConfig: jest.fn( () => entities ) };
125
123
 
126
124
  // Provide response
127
125
  apiFetch.mockImplementation( () => {
@@ -137,7 +135,7 @@ describe( 'deleteEntityRecord', () => {
137
135
  {
138
136
  throwOnError: true,
139
137
  }
140
- )( { dispatch } )
138
+ )( { dispatch, resolveSelect } )
141
139
  ).rejects.toEqual( new Error( 'API error' ) );
142
140
  } );
143
141
 
@@ -151,8 +149,7 @@ describe( 'deleteEntityRecord', () => {
151
149
  __unstableAcquireStoreLock: jest.fn(),
152
150
  __unstableReleaseStoreLock: jest.fn(),
153
151
  } );
154
- // Provide entities
155
- dispatch.mockReturnValueOnce( entities );
152
+ const resolveSelect = { getEntitiesConfig: jest.fn( () => entities ) };
156
153
 
157
154
  // Provide response
158
155
  apiFetch.mockImplementation( () => {
@@ -168,7 +165,7 @@ describe( 'deleteEntityRecord', () => {
168
165
  {
169
166
  throwOnError: false,
170
167
  }
171
- )( { dispatch } )
168
+ )( { dispatch, resolveSelect } )
172
169
  ).resolves.toBe( false );
173
170
  } );
174
171
  } );
@@ -195,8 +192,7 @@ describe( 'saveEditedEntityRecord', () => {
195
192
  const dispatch = Object.assign( jest.fn(), {
196
193
  saveEntityRecord: jest.fn(),
197
194
  } );
198
- // Provide entities
199
- dispatch.mockReturnValueOnce( configs );
195
+ const resolveSelect = { getEntitiesConfig: jest.fn( () => configs ) };
200
196
 
201
197
  // Provide response
202
198
  const updatedRecord = { ...item, menu: 10 };
@@ -208,7 +204,7 @@ describe( 'saveEditedEntityRecord', () => {
208
204
  'root',
209
205
  'menuItem',
210
206
  1
211
- )( { dispatch, select } );
207
+ )( { dispatch, select, resolveSelect } );
212
208
 
213
209
  expect( dispatch.saveEntityRecord ).toHaveBeenCalledWith(
214
210
  'root',
@@ -236,8 +232,7 @@ describe( 'saveEditedEntityRecord', () => {
236
232
  const dispatch = Object.assign( jest.fn(), {
237
233
  saveEntityRecord: jest.fn(),
238
234
  } );
239
- // Provide entities
240
- dispatch.mockReturnValueOnce( configs );
235
+ const resolveSelect = { getEntitiesConfig: jest.fn( () => configs ) };
241
236
 
242
237
  // Provide response
243
238
  const updatedRecord = { ...item, menu: 10 };
@@ -249,7 +244,7 @@ describe( 'saveEditedEntityRecord', () => {
249
244
  'root',
250
245
  'menuLocation',
251
246
  'primary'
252
- )( { dispatch, select } );
247
+ )( { dispatch, select, resolveSelect } );
253
248
 
254
249
  expect( dispatch.saveEntityRecord ).toHaveBeenCalledWith(
255
250
  'root',
@@ -280,9 +275,7 @@ describe( 'saveEntityRecord', () => {
280
275
  const select = {
281
276
  getRawEntityRecord: () => post,
282
277
  };
283
-
284
- // Provide entities
285
- dispatch.mockReturnValueOnce( configs );
278
+ const resolveSelect = { getEntitiesConfig: jest.fn( () => configs ) };
286
279
 
287
280
  // Provide response
288
281
  const updatedRecord = { ...post, id: 10 };
@@ -294,7 +287,7 @@ describe( 'saveEntityRecord', () => {
294
287
  'postType',
295
288
  'post',
296
289
  post
297
- )( { select, dispatch } );
290
+ )( { select, dispatch, resolveSelect } );
298
291
 
299
292
  expect( apiFetch ).toHaveBeenCalledTimes( 1 );
300
293
  expect( apiFetch ).toHaveBeenCalledWith( {
@@ -303,7 +296,7 @@ describe( 'saveEntityRecord', () => {
303
296
  data: post,
304
297
  } );
305
298
 
306
- expect( dispatch ).toHaveBeenCalledTimes( 3 );
299
+ expect( dispatch ).toHaveBeenCalledTimes( 2 );
307
300
  expect( dispatch ).toHaveBeenCalledWith( {
308
301
  type: 'SAVE_ENTITY_RECORD_START',
309
302
  kind: 'postType',
@@ -347,9 +340,7 @@ describe( 'saveEntityRecord', () => {
347
340
  const select = {
348
341
  getRawEntityRecord: () => post,
349
342
  };
350
-
351
- // Provide entities
352
- dispatch.mockReturnValueOnce( entities );
343
+ const resolveSelect = { getEntitiesConfig: jest.fn( () => entities ) };
353
344
 
354
345
  // Provide response
355
346
  apiFetch.mockImplementation( () => {
@@ -359,7 +350,7 @@ describe( 'saveEntityRecord', () => {
359
350
  await expect(
360
351
  saveEntityRecord( 'postType', 'post', post, {
361
352
  throwOnError: true,
362
- } )( { select, dispatch } )
353
+ } )( { select, dispatch, resolveSelect } )
363
354
  ).rejects.toEqual( new Error( 'API error' ) );
364
355
  } );
365
356
 
@@ -371,9 +362,7 @@ describe( 'saveEntityRecord', () => {
371
362
  const select = {
372
363
  getRawEntityRecord: () => post,
373
364
  };
374
-
375
- // Provide entities
376
- dispatch.mockReturnValueOnce( entities );
365
+ const resolveSelect = { getEntitiesConfig: jest.fn( () => entities ) };
377
366
 
378
367
  // Provide response
379
368
  apiFetch.mockImplementation( () => {
@@ -383,7 +372,7 @@ describe( 'saveEntityRecord', () => {
383
372
  await expect(
384
373
  saveEntityRecord( 'postType', 'post', post, {
385
374
  throwOnError: false,
386
- } )( { select, dispatch } )
375
+ } )( { select, dispatch, resolveSelect } )
387
376
  ).resolves.toEqual( undefined );
388
377
  } );
389
378
 
@@ -395,9 +384,7 @@ describe( 'saveEntityRecord', () => {
395
384
  const select = {
396
385
  getRawEntityRecord: () => post,
397
386
  };
398
-
399
- // Provide entities
400
- dispatch.mockReturnValueOnce( configs );
387
+ const resolveSelect = { getEntitiesConfig: jest.fn( () => configs ) };
401
388
 
402
389
  // Provide response
403
390
  const updatedRecord = { ...post, id: 10 };
@@ -409,7 +396,7 @@ describe( 'saveEntityRecord', () => {
409
396
  'postType',
410
397
  'post',
411
398
  post
412
- )( { select, dispatch } );
399
+ )( { select, dispatch, resolveSelect } );
413
400
 
414
401
  expect( apiFetch ).toHaveBeenCalledTimes( 1 );
415
402
  expect( apiFetch ).toHaveBeenCalledWith( {
@@ -418,7 +405,7 @@ describe( 'saveEntityRecord', () => {
418
405
  data: post,
419
406
  } );
420
407
 
421
- expect( dispatch ).toHaveBeenCalledTimes( 3 );
408
+ expect( dispatch ).toHaveBeenCalledTimes( 2 );
422
409
  expect( dispatch ).toHaveBeenCalledWith( {
423
410
  type: 'SAVE_ENTITY_RECORD_START',
424
411
  kind: 'postType',
@@ -467,9 +454,7 @@ describe( 'saveEntityRecord', () => {
467
454
  const select = {
468
455
  getRawEntityRecord: () => ( {} ),
469
456
  };
470
-
471
- // Provide entities
472
- dispatch.mockReturnValueOnce( configs );
457
+ const resolveSelect = { getEntitiesConfig: jest.fn( () => configs ) };
473
458
 
474
459
  // Provide response
475
460
  apiFetch.mockImplementation( () => postType );
@@ -478,7 +463,7 @@ describe( 'saveEntityRecord', () => {
478
463
  'root',
479
464
  'postType',
480
465
  postType
481
- )( { select, dispatch } );
466
+ )( { select, dispatch, resolveSelect } );
482
467
 
483
468
  expect( apiFetch ).toHaveBeenCalledTimes( 1 );
484
469
  expect( apiFetch ).toHaveBeenCalledWith( {
@@ -487,7 +472,7 @@ describe( 'saveEntityRecord', () => {
487
472
  data: postType,
488
473
  } );
489
474
 
490
- expect( dispatch ).toHaveBeenCalledTimes( 3 );
475
+ expect( dispatch ).toHaveBeenCalledTimes( 2 );
491
476
  expect( dispatch ).toHaveBeenCalledWith( {
492
477
  type: 'SAVE_ENTITY_RECORD_START',
493
478
  kind: 'root',
@@ -1,16 +1,9 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import triggerFetch from '@wordpress/api-fetch';
5
- jest.mock( '@wordpress/api-fetch' );
6
-
7
1
  /**
8
2
  * Internal dependencies
9
3
  */
10
4
  import {
11
5
  getMethodName,
12
6
  rootEntitiesConfig,
13
- getOrLoadEntitiesConfig,
14
7
  prePersistPostType,
15
8
  } from '../entities';
16
9
 
@@ -43,79 +36,6 @@ describe( 'getMethodName', () => {
43
36
  } );
44
37
  } );
45
38
 
46
- describe( 'getKindEntities', () => {
47
- beforeEach( async () => {
48
- triggerFetch.mockReset();
49
- } );
50
-
51
- it( 'shouldn’t do anything if the entities have already been resolved', async () => {
52
- const dispatch = jest.fn();
53
- const select = {
54
- getEntitiesConfig: jest.fn( () => entities ),
55
- getEntityConfig: jest.fn( () => ( {
56
- kind: 'postType',
57
- name: 'post',
58
- } ) ),
59
- };
60
- const entities = [ { kind: 'postType' } ];
61
- await getOrLoadEntitiesConfig(
62
- 'postType',
63
- 'post'
64
- )( { dispatch, select } );
65
- expect( dispatch ).not.toHaveBeenCalled();
66
- } );
67
-
68
- it( 'shouldn’t do anything if there no defined kind config', async () => {
69
- const dispatch = jest.fn();
70
- const select = {
71
- getEntitiesConfig: jest.fn( () => [] ),
72
- getEntityConfig: jest.fn( () => undefined ),
73
- };
74
- await getOrLoadEntitiesConfig(
75
- 'unknownKind',
76
- undefined
77
- )( { dispatch, select } );
78
- expect( dispatch ).not.toHaveBeenCalled();
79
- } );
80
-
81
- it( 'should fetch and add the entities', async () => {
82
- const fetchedEntities = [
83
- {
84
- rest_base: 'posts',
85
- labels: {
86
- singular_name: 'post',
87
- },
88
- supports: {
89
- revisions: true,
90
- },
91
- },
92
- ];
93
- const dispatch = jest.fn();
94
- const select = {
95
- getEntitiesConfig: jest.fn( () => [] ),
96
- getEntityConfig: jest.fn( () => undefined ),
97
- };
98
- triggerFetch.mockImplementation( () => fetchedEntities );
99
-
100
- await getOrLoadEntitiesConfig(
101
- 'postType',
102
- 'post'
103
- )( { dispatch, select } );
104
- expect( dispatch ).toHaveBeenCalledTimes( 1 );
105
- expect( dispatch.mock.calls[ 0 ][ 0 ].type ).toBe( 'ADD_ENTITIES' );
106
- expect( dispatch.mock.calls[ 0 ][ 0 ].entities.length ).toBe( 1 );
107
- expect( dispatch.mock.calls[ 0 ][ 0 ].entities[ 0 ].baseURL ).toBe(
108
- '/wp/v2/posts'
109
- );
110
- expect(
111
- dispatch.mock.calls[ 0 ][ 0 ].entities[ 0 ].getRevisionsUrl( 1 )
112
- ).toBe( '/wp/v2/posts/1/revisions' );
113
- expect(
114
- dispatch.mock.calls[ 0 ][ 0 ].entities[ 0 ].getRevisionsUrl( 1, 2 )
115
- ).toBe( '/wp/v2/posts/1/revisions/2' );
116
- } );
117
- } );
118
-
119
39
  describe( 'prePersistPostType', () => {
120
40
  it( 'set the status to draft and empty the title when saving auto-draft posts', () => {
121
41
  let record = {
@@ -29,6 +29,7 @@ describe( 'getEntityRecord', () => {
29
29
  },
30
30
  ];
31
31
  const registry = { batch: ( callback ) => callback() };
32
+ const resolveSelect = { getEntitiesConfig: jest.fn( () => ENTITIES ) };
32
33
 
33
34
  let dispatch;
34
35
  beforeEach( async () => {
@@ -43,9 +44,6 @@ describe( 'getEntityRecord', () => {
43
44
  } );
44
45
 
45
46
  it( 'yields with requested post type', async () => {
46
- // Provide entities
47
- dispatch.mockReturnValueOnce( ENTITIES );
48
-
49
47
  // Provide response
50
48
  triggerFetch.mockImplementation( () => POST_TYPE_RESPONSE );
51
49
 
@@ -53,7 +51,7 @@ describe( 'getEntityRecord', () => {
53
51
  'root',
54
52
  'postType',
55
53
  'post'
56
- )( { dispatch, registry } );
54
+ )( { dispatch, registry, resolveSelect } );
57
55
 
58
56
  // Fetch request should have been issued.
59
57
  expect( triggerFetch ).toHaveBeenCalledWith( {
@@ -84,8 +82,6 @@ describe( 'getEntityRecord', () => {
84
82
  const select = {
85
83
  hasEntityRecords: jest.fn( () => {} ),
86
84
  };
87
- // Provide entities
88
- dispatch.mockReturnValueOnce( ENTITIES );
89
85
 
90
86
  // Provide response
91
87
  triggerFetch.mockImplementation( () => POST_TYPE_RESPONSE );
@@ -95,7 +91,7 @@ describe( 'getEntityRecord', () => {
95
91
  'postType',
96
92
  'post',
97
93
  query
98
- )( { dispatch, select, registry } );
94
+ )( { dispatch, select, registry, resolveSelect } );
99
95
 
100
96
  // Trigger apiFetch, test that the query is present in the url.
101
97
  expect( triggerFetch ).toHaveBeenCalledWith( {
@@ -141,6 +137,7 @@ describe( 'getEntityRecords', () => {
141
137
  },
142
138
  ];
143
139
  const registry = { batch: ( callback ) => callback() };
140
+ const resolveSelect = { getEntitiesConfig: jest.fn( () => ENTITIES ) };
144
141
 
145
142
  beforeEach( async () => {
146
143
  triggerFetch.mockReset();
@@ -152,13 +149,14 @@ describe( 'getEntityRecords', () => {
152
149
  __unstableAcquireStoreLock: jest.fn(),
153
150
  __unstableReleaseStoreLock: jest.fn(),
154
151
  } );
155
- // Provide entities
156
- dispatch.mockReturnValueOnce( ENTITIES );
157
152
 
158
153
  // Provide response
159
154
  triggerFetch.mockImplementation( () => POST_TYPES );
160
155
 
161
- await getEntityRecords( 'root', 'postType' )( { dispatch, registry } );
156
+ await getEntityRecords(
157
+ 'root',
158
+ 'postType'
159
+ )( { dispatch, registry, resolveSelect } );
162
160
 
163
161
  // Fetch request should have been issued.
164
162
  expect( triggerFetch ).toHaveBeenCalledWith( {
@@ -183,13 +181,14 @@ describe( 'getEntityRecords', () => {
183
181
  __unstableAcquireStoreLock: jest.fn(),
184
182
  __unstableReleaseStoreLock: jest.fn(),
185
183
  } );
186
- // Provide entities
187
- dispatch.mockReturnValueOnce( ENTITIES );
188
184
 
189
185
  // Provide response
190
186
  triggerFetch.mockImplementation( () => POST_TYPES );
191
187
 
192
- await getEntityRecords( 'root', 'postType' )( { dispatch, registry } );
188
+ await getEntityRecords(
189
+ 'root',
190
+ 'postType'
191
+ )( { dispatch, registry, resolveSelect } );
193
192
 
194
193
  // Fetch request should have been issued.
195
194
  expect( triggerFetch ).toHaveBeenCalledWith( {
@@ -216,13 +215,14 @@ describe( 'getEntityRecords', () => {
216
215
  __unstableReleaseStoreLock: jest.fn(),
217
216
  finishResolutions,
218
217
  } );
219
- // Provide entities
220
- dispatch.mockReturnValueOnce( ENTITIES );
221
218
 
222
219
  // Provide response
223
220
  triggerFetch.mockImplementation( () => POST_TYPES );
224
221
 
225
- await getEntityRecords( 'root', 'postType' )( { dispatch, registry } );
222
+ await getEntityRecords(
223
+ 'root',
224
+ 'postType'
225
+ )( { dispatch, registry, resolveSelect } );
226
226
 
227
227
  // Fetch request should have been issued.
228
228
  expect( triggerFetch ).toHaveBeenCalledWith( {
@@ -290,6 +290,7 @@ describe( 'canUser', () => {
290
290
  baseURLParams: { context: 'edit' },
291
291
  },
292
292
  ];
293
+ const resolveSelect = { getEntitiesConfig: jest.fn( () => ENTITIES ) };
293
294
 
294
295
  let dispatch, registry;
295
296
  beforeEach( async () => {
@@ -303,7 +304,6 @@ describe( 'canUser', () => {
303
304
  receiveUserPermission: jest.fn(),
304
305
  finishResolution: jest.fn(),
305
306
  } );
306
- dispatch.mockReturnValue( ENTITIES );
307
307
  triggerFetch.mockReset();
308
308
  } );
309
309
 
@@ -312,10 +312,14 @@ describe( 'canUser', () => {
312
312
  Promise.reject( { status: 404 } )
313
313
  );
314
314
 
315
- await canUser( 'create', 'media' )( { dispatch, registry } );
315
+ await canUser(
316
+ 'create',
317
+ 'media'
318
+ )( { dispatch, registry, resolveSelect } );
316
319
  await canUser( 'create', { kind: 'root', name: 'media' } )( {
317
320
  dispatch,
318
321
  registry,
322
+ resolveSelect,
319
323
  } );
320
324
 
321
325
  expect( triggerFetch ).toHaveBeenCalledWith( {
@@ -332,6 +336,7 @@ describe( 'canUser', () => {
332
336
  canUser( 'create', { name: 'wp_block' } )( {
333
337
  dispatch,
334
338
  registry,
339
+ resolveSelect,
335
340
  } )
336
341
  ).rejects.toThrow( 'The entity resource object is not valid.' );
337
342
  } );
@@ -341,7 +346,10 @@ describe( 'canUser', () => {
341
346
  headers: new Map( [ [ 'allow', 'GET' ] ] ),
342
347
  } ) );
343
348
 
344
- await canUser( 'create', 'media' )( { dispatch, registry } );
349
+ await canUser(
350
+ 'create',
351
+ 'media'
352
+ )( { dispatch, registry, resolveSelect } );
345
353
 
346
354
  expect( triggerFetch ).toHaveBeenCalledWith( {
347
355
  path: '/wp/v2/media',
@@ -363,6 +371,7 @@ describe( 'canUser', () => {
363
371
  await canUser( 'create', { kind: 'root', name: 'media' } )( {
364
372
  dispatch,
365
373
  registry,
374
+ resolveSelect,
366
375
  } );
367
376
 
368
377
  expect( triggerFetch ).toHaveBeenCalledWith( {
@@ -382,7 +391,10 @@ describe( 'canUser', () => {
382
391
  headers: new Map( [ [ 'allow', 'POST, GET, PUT, DELETE' ] ] ),
383
392
  } ) );
384
393
 
385
- await canUser( 'create', 'media' )( { dispatch, registry } );
394
+ await canUser(
395
+ 'create',
396
+ 'media'
397
+ )( { dispatch, registry, resolveSelect } );
386
398
 
387
399
  expect( triggerFetch ).toHaveBeenCalledWith( {
388
400
  path: '/wp/v2/media',
@@ -404,6 +416,7 @@ describe( 'canUser', () => {
404
416
  await canUser( 'create', { kind: 'root', name: 'media' } )( {
405
417
  dispatch,
406
418
  registry,
419
+ resolveSelect,
407
420
  } );
408
421
 
409
422
  expect( triggerFetch ).toHaveBeenCalledWith( {
@@ -423,7 +436,11 @@ describe( 'canUser', () => {
423
436
  headers: new Map( [ [ 'allow', 'POST, GET, PUT, DELETE' ] ] ),
424
437
  } ) );
425
438
 
426
- await canUser( 'create', 'blocks', 123 )( { dispatch, registry } );
439
+ await canUser(
440
+ 'create',
441
+ 'blocks',
442
+ 123
443
+ )( { dispatch, registry, resolveSelect } );
427
444
 
428
445
  expect( triggerFetch ).toHaveBeenCalledWith( {
429
446
  path: '/wp/v2/blocks/123',
@@ -449,6 +466,7 @@ describe( 'canUser', () => {
449
466
  } )( {
450
467
  dispatch,
451
468
  registry,
469
+ resolveSelect,
452
470
  } );
453
471
 
454
472
  expect( triggerFetch ).toHaveBeenCalledWith( {
@@ -475,8 +493,14 @@ describe( 'canUser', () => {
475
493
  headers: new Map( [ [ 'allow', 'POST, GET' ] ] ),
476
494
  } ) );
477
495
 
478
- await canUser( 'create', 'blocks' )( { dispatch, registry } );
479
- await canUser( 'read', 'blocks' )( { dispatch, registry } );
496
+ await canUser(
497
+ 'create',
498
+ 'blocks'
499
+ )( { dispatch, registry, resolveSelect } );
500
+ await canUser(
501
+ 'read',
502
+ 'blocks'
503
+ )( { dispatch, registry, resolveSelect } );
480
504
 
481
505
  expect( triggerFetch ).toHaveBeenCalledTimes( 1 );
482
506
 
@@ -508,6 +532,7 @@ describe( 'canUser', () => {
508
532
  } )( {
509
533
  dispatch,
510
534
  registry,
535
+ resolveSelect,
511
536
  } );
512
537
  await canUser( 'read', {
513
538
  kind: 'postType',
@@ -515,6 +540,7 @@ describe( 'canUser', () => {
515
540
  } )( {
516
541
  dispatch,
517
542
  registry,
543
+ resolveSelect,
518
544
  } );
519
545
 
520
546
  expect( triggerFetch ).toHaveBeenCalledTimes( 1 );
@@ -541,10 +567,22 @@ describe( 'canUser', () => {
541
567
  headers: new Map( [ [ 'allow', 'POST, GET' ] ] ),
542
568
  } ) );
543
569
 
544
- await canUser( 'create', 'blocks' )( { dispatch, registry } );
545
- await canUser( 'read', 'blocks' )( { dispatch, registry } );
546
- await canUser( 'update', 'blocks' )( { dispatch, registry } );
547
- await canUser( 'delete', 'blocks' )( { dispatch, registry } );
570
+ await canUser(
571
+ 'create',
572
+ 'blocks'
573
+ )( { dispatch, registry, resolveSelect } );
574
+ await canUser(
575
+ 'read',
576
+ 'blocks'
577
+ )( { dispatch, registry, resolveSelect } );
578
+ await canUser(
579
+ 'update',
580
+ 'blocks'
581
+ )( { dispatch, registry, resolveSelect } );
582
+ await canUser(
583
+ 'delete',
584
+ 'blocks'
585
+ )( { dispatch, registry, resolveSelect } );
548
586
 
549
587
  expect( dispatch.receiveUserPermission ).toHaveBeenCalledWith(
550
588
  'create/blocks',
@@ -576,10 +614,26 @@ describe( 'canUser', () => {
576
614
  headers: new Map( [ [ 'allow', 'POST, GET, PUT, DELETE' ] ] ),
577
615
  } ) );
578
616
 
579
- await canUser( 'create', 'blocks', 123 )( { dispatch, registry } );
580
- await canUser( 'read', 'blocks', 123 )( { dispatch, registry } );
581
- await canUser( 'update', 'blocks', 123 )( { dispatch, registry } );
582
- await canUser( 'delete', 'blocks', 123 )( { dispatch, registry } );
617
+ await canUser(
618
+ 'create',
619
+ 'blocks',
620
+ 123
621
+ )( { dispatch, registry, resolveSelect } );
622
+ await canUser(
623
+ 'read',
624
+ 'blocks',
625
+ 123
626
+ )( { dispatch, registry, resolveSelect } );
627
+ await canUser(
628
+ 'update',
629
+ 'blocks',
630
+ 123
631
+ )( { dispatch, registry, resolveSelect } );
632
+ await canUser(
633
+ 'delete',
634
+ 'blocks',
635
+ 123
636
+ )( { dispatch, registry, resolveSelect } );
583
637
 
584
638
  expect( triggerFetch ).toHaveBeenCalledTimes( 1 );
585
639
 
@@ -617,22 +671,22 @@ describe( 'canUser', () => {
617
671
  kind: 'postType',
618
672
  name: 'wp_block',
619
673
  id: 123,
620
- } )( { dispatch, registry } );
674
+ } )( { dispatch, registry, resolveSelect } );
621
675
  await canUser( 'read', {
622
676
  kind: 'postType',
623
677
  name: 'wp_block',
624
678
  id: 123,
625
- } )( { dispatch, registry } );
679
+ } )( { dispatch, registry, resolveSelect } );
626
680
  await canUser( 'update', {
627
681
  kind: 'postType',
628
682
  name: 'wp_block',
629
683
  id: 123,
630
- } )( { dispatch, registry } );
684
+ } )( { dispatch, registry, resolveSelect } );
631
685
  await canUser( 'delete', {
632
686
  kind: 'postType',
633
687
  name: 'wp_block',
634
688
  id: 123,
635
- } )( { dispatch, registry } );
689
+ } )( { dispatch, registry, resolveSelect } );
636
690
 
637
691
  expect( triggerFetch ).toHaveBeenCalledTimes( 1 );
638
692