Skip to content

Commit

Permalink
Added failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
ramonjd committed Sep 28, 2023
1 parent 4afe96f commit 37e23db
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/core-data/src/resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ export const getEntityRecords =
// When requesting all fields, the list of results can be used to
// resolve the `getEntityRecord` selector in addition to `getEntityRecords`.
// See https://github.com/WordPress/gutenberg/pull/26575
if ( ! isRevision && ! query?._fields && ! query.context ) {
if ( ! query?._fields && ! query.context ) {
const key = entityConfig.key || DEFAULT_ENTITY_KEY;
const resolutionsArgs = records
.filter( ( record ) => record[ key ] )
Expand Down
48 changes: 48 additions & 0 deletions packages/core-data/src/test/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,54 @@ describe( 'getEntityRecords', () => {
expect( postTypeFirstRecords ).toBe( postTypeSecondRecords );
expect( wpBlockFirstRecords ).toBe( wpBlockSecondRecords );
} );

it( 'should return revisions', () => {
const state = deepFreeze( {
entities: {
records: {
postType: {
post: {
revisions: {
1: {
items: {
view: {
10: {
id: 10,
content: 'chicken',
author: 'bob',
parent: 1,
},
},
},
itemIsComplete: {
view: {
10: true,
},
},
queries: {
view: {
'': [ 10 ],
},
},
},
},
},
},
},
},
} );

expect(
getEntityRecords( state, 'postType', 'post:1:revisions' )
).toBe( [
{
id: 10,
content: 'chicken',
author: 'bob',
parent: 1,
},
] );
} );
} );

describe( '__experimentalGetDirtyEntityRecords', () => {
Expand Down

0 comments on commit 37e23db

Please sign in to comment.