@wordpress/core-data 4.1.1 → 4.2.0-next.e230fbab09.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.
- package/CHANGELOG.md +6 -0
- package/README.md +2 -10
- package/build/actions.js +9 -13
- package/build/actions.js.map +1 -1
- package/build/batch/create-batch.js +17 -12
- package/build/batch/create-batch.js.map +1 -1
- package/build/entities.js +1 -1
- package/build/entities.js.map +1 -1
- package/build/entity-types/attachment.js +6 -0
- package/build/entity-types/attachment.js.map +1 -0
- package/build/entity-types/base-entity-types.js +47 -0
- package/build/entity-types/base-entity-types.js.map +1 -0
- package/build/entity-types/comment.js +6 -0
- package/build/entity-types/comment.js.map +1 -0
- package/build/entity-types/helpers.js +6 -0
- package/build/entity-types/helpers.js.map +1 -0
- package/build/entity-types/index.js +6 -0
- package/build/entity-types/index.js.map +1 -0
- package/build/entity-types/menu-location.js +6 -0
- package/build/entity-types/menu-location.js.map +1 -0
- package/build/entity-types/nav-menu-item.js +6 -0
- package/build/entity-types/nav-menu-item.js.map +1 -0
- package/build/entity-types/nav-menu.js +6 -0
- package/build/entity-types/nav-menu.js.map +1 -0
- package/build/entity-types/navigation-area.js +6 -0
- package/build/entity-types/navigation-area.js.map +1 -0
- package/build/entity-types/page.js +6 -0
- package/build/entity-types/page.js.map +1 -0
- package/build/entity-types/plugin.js +6 -0
- package/build/entity-types/plugin.js.map +1 -0
- package/build/entity-types/post.js +6 -0
- package/build/entity-types/post.js.map +1 -0
- package/build/entity-types/settings.js +6 -0
- package/build/entity-types/settings.js.map +1 -0
- package/build/entity-types/sidebar.js +6 -0
- package/build/entity-types/sidebar.js.map +1 -0
- package/build/entity-types/taxonomy.js +6 -0
- package/build/entity-types/taxonomy.js.map +1 -0
- package/build/entity-types/theme.js +6 -0
- package/build/entity-types/theme.js.map +1 -0
- package/build/entity-types/type.js +6 -0
- package/build/entity-types/type.js.map +1 -0
- package/build/entity-types/user.js +6 -0
- package/build/entity-types/user.js.map +1 -0
- package/build/entity-types/widget-type.js +6 -0
- package/build/entity-types/widget-type.js.map +1 -0
- package/build/entity-types/widget.js +6 -0
- package/build/entity-types/widget.js.map +1 -0
- package/build/entity-types/wp-template-part.js +6 -0
- package/build/entity-types/wp-template-part.js.map +1 -0
- package/build/entity-types/wp-template.js +6 -0
- package/build/entity-types/wp-template.js.map +1 -0
- package/build/fetch/__experimental-fetch-link-suggestions.js +2 -2
- package/build/fetch/__experimental-fetch-link-suggestions.js.map +1 -1
- package/build/hooks/constants.js +18 -0
- package/build/hooks/constants.js.map +1 -0
- package/build/hooks/memoize.js +18 -0
- package/build/hooks/memoize.js.map +1 -0
- package/build/hooks/use-entity-record.js +60 -0
- package/build/hooks/use-entity-record.js.map +1 -0
- package/build/hooks/use-entity-records.js +77 -0
- package/build/hooks/use-entity-records.js.map +1 -0
- package/build/hooks/use-query-select.js +130 -0
- package/build/hooks/use-query-select.js.map +1 -0
- package/build/index.js +34 -3
- package/build/index.js.map +1 -1
- package/build/reducer.js +1 -1
- package/build/reducer.js.map +1 -1
- package/build/resolvers.js +7 -17
- package/build/resolvers.js.map +1 -1
- package/build-module/actions.js +9 -13
- package/build-module/actions.js.map +1 -1
- package/build-module/batch/create-batch.js +17 -12
- package/build-module/batch/create-batch.js.map +1 -1
- package/build-module/entities.js +1 -1
- package/build-module/entities.js.map +1 -1
- package/build-module/entity-types/attachment.js +2 -0
- package/build-module/entity-types/attachment.js.map +1 -0
- package/build-module/entity-types/base-entity-types.js +39 -0
- package/build-module/entity-types/base-entity-types.js.map +1 -0
- package/build-module/entity-types/comment.js +2 -0
- package/build-module/entity-types/comment.js.map +1 -0
- package/build-module/entity-types/helpers.js +2 -0
- package/build-module/entity-types/helpers.js.map +1 -0
- package/build-module/entity-types/index.js +2 -0
- package/build-module/entity-types/index.js.map +1 -0
- package/build-module/entity-types/menu-location.js +2 -0
- package/build-module/entity-types/menu-location.js.map +1 -0
- package/build-module/entity-types/nav-menu-item.js +2 -0
- package/build-module/entity-types/nav-menu-item.js.map +1 -0
- package/build-module/entity-types/nav-menu.js +2 -0
- package/build-module/entity-types/nav-menu.js.map +1 -0
- package/build-module/entity-types/navigation-area.js +2 -0
- package/build-module/entity-types/navigation-area.js.map +1 -0
- package/build-module/entity-types/page.js +2 -0
- package/build-module/entity-types/page.js.map +1 -0
- package/build-module/entity-types/plugin.js +2 -0
- package/build-module/entity-types/plugin.js.map +1 -0
- package/build-module/entity-types/post.js +2 -0
- package/build-module/entity-types/post.js.map +1 -0
- package/build-module/entity-types/settings.js +2 -0
- package/build-module/entity-types/settings.js.map +1 -0
- package/build-module/entity-types/sidebar.js +2 -0
- package/build-module/entity-types/sidebar.js.map +1 -0
- package/build-module/entity-types/taxonomy.js +2 -0
- package/build-module/entity-types/taxonomy.js.map +1 -0
- package/build-module/entity-types/theme.js +2 -0
- package/build-module/entity-types/theme.js.map +1 -0
- package/build-module/entity-types/type.js +2 -0
- package/build-module/entity-types/type.js.map +1 -0
- package/build-module/entity-types/user.js +2 -0
- package/build-module/entity-types/user.js.map +1 -0
- package/build-module/entity-types/widget-type.js +2 -0
- package/build-module/entity-types/widget-type.js.map +1 -0
- package/build-module/entity-types/widget.js +2 -0
- package/build-module/entity-types/widget.js.map +1 -0
- package/build-module/entity-types/wp-template-part.js +2 -0
- package/build-module/entity-types/wp-template-part.js.map +1 -0
- package/build-module/entity-types/wp-template.js +2 -0
- package/build-module/entity-types/wp-template.js.map +1 -0
- package/build-module/fetch/__experimental-fetch-link-suggestions.js +2 -2
- package/build-module/fetch/__experimental-fetch-link-suggestions.js.map +1 -1
- package/build-module/hooks/constants.js +10 -0
- package/build-module/hooks/constants.js.map +1 -0
- package/build-module/hooks/memoize.js +7 -0
- package/build-module/hooks/memoize.js.map +1 -0
- package/build-module/hooks/use-entity-record.js +49 -0
- package/build-module/hooks/use-entity-record.js.map +1 -0
- package/build-module/hooks/use-entity-records.js +65 -0
- package/build-module/hooks/use-entity-records.js.map +1 -0
- package/build-module/hooks/use-query-select.js +116 -0
- package/build-module/hooks/use-query-select.js.map +1 -0
- package/build-module/index.js +4 -2
- package/build-module/index.js.map +1 -1
- package/build-module/reducer.js +1 -1
- package/build-module/reducer.js.map +1 -1
- package/build-module/resolvers.js +8 -18
- package/build-module/resolvers.js.map +1 -1
- package/package.json +15 -11
- package/src/actions.js +9 -13
- package/src/batch/create-batch.js +16 -12
- package/src/entities.js +1 -1
- package/src/entity-types/README.md +193 -0
- package/src/entity-types/attachment.ts +146 -0
- package/src/entity-types/base-entity-types.ts +36 -0
- package/src/entity-types/comment.ts +96 -0
- package/src/entity-types/helpers.ts +153 -0
- package/src/entity-types/index.ts +72 -0
- package/src/entity-types/menu-location.ts +29 -0
- package/src/entity-types/nav-menu-item.ts +106 -0
- package/src/entity-types/nav-menu.ts +53 -0
- package/src/entity-types/navigation-area.ts +29 -0
- package/src/entity-types/page.ts +144 -0
- package/src/entity-types/plugin.ts +74 -0
- package/src/entity-types/post.ts +153 -0
- package/src/entity-types/settings.ts +93 -0
- package/src/entity-types/sidebar.ts +60 -0
- package/src/entity-types/taxonomy.ts +92 -0
- package/src/entity-types/theme.ts +222 -0
- package/src/entity-types/type.ts +80 -0
- package/src/entity-types/user.ts +109 -0
- package/src/entity-types/widget-type.ts +37 -0
- package/src/entity-types/widget.ts +64 -0
- package/src/entity-types/wp-template-part.ts +94 -0
- package/src/entity-types/wp-template.ts +94 -0
- package/src/fetch/__experimental-fetch-link-suggestions.js +2 -2
- package/src/hooks/constants.ts +7 -0
- package/src/hooks/memoize.js +7 -0
- package/src/hooks/test/use-entity-record.js +74 -0
- package/src/hooks/test/use-entity-records.js +78 -0
- package/src/hooks/test/use-query-select.js +194 -0
- package/src/hooks/use-entity-record.ts +72 -0
- package/src/hooks/use-entity-records.ts +89 -0
- package/src/hooks/use-query-select.ts +131 -0
- package/src/index.js +3 -1
- package/src/locks/test/engine.js +13 -13
- package/src/locks/test/reducer.js +3 -3
- package/src/locks/test/utils.js +2 -2
- package/src/reducer.js +1 -1
- package/src/resolvers.js +6 -17
- package/src/test/resolvers.js +17 -23
- package/src/test/selectors.js +2 -3
package/src/locks/test/engine.js
CHANGED
|
@@ -5,7 +5,7 @@ import createLocks from '../engine';
|
|
|
5
5
|
|
|
6
6
|
jest.useRealTimers();
|
|
7
7
|
|
|
8
|
-
//
|
|
8
|
+
// We correctly await all promises with expect calls, but the rule doesn't detect that.
|
|
9
9
|
/* eslint-disable jest/valid-expect-in-promise */
|
|
10
10
|
|
|
11
11
|
describe( 'Locks engine', () => {
|
|
@@ -15,11 +15,11 @@ describe( 'Locks engine', () => {
|
|
|
15
15
|
let l1Granted = false;
|
|
16
16
|
let l2Granted = false;
|
|
17
17
|
|
|
18
|
-
//
|
|
18
|
+
// Request two locks.
|
|
19
19
|
const l1 = locks.acquire( 'store', [ 'root' ], true );
|
|
20
20
|
const l2 = locks.acquire( 'store', [ 'root' ], true );
|
|
21
21
|
|
|
22
|
-
//
|
|
22
|
+
// On each grant, verify that the other lock is not granted at the same time.
|
|
23
23
|
const check1 = l1.then( () => {
|
|
24
24
|
l1Granted = true;
|
|
25
25
|
expect( l2Granted ).toBe( false );
|
|
@@ -30,7 +30,7 @@ describe( 'Locks engine', () => {
|
|
|
30
30
|
expect( l1Granted ).toBe( false );
|
|
31
31
|
} );
|
|
32
32
|
|
|
33
|
-
//
|
|
33
|
+
// Unlock both.
|
|
34
34
|
const lock1 = await l1;
|
|
35
35
|
locks.release( lock1 );
|
|
36
36
|
l1Granted = false;
|
|
@@ -39,7 +39,7 @@ describe( 'Locks engine', () => {
|
|
|
39
39
|
locks.release( lock2 );
|
|
40
40
|
l2Granted = false;
|
|
41
41
|
|
|
42
|
-
//
|
|
42
|
+
// Ensure that both locks were granted and checked.
|
|
43
43
|
return await Promise.all( [ check1, check2 ] );
|
|
44
44
|
} );
|
|
45
45
|
|
|
@@ -49,11 +49,11 @@ describe( 'Locks engine', () => {
|
|
|
49
49
|
let l1Granted = false;
|
|
50
50
|
let l2Granted = false;
|
|
51
51
|
|
|
52
|
-
//
|
|
52
|
+
// Request two locks.
|
|
53
53
|
const l1 = locks.acquire( 'store', [ 'root' ], false );
|
|
54
54
|
const l2 = locks.acquire( 'store', [ 'root' ], true );
|
|
55
55
|
|
|
56
|
-
//
|
|
56
|
+
// On each grant, verify that the other lock is not granted at the same time.
|
|
57
57
|
const check1 = l1.then( () => {
|
|
58
58
|
l1Granted = true;
|
|
59
59
|
expect( l2Granted ).toBe( false );
|
|
@@ -64,7 +64,7 @@ describe( 'Locks engine', () => {
|
|
|
64
64
|
expect( l1Granted ).toBe( false );
|
|
65
65
|
} );
|
|
66
66
|
|
|
67
|
-
//
|
|
67
|
+
// Unlock both.
|
|
68
68
|
const lock1 = await l1;
|
|
69
69
|
locks.release( lock1 );
|
|
70
70
|
l1Granted = false;
|
|
@@ -73,7 +73,7 @@ describe( 'Locks engine', () => {
|
|
|
73
73
|
locks.release( lock2 );
|
|
74
74
|
l2Granted = false;
|
|
75
75
|
|
|
76
|
-
//
|
|
76
|
+
// Ensure that both locks were granted and checked.
|
|
77
77
|
return await Promise.all( [ check1, check2 ] );
|
|
78
78
|
} );
|
|
79
79
|
|
|
@@ -83,11 +83,11 @@ describe( 'Locks engine', () => {
|
|
|
83
83
|
let l1Granted = false;
|
|
84
84
|
let l2Granted = false;
|
|
85
85
|
|
|
86
|
-
//
|
|
86
|
+
// Request two locks.
|
|
87
87
|
const l1 = locks.acquire( 'store', [ 'root' ], true );
|
|
88
88
|
const l2 = locks.acquire( 'store', [ 'root', 'child' ], true );
|
|
89
89
|
|
|
90
|
-
//
|
|
90
|
+
// On each grant, verify that the other lock is not granted at the same time.
|
|
91
91
|
const check1 = l1.then( () => {
|
|
92
92
|
l1Granted = true;
|
|
93
93
|
expect( l2Granted ).toBe( false );
|
|
@@ -98,7 +98,7 @@ describe( 'Locks engine', () => {
|
|
|
98
98
|
expect( l1Granted ).toBe( false );
|
|
99
99
|
} );
|
|
100
100
|
|
|
101
|
-
//
|
|
101
|
+
// Unlock both.
|
|
102
102
|
const lock1 = await l1;
|
|
103
103
|
locks.release( lock1 );
|
|
104
104
|
l1Granted = false;
|
|
@@ -107,7 +107,7 @@ describe( 'Locks engine', () => {
|
|
|
107
107
|
locks.release( lock2 );
|
|
108
108
|
l2Granted = false;
|
|
109
109
|
|
|
110
|
-
//
|
|
110
|
+
// Ensure that both locks were granted and checked.
|
|
111
111
|
return await Promise.all( [ check1, check2 ] );
|
|
112
112
|
} );
|
|
113
113
|
|
|
@@ -62,7 +62,7 @@ describe( 'locks', () => {
|
|
|
62
62
|
red,
|
|
63
63
|
blue,
|
|
64
64
|
green: {
|
|
65
|
-
// ...and add the lock
|
|
65
|
+
// ...and add the lock.
|
|
66
66
|
locks: [ lock ],
|
|
67
67
|
children: {},
|
|
68
68
|
},
|
|
@@ -92,7 +92,7 @@ describe( 'locks', () => {
|
|
|
92
92
|
red,
|
|
93
93
|
blue,
|
|
94
94
|
green: {
|
|
95
|
-
// ...and add the lock
|
|
95
|
+
// ...and add the lock.
|
|
96
96
|
locks: [ lock ],
|
|
97
97
|
children: {},
|
|
98
98
|
},
|
|
@@ -118,7 +118,7 @@ describe( 'locks', () => {
|
|
|
118
118
|
red,
|
|
119
119
|
blue,
|
|
120
120
|
green: {
|
|
121
|
-
// Should remove the lock
|
|
121
|
+
// Should remove the lock.
|
|
122
122
|
locks: [],
|
|
123
123
|
children: {},
|
|
124
124
|
},
|
package/src/locks/test/utils.js
CHANGED
|
@@ -193,13 +193,13 @@ describe( 'deepCopyLocksTreePath', () => {
|
|
|
193
193
|
expect( deepCopy.children ).not.toBe( tree.children );
|
|
194
194
|
expect( deepCopy.children.target ).not.toBe( tree.children.target );
|
|
195
195
|
|
|
196
|
-
// Locks lists should be preserved
|
|
196
|
+
// Locks lists should be preserved.
|
|
197
197
|
expect( deepCopy.locks ).toBe( tree.locks );
|
|
198
198
|
expect( deepCopy.children.target.locks ).toBe(
|
|
199
199
|
tree.children.target.locks
|
|
200
200
|
);
|
|
201
201
|
|
|
202
|
-
// Specific locks should be preserved
|
|
202
|
+
// Specific locks should be preserved.
|
|
203
203
|
expect( deepCopy.locks[ 0 ] ).toBe( tree.locks[ 0 ] );
|
|
204
204
|
|
|
205
205
|
// No need to clone lower levels of the tree, let's check if they're still the same:
|
package/src/reducer.js
CHANGED
|
@@ -355,7 +355,7 @@ export function entitiesConfig( state = defaultEntities, action ) {
|
|
|
355
355
|
export const entities = ( state = {}, action ) => {
|
|
356
356
|
const newConfig = entitiesConfig( state.config, action );
|
|
357
357
|
|
|
358
|
-
// Generates a dynamic reducer for the entities
|
|
358
|
+
// Generates a dynamic reducer for the entities.
|
|
359
359
|
let entitiesDataReducer = state.reducer;
|
|
360
360
|
if ( ! entitiesDataReducer || newConfig !== state.config ) {
|
|
361
361
|
const entitiesByKind = groupBy( newConfig, 'kind' );
|
package/src/resolvers.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { find, includes, get,
|
|
4
|
+
import { find, includes, get, compact, uniq } from 'lodash';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -283,11 +283,7 @@ export const canUser = ( action, resource, id ) => async ( { dispatch } ) => {
|
|
|
283
283
|
try {
|
|
284
284
|
response = await apiFetch( {
|
|
285
285
|
path,
|
|
286
|
-
|
|
287
|
-
// a bug in the REST API which causes the Allow header to not be sent on
|
|
288
|
-
// OPTIONS requests to /posts/:id routes.
|
|
289
|
-
// https://core.trac.wordpress.org/ticket/45753
|
|
290
|
-
method: id ? 'GET' : 'OPTIONS',
|
|
286
|
+
method: 'OPTIONS',
|
|
291
287
|
parse: false,
|
|
292
288
|
} );
|
|
293
289
|
} catch ( error ) {
|
|
@@ -296,17 +292,10 @@ export const canUser = ( action, resource, id ) => async ( { dispatch } ) => {
|
|
|
296
292
|
return;
|
|
297
293
|
}
|
|
298
294
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
allowHeader = response.headers.get( 'allow' );
|
|
304
|
-
} else {
|
|
305
|
-
// If the request was preloaded server-side and is returned by the
|
|
306
|
-
// preloading middleware, the header will be a simple property.
|
|
307
|
-
allowHeader = get( response, [ 'headers', 'Allow' ], '' );
|
|
308
|
-
}
|
|
309
|
-
|
|
295
|
+
// Optional chaining operator is used here because the API requests don't
|
|
296
|
+
// return the expected result in the native version. Instead, API requests
|
|
297
|
+
// only return the result, without including response properties like the headers.
|
|
298
|
+
const allowHeader = response.headers?.get( 'allow' );
|
|
310
299
|
const key = compact( [ action, resource, id ] ).join( '/' );
|
|
311
300
|
const isAllowed = includes( allowHeader, method );
|
|
312
301
|
dispatch.receiveUserPermission( key, isAllowed );
|
package/src/test/resolvers.js
CHANGED
|
@@ -46,12 +46,12 @@ describe( 'getEntityRecord', () => {
|
|
|
46
46
|
|
|
47
47
|
await getEntityRecord( 'root', 'postType', 'post' )( { dispatch } );
|
|
48
48
|
|
|
49
|
-
// Fetch request should have been issued
|
|
49
|
+
// Fetch request should have been issued.
|
|
50
50
|
expect( triggerFetch ).toHaveBeenCalledWith( {
|
|
51
51
|
path: '/wp/v2/types/post?context=edit',
|
|
52
52
|
} );
|
|
53
53
|
|
|
54
|
-
// The record should have been received
|
|
54
|
+
// The record should have been received.
|
|
55
55
|
expect( dispatch.receiveEntityRecords ).toHaveBeenCalledWith(
|
|
56
56
|
'root',
|
|
57
57
|
'postType',
|
|
@@ -59,7 +59,7 @@ describe( 'getEntityRecord', () => {
|
|
|
59
59
|
undefined
|
|
60
60
|
);
|
|
61
61
|
|
|
62
|
-
// Locks should have been acquired and released
|
|
62
|
+
// Locks should have been acquired and released.
|
|
63
63
|
expect( dispatch.__unstableAcquireStoreLock ).toHaveBeenCalledTimes(
|
|
64
64
|
1
|
|
65
65
|
);
|
|
@@ -94,19 +94,19 @@ describe( 'getEntityRecord', () => {
|
|
|
94
94
|
query
|
|
95
95
|
)( { dispatch, select } );
|
|
96
96
|
|
|
97
|
-
// Check resolution cache for an existing entity that fulfills the request with query
|
|
97
|
+
// Check resolution cache for an existing entity that fulfills the request with query.
|
|
98
98
|
expect( select.hasEntityRecords ).toHaveBeenCalledWith(
|
|
99
99
|
'root',
|
|
100
100
|
'postType',
|
|
101
101
|
queryObj
|
|
102
102
|
);
|
|
103
103
|
|
|
104
|
-
// Trigger apiFetch, test that the query is present in the url
|
|
104
|
+
// Trigger apiFetch, test that the query is present in the url.
|
|
105
105
|
expect( triggerFetch ).toHaveBeenCalledWith( {
|
|
106
106
|
path: '/wp/v2/types/post?context=view&_envelope=1',
|
|
107
107
|
} );
|
|
108
108
|
|
|
109
|
-
// The record should have been received
|
|
109
|
+
// The record should have been received.
|
|
110
110
|
expect( dispatch.receiveEntityRecords ).toHaveBeenCalledWith(
|
|
111
111
|
'root',
|
|
112
112
|
'postType',
|
|
@@ -114,7 +114,7 @@ describe( 'getEntityRecord', () => {
|
|
|
114
114
|
queryObj
|
|
115
115
|
);
|
|
116
116
|
|
|
117
|
-
// Locks should have been acquired and released
|
|
117
|
+
// Locks should have been acquired and released.
|
|
118
118
|
expect( dispatch.__unstableAcquireStoreLock ).toHaveBeenCalledTimes(
|
|
119
119
|
1
|
|
120
120
|
);
|
|
@@ -163,12 +163,12 @@ describe( 'getEntityRecords', () => {
|
|
|
163
163
|
|
|
164
164
|
await getEntityRecords( 'root', 'postType' )( { dispatch } );
|
|
165
165
|
|
|
166
|
-
// Fetch request should have been issued
|
|
166
|
+
// Fetch request should have been issued.
|
|
167
167
|
expect( triggerFetch ).toHaveBeenCalledWith( {
|
|
168
168
|
path: '/wp/v2/types?context=edit',
|
|
169
169
|
} );
|
|
170
170
|
|
|
171
|
-
// The record should have been received
|
|
171
|
+
// The record should have been received.
|
|
172
172
|
expect( dispatch.receiveEntityRecords ).toHaveBeenCalledWith(
|
|
173
173
|
'root',
|
|
174
174
|
'postType',
|
|
@@ -191,12 +191,12 @@ describe( 'getEntityRecords', () => {
|
|
|
191
191
|
|
|
192
192
|
await getEntityRecords( 'root', 'postType' )( { dispatch } );
|
|
193
193
|
|
|
194
|
-
// Fetch request should have been issued
|
|
194
|
+
// Fetch request should have been issued.
|
|
195
195
|
expect( triggerFetch ).toHaveBeenCalledWith( {
|
|
196
196
|
path: '/wp/v2/types?context=edit',
|
|
197
197
|
} );
|
|
198
198
|
|
|
199
|
-
// The record should have been received
|
|
199
|
+
// The record should have been received.
|
|
200
200
|
expect(
|
|
201
201
|
dispatch.__unstableAcquireStoreLock
|
|
202
202
|
).toHaveBeenCalledWith(
|
|
@@ -223,12 +223,12 @@ describe( 'getEntityRecords', () => {
|
|
|
223
223
|
|
|
224
224
|
await getEntityRecords( 'root', 'postType' )( { dispatch } );
|
|
225
225
|
|
|
226
|
-
// Fetch request should have been issued
|
|
226
|
+
// Fetch request should have been issued.
|
|
227
227
|
expect( triggerFetch ).toHaveBeenCalledWith( {
|
|
228
228
|
path: '/wp/v2/types?context=edit',
|
|
229
229
|
} );
|
|
230
230
|
|
|
231
|
-
// The record should have been received
|
|
231
|
+
// The record should have been received.
|
|
232
232
|
expect( dispatch ).toHaveBeenCalledWith( {
|
|
233
233
|
type: 'START_RESOLUTIONS',
|
|
234
234
|
selectorName: 'getEntityRecord',
|
|
@@ -312,9 +312,7 @@ describe( 'canUser', () => {
|
|
|
312
312
|
} );
|
|
313
313
|
|
|
314
314
|
triggerFetch.mockImplementation( () => ( {
|
|
315
|
-
headers:
|
|
316
|
-
Allow: 'GET',
|
|
317
|
-
},
|
|
315
|
+
headers: new Map( [ [ 'allow', 'GET' ] ] ),
|
|
318
316
|
} ) );
|
|
319
317
|
|
|
320
318
|
await canUser( 'create', 'media' )( { dispatch } );
|
|
@@ -337,9 +335,7 @@ describe( 'canUser', () => {
|
|
|
337
335
|
} );
|
|
338
336
|
|
|
339
337
|
triggerFetch.mockImplementation( () => ( {
|
|
340
|
-
headers:
|
|
341
|
-
Allow: 'POST, GET, PUT, DELETE',
|
|
342
|
-
},
|
|
338
|
+
headers: new Map( [ [ 'allow', 'POST, GET, PUT, DELETE' ] ] ),
|
|
343
339
|
} ) );
|
|
344
340
|
|
|
345
341
|
await canUser( 'create', 'media' )( { dispatch } );
|
|
@@ -362,16 +358,14 @@ describe( 'canUser', () => {
|
|
|
362
358
|
} );
|
|
363
359
|
|
|
364
360
|
triggerFetch.mockImplementation( () => ( {
|
|
365
|
-
headers:
|
|
366
|
-
Allow: 'POST, GET, PUT, DELETE',
|
|
367
|
-
},
|
|
361
|
+
headers: new Map( [ [ 'allow', 'POST, GET, PUT, DELETE' ] ] ),
|
|
368
362
|
} ) );
|
|
369
363
|
|
|
370
364
|
await canUser( 'create', 'blocks', 123 )( { dispatch } );
|
|
371
365
|
|
|
372
366
|
expect( triggerFetch ).toHaveBeenCalledWith( {
|
|
373
367
|
path: '/wp/v2/blocks/123',
|
|
374
|
-
method: '
|
|
368
|
+
method: 'OPTIONS',
|
|
375
369
|
parse: false,
|
|
376
370
|
} );
|
|
377
371
|
|
package/src/test/selectors.js
CHANGED
|
@@ -24,8 +24,7 @@ import {
|
|
|
24
24
|
getCurrentUser,
|
|
25
25
|
getReferenceByDistinctEdits,
|
|
26
26
|
} from '../selectors';
|
|
27
|
-
|
|
28
|
-
// getEntityRecord and __experimentalGetEntityRecordNoResolver selectors share the same tests
|
|
27
|
+
// getEntityRecord and __experimentalGetEntityRecordNoResolver selectors share the same tests.
|
|
29
28
|
describe.each( [
|
|
30
29
|
[ getEntityRecord ],
|
|
31
30
|
[ __experimentalGetEntityRecordNoResolver ],
|
|
@@ -398,7 +397,7 @@ describe( 'getEntityRecords', () => {
|
|
|
398
397
|
'wp_block'
|
|
399
398
|
);
|
|
400
399
|
|
|
401
|
-
// Simulate update states
|
|
400
|
+
// Simulate update states.
|
|
402
401
|
state = { ...state };
|
|
403
402
|
|
|
404
403
|
const postTypeSecondRecords = getEntityRecords(
|