diff --git a/packages/core-data/src/resolvers.js b/packages/core-data/src/resolvers.js index 175319b9a8ec5..9977cd0e558a6 100644 --- a/packages/core-data/src/resolvers.js +++ b/packages/core-data/src/resolvers.js @@ -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 ] ) diff --git a/packages/core-data/src/test/selectors.js b/packages/core-data/src/test/selectors.js index 5ae7a81fa144e..9786e1a4977af 100644 --- a/packages/core-data/src/test/selectors.js +++ b/packages/core-data/src/test/selectors.js @@ -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', () => {