Skip to content

Commit

Permalink
Rename 'page content lock' to 'page content focus' (#51280)
Browse files Browse the repository at this point in the history
noisysocks authored Jun 8, 2023
1 parent 1cd2392 commit fd19c59
Showing 19 changed files with 126 additions and 128 deletions.
12 changes: 6 additions & 6 deletions docs/reference-guides/data/data-core-edit-site.md
Original file line number Diff line number Diff line change
@@ -131,17 +131,17 @@ _Returns_

- `Object`: Settings.

### hasPageContentLock
### hasPageContentFocus

Whether or not the editor is locked so that only page content can be edited.
Whether or not the editor allows only page content to be edited.

_Parameters_

- _state_ `Object`: Global application state.

_Returns_

- `boolean`: Whether or not the editor is locked.
- `boolean`: Whether or not focus is on editing page content.

### isFeatureActive

@@ -280,13 +280,13 @@ _Returns_

- `number`: The resolved template ID for the page route.

### setHasPageContentLock
### setHasPageContentFocus

Sets whether or not the editor is locked so that only page content can be edited.
Sets whether or not the editor allows only page content to be edited.

_Parameters_

- _hasPageContentLock_ `boolean`: True to enable lock, false to disable.
- _hasPageContentFocus_ `boolean`: True to allow only page content to be edited, false to allow template to be edited.

### setHomeTemplateId

16 changes: 8 additions & 8 deletions packages/edit-site/src/components/block-editor/index.js
Original file line number Diff line number Diff line change
@@ -39,9 +39,9 @@ import EditorCanvas from './editor-canvas';
import { unlock } from '../../private-apis';
import EditorCanvasContainer from '../editor-canvas-container';
import {
PageContentLock,
usePageContentLockNotifications,
} from '../page-content-lock';
DisableNonPageContentBlocks,
usePageContentFocusNotifications,
} from '../page-content-focus';

const { ExperimentalBlockEditorProvider } = unlock( blockEditorPrivateApis );

@@ -53,21 +53,21 @@ const LAYOUT = {

export default function BlockEditor() {
const { setIsInserterOpened } = useDispatch( editSiteStore );
const { storedSettings, templateType, canvasMode, hasPageContentLock } =
const { storedSettings, templateType, canvasMode, hasPageContentFocus } =
useSelect(
( select ) => {
const {
getSettings,
getEditedPostType,
getCanvasMode,
hasPageContentLock: _hasPageContentLock,
hasPageContentFocus: _hasPageContentFocus,
} = unlock( select( editSiteStore ) );

return {
storedSettings: getSettings( setIsInserterOpened ),
templateType: getEditedPostType(),
canvasMode: getCanvasMode(),
hasPageContentLock: _hasPageContentLock(),
hasPageContentFocus: _hasPageContentFocus(),
};
},
[ setIsInserterOpened ]
@@ -146,7 +146,7 @@ export default function BlockEditor() {
contentRef,
useClipboardHandler(),
useTypingObserver(),
usePageContentLockNotifications(),
usePageContentFocusNotifications(),
] );
const isMobileViewport = useViewportMatch( 'small', '<' );
const { clearSelectedBlock } = useDispatch( blockEditorStore );
@@ -172,7 +172,7 @@ export default function BlockEditor() {
onChange={ onChange }
useSubRegistry={ false }
>
{ hasPageContentLock && <PageContentLock /> }
{ hasPageContentFocus && <DisableNonPageContentBlocks /> }
<TemplatePartConverter />
<SidebarInspectorFill>
<BlockInspector />
12 changes: 6 additions & 6 deletions packages/edit-site/src/components/editor/index.js
Original file line number Diff line number Diff line change
@@ -73,15 +73,15 @@ export default function Editor( { isLoading } ) {
isListViewOpen,
showIconLabels,
showBlockBreadcrumbs,
hasPageContentLock,
hasPageContentFocus,
} = useSelect( ( select ) => {
const {
getEditedPostContext,
getEditorMode,
getCanvasMode,
isInserterOpened,
isListViewOpened,
hasPageContentLock: _hasPageContentLock,
hasPageContentFocus: _hasPageContentFocus,
} = unlock( select( editSiteStore ) );
const { __unstableGetEditorMode } = select( blockEditorStore );
const { getActiveComplementaryArea } = select( interfaceStore );
@@ -106,7 +106,7 @@ export default function Editor( { isLoading } ) {
'core/edit-site',
'showBlockBreadcrumbs'
),
hasPageContentLock: _hasPageContentLock(),
hasPageContentFocus: _hasPageContentFocus(),
};
}, [] );
const { setEditedPostContext } = useDispatch( editSiteStore );
@@ -127,7 +127,7 @@ export default function Editor( { isLoading } ) {
const blockContext = useMemo( () => {
const { postType, postId, ...nonPostFields } = context ?? {};
return {
...( hasPageContentLock ? context : nonPostFields ),
...( hasPageContentFocus ? context : nonPostFields ),
queryContext: [
context?.queryContext || { page: 1 },
( newQueryContext ) =>
@@ -140,7 +140,7 @@ export default function Editor( { isLoading } ) {
} ),
],
};
}, [ hasPageContentLock, context, setEditedPostContext ] );
}, [ hasPageContentFocus, context, setEditedPostContext ] );

let title;
if ( hasLoadedPost ) {
@@ -230,7 +230,7 @@ export default function Editor( { isLoading } ) {
shouldShowBlockBreakcrumbs && (
<BlockBreadcrumb
rootLabelText={
hasPageContentLock
hasPageContentFocus
? __( 'Page' )
: __( 'Template' )
}
Original file line number Diff line number Diff line change
@@ -36,9 +36,9 @@ export default function DocumentActions() {
}

function PageDocumentActions() {
const { hasPageContentLock, context } = useSelect(
const { hasPageContentFocus, context } = useSelect(
( select ) => ( {
hasPageContentLock: select( editSiteStore ).hasPageContentLock(),
hasPageContentFocus: select( editSiteStore ).hasPageContentFocus(),
context: select( editSiteStore ).getEditedPostContext(),
} ),
[]
@@ -50,16 +50,16 @@ function PageDocumentActions() {
context.postId
);

const { setHasPageContentLock } = useDispatch( editSiteStore );
const { setHasPageContentFocus } = useDispatch( editSiteStore );

const [ hasEditedTemplate, setHasEditedTemplate ] = useState( false );
const prevHasPageContentLock = useRef( false );
const prevHasPageContentFocus = useRef( false );
useEffect( () => {
if ( prevHasPageContentLock.current && ! hasPageContentLock ) {
if ( prevHasPageContentFocus.current && ! hasPageContentFocus ) {
setHasEditedTemplate( true );
}
prevHasPageContentLock.current = hasPageContentLock;
}, [ hasPageContentLock ] );
prevHasPageContentFocus.current = hasPageContentFocus;
}, [ hasPageContentFocus ] );

if ( ! hasResolved ) {
return null;
@@ -73,7 +73,7 @@ function PageDocumentActions() {
);
}

return hasPageContentLock ? (
return hasPageContentFocus ? (
<BaseDocumentActions
className={ classnames( 'is-page', {
'is-animated': hasEditedTemplate,
@@ -85,7 +85,7 @@ function PageDocumentActions() {
) : (
<TemplateDocumentActions
className="is-animated"
onBack={ () => setHasPageContentLock( true ) }
onBack={ () => setHasPageContentFocus( true ) }
/>
);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const CONTENT_BLOCK_TYPES = [
export const PAGE_CONTENT_BLOCK_TYPES = [
'core/post-title',
'core/post-featured-image',
'core/post-content',
Original file line number Diff line number Diff line change
@@ -10,20 +10,28 @@ import { useEffect } from '@wordpress/element';
* Internal dependencies
*/
import { unlock } from '../../private-apis';
import { CONTENT_BLOCK_TYPES } from './constants';
import { PAGE_CONTENT_BLOCK_TYPES } from './constants';

const { useBlockEditingMode } = unlock( blockEditorPrivateApis );

/**
* Component that when rendered, makes it so that the site editor allows only
* page content to be edited.
*/
export function DisableNonPageContentBlocks() {
useDisableNonPageContentBlocks();
}

/**
* Disables non-content blocks using the `useBlockEditingMode` hook.
*/
export function useDisableNonContentBlocks() {
export function useDisableNonPageContentBlocks() {
useBlockEditingMode( 'disabled' );
useEffect( () => {
addFilter(
'editor.BlockEdit',
'core/edit-site/disable-non-content-blocks',
withDisableNonContentBlocks
withDisableNonPageContentBlocks
);
return () =>
removeFilter(
@@ -33,12 +41,12 @@ export function useDisableNonContentBlocks() {
}, [] );
}

const withDisableNonContentBlocks = createHigherOrderComponent(
const withDisableNonPageContentBlocks = createHigherOrderComponent(
( BlockEdit ) => ( props ) => {
const isContent = CONTENT_BLOCK_TYPES.includes( props.name );
const isContent = PAGE_CONTENT_BLOCK_TYPES.includes( props.name );
const mode = isContent ? 'contentOnly' : undefined;
useBlockEditingMode( mode );
return <BlockEdit { ...props } />;
},
'withBlockEditingMode'
'withDisableNonPageContentBlocks'
);
2 changes: 2 additions & 0 deletions packages/edit-site/src/components/page-content-focus/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './disable-non-page-content-blocks';
export { usePageContentFocusNotifications } from './use-page-content-focus-notifications';
Original file line number Diff line number Diff line change
@@ -20,38 +20,38 @@ import { store as editSiteStore } from '../../store';
* (using useMergeRefs()) to
* the editor iframe canvas.
*/
export function usePageContentLockNotifications() {
export function usePageContentFocusNotifications() {
const ref = useEditTemplateNotification();
useBackToPageNotification();
return ref;
}

/**
* Hook that displays a 'Edit your template to edit this block' notification
* when the user is focusing on editing page content and clicks on a locked
* when the user is focusing on editing page content and clicks on a disabled
* template block.
*
* @return {import('react').RefObject<HTMLElement>} Ref which should be passed
* (using useMergeRefs()) to
* the editor iframe canvas.
*/
function useEditTemplateNotification() {
const hasPageContentLock = useSelect(
( select ) => select( editSiteStore ).hasPageContentLock(),
const hasPageContentFocus = useSelect(
( select ) => select( editSiteStore ).hasPageContentFocus(),
[]
);

const alreadySeen = useRef( false );

const { createInfoNotice } = useDispatch( noticesStore );
const { setHasPageContentLock } = useDispatch( editSiteStore );
const { setHasPageContentFocus } = useDispatch( editSiteStore );

return useRefEffect(
( node ) => {
const handleClick = ( event ) => {
if (
! alreadySeen.current &&
hasPageContentLock &&
hasPageContentFocus &&
event.target.classList.contains( 'is-root-container' )
) {
createInfoNotice(
@@ -63,7 +63,7 @@ function useEditTemplateNotification() {
{
label: __( 'Edit template' ),
onClick: () =>
setHasPageContentLock( false ),
setHasPageContentFocus( false ),
},
],
}
@@ -75,10 +75,10 @@ function useEditTemplateNotification() {
return () => node.removeEventListener( 'click', handleClick );
},
[
hasPageContentLock,
hasPageContentFocus,
alreadySeen,
createInfoNotice,
setHasPageContentLock,
setHasPageContentFocus,
]
);
}
@@ -88,41 +88,41 @@ function useEditTemplateNotification() {
* switches from focusing on editing page content to editing a template.
*/
function useBackToPageNotification() {
const hasPageContentLock = useSelect(
( select ) => select( editSiteStore ).hasPageContentLock(),
const hasPageContentFocus = useSelect(
( select ) => select( editSiteStore ).hasPageContentFocus(),
[]
);

const alreadySeen = useRef( false );
const prevHasPageContentLock = useRef( false );
const prevHasPageContentFocus = useRef( false );

const { createInfoNotice } = useDispatch( noticesStore );
const { setHasPageContentLock } = useDispatch( editSiteStore );
const { setHasPageContentFocus } = useDispatch( editSiteStore );

useEffect( () => {
if (
! alreadySeen.current &&
prevHasPageContentLock.current &&
! hasPageContentLock
prevHasPageContentFocus.current &&
! hasPageContentFocus
) {
createInfoNotice( __( 'You are editing a template' ), {
isDismissible: true,
type: 'snackbar',
actions: [
{
label: __( 'Back to page' ),
onClick: () => setHasPageContentLock( true ),
onClick: () => setHasPageContentFocus( true ),
},
],
} );
alreadySeen.current = true;
}
prevHasPageContentLock.current = hasPageContentLock;
prevHasPageContentFocus.current = hasPageContentFocus;
}, [
alreadySeen,
prevHasPageContentLock,
hasPageContentLock,
prevHasPageContentFocus,
hasPageContentFocus,
createInfoNotice,
setHasPageContentLock,
setHasPageContentFocus,
] );
}
14 changes: 0 additions & 14 deletions packages/edit-site/src/components/page-content-lock/index.js

This file was deleted.

10 changes: 5 additions & 5 deletions packages/edit-site/src/components/sidebar-edit-mode/index.js
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ export function SidebarComplementaryAreaFills() {
isEditorSidebarOpened,
hasBlockSelection,
supportsGlobalStyles,
hasPageContentLock,
hasPageContentFocus,
} = useSelect( ( select ) => {
const _sidebar =
select( interfaceStore ).getActiveComplementaryArea( STORE_NAME );
@@ -48,23 +48,23 @@ export function SidebarComplementaryAreaFills() {
hasBlockSelection:
!! select( blockEditorStore ).getBlockSelectionStart(),
supportsGlobalStyles: ! settings?.supportsTemplatePartsMode,
hasPageContentLock: select( editSiteStore ).hasPageContentLock(),
hasPageContentFocus: select( editSiteStore ).hasPageContentFocus(),
};
}, [] );
const { enableComplementaryArea } = useDispatch( interfaceStore );

useEffect( () => {
// Don't automatically switch tab when the sidebar is closed or when we
// are focused on page content.
if ( ! isEditorSidebarOpened || hasPageContentLock ) {
if ( ! isEditorSidebarOpened || hasPageContentFocus ) {
return;
}
if ( hasBlockSelection ) {
enableComplementaryArea( STORE_NAME, SIDEBAR_BLOCK );
} else {
enableComplementaryArea( STORE_NAME, SIDEBAR_TEMPLATE );
}
}, [ hasBlockSelection, isEditorSidebarOpened, hasPageContentLock ] );
}, [ hasBlockSelection, isEditorSidebarOpened, hasPageContentFocus ] );

let sidebarName = sidebar;
if ( ! isEditorSidebarOpened ) {
@@ -83,7 +83,7 @@ export function SidebarComplementaryAreaFills() {
>
{ sidebarName === SIDEBAR_TEMPLATE && (
<>
{ hasPageContentLock ? (
{ hasPageContentFocus ? (
<PagePanels />
) : (
<TemplatePanel />
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ import { store as blockEditorStore, BlockIcon } from '@wordpress/block-editor';
/**
* Internal dependencies
*/
import { CONTENT_BLOCK_TYPES } from '../../page-content-lock/constants';
import { PAGE_CONTENT_BLOCK_TYPES } from '../../page-content-focus/constants';

// TODO: This overlaps a lot with BlockInspectorLockedBlocks in
// @wordpress/block-editor. DRY them into a single component.
@@ -29,7 +29,7 @@ export default function ContentBlocksList() {
} = select( blockEditorStore );
return getClientIdsWithDescendants().flatMap( ( clientId ) => {
const blockName = getBlockName( clientId );
if ( ! CONTENT_BLOCK_TYPES.includes( blockName ) ) {
if ( ! PAGE_CONTENT_BLOCK_TYPES.includes( blockName ) ) {
return [];
}
return [
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ export default function PagePanels() {
record: template,
} = useEditedEntityRecord();

const { setHasPageContentLock } = useDispatch( editSiteStore );
const { setHasPageContentFocus } = useDispatch( editSiteStore );

const blockContext = useMemo(
() => ( { ...context, postType: null, postId: null } ),
@@ -78,7 +78,7 @@ export default function PagePanels() {
<Button
className="edit-site-page-panels__edit-template-button"
variant="secondary"
onClick={ () => setHasPageContentLock( false ) }
onClick={ () => setHasPageContentFocus( false ) }
>
{ __( 'Edit template' ) }
</Button>
Original file line number Diff line number Diff line change
@@ -19,8 +19,8 @@ import { SIDEBAR_BLOCK, SIDEBAR_TEMPLATE } from '../constants';
import { store as editSiteStore } from '../../../store';

const SettingsHeader = ( { sidebarName } ) => {
const hasPageContentLock = useSelect( ( select ) =>
select( editSiteStore ).hasPageContentLock()
const hasPageContentFocus = useSelect( ( select ) =>
select( editSiteStore ).hasPageContentFocus()
);

const { enableComplementaryArea } = useDispatch( interfaceStore );
@@ -30,7 +30,7 @@ const SettingsHeader = ( { sidebarName } ) => {
enableComplementaryArea( STORE_NAME, SIDEBAR_BLOCK );

let templateAriaLabel;
if ( hasPageContentLock ) {
if ( hasPageContentFocus ) {
templateAriaLabel =
sidebarName === SIDEBAR_TEMPLATE
? // translators: ARIA label for the Template sidebar tab, selected.
@@ -60,10 +60,10 @@ const SettingsHeader = ( { sidebarName } ) => {
) }
aria-label={ templateAriaLabel }
data-label={
hasPageContentLock ? __( 'Page' ) : __( 'Template' )
hasPageContentFocus ? __( 'Page' ) : __( 'Template' )
}
>
{ hasPageContentLock ? __( 'Page' ) : __( 'Template' ) }
{ hasPageContentFocus ? __( 'Page' ) : __( 'Template' ) }
</Button>
</li>
<li>
17 changes: 9 additions & 8 deletions packages/edit-site/src/store/actions.js
Original file line number Diff line number Diff line change
@@ -532,19 +532,20 @@ export const switchEditorMode =
};

/**
* Sets whether or not the editor is locked so that only page content can be
* edited.
* Sets whether or not the editor allows only page content to be edited.
*
* @param {boolean} hasPageContentLock True to enable lock, false to disable.
* @param {boolean} hasPageContentFocus True to allow only page content to be
* edited, false to allow template to be
* edited.
*/
export const setHasPageContentLock =
( hasPageContentLock ) =>
export const setHasPageContentFocus =
( hasPageContentFocus ) =>
( { dispatch, registry } ) => {
if ( hasPageContentLock ) {
if ( hasPageContentFocus ) {
registry.dispatch( blockEditorStore ).clearSelectedBlock();
}
dispatch( {
type: 'SET_HAS_PAGE_CONTENT_LOCK',
hasPageContentLock,
type: 'SET_HAS_PAGE_CONTENT_FOCUS',
hasPageContentFocus,
} );
};
11 changes: 6 additions & 5 deletions packages/edit-site/src/store/reducer.js
Original file line number Diff line number Diff line change
@@ -158,19 +158,20 @@ function editorCanvasContainerView( state = undefined, action ) {
}

/**
* Reducer used to track whether the page content is locked.
* Reducer used to track whether the editor allows only page content to be
* edited.
*
* @param {boolean} state Current state.
* @param {Object} action Dispatched action.
*
* @return {boolean} Updated state.
*/
export function hasPageContentLock( state = false, action ) {
export function hasPageContentFocus( state = false, action ) {
switch ( action.type ) {
case 'SET_EDITED_POST':
return !! action.context?.postId;
case 'SET_HAS_PAGE_CONTENT_LOCK':
return action.hasPageContentLock;
case 'SET_HAS_PAGE_CONTENT_FOCUS':
return action.hasPageContentFocus;
}

return state;
@@ -185,5 +186,5 @@ export default combineReducers( {
saveViewPanel,
canvasMode,
editorCanvasContainerView,
hasPageContentLock,
hasPageContentFocus,
} );
8 changes: 4 additions & 4 deletions packages/edit-site/src/store/selectors.js
Original file line number Diff line number Diff line change
@@ -336,12 +336,12 @@ export function isPage( state ) {
}

/**
* Whether or not the editor is locked so that only page content can be edited.
* Whether or not the editor allows only page content to be edited.
*
* @param {Object} state Global application state.
*
* @return {boolean} Whether or not the editor is locked.
* @return {boolean} Whether or not focus is on editing page content.
*/
export function hasPageContentLock( state ) {
return isPage( state ) ? state.hasPageContentLock : false;
export function hasPageContentFocus( state ) {
return isPage( state ) ? state.hasPageContentFocus : false;
}
16 changes: 8 additions & 8 deletions packages/edit-site/src/store/test/actions.js
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ import { store as preferencesStore } from '@wordpress/preferences';
* Internal dependencies
*/
import { store as editSiteStore } from '..';
import { setHasPageContentLock } from '../actions';
import { setHasPageContentFocus } from '../actions';

const ENTITY_TYPES = {
wp_template: {
@@ -217,18 +217,18 @@ describe( 'actions', () => {
} );
} );

describe( 'setHasPageContentLock', () => {
describe( 'setHasPageContentFocus', () => {
it( 'toggles the page content lock on', () => {
const dispatch = jest.fn();
const clearSelectedBlock = jest.fn();
const registry = {
dispatch: () => ( { clearSelectedBlock } ),
};
setHasPageContentLock( true )( { dispatch, registry } );
setHasPageContentFocus( true )( { dispatch, registry } );
expect( clearSelectedBlock ).toHaveBeenCalled();
expect( dispatch ).toHaveBeenCalledWith( {
type: 'SET_HAS_PAGE_CONTENT_LOCK',
hasPageContentLock: true,
type: 'SET_HAS_PAGE_CONTENT_FOCUS',
hasPageContentFocus: true,
} );
} );

@@ -238,11 +238,11 @@ describe( 'actions', () => {
const registry = {
dispatch: () => ( { clearSelectedBlock } ),
};
setHasPageContentLock( false )( { dispatch, registry } );
setHasPageContentFocus( false )( { dispatch, registry } );
expect( clearSelectedBlock ).not.toHaveBeenCalled();
expect( dispatch ).toHaveBeenCalledWith( {
type: 'SET_HAS_PAGE_CONTENT_LOCK',
hasPageContentLock: false,
type: 'SET_HAS_PAGE_CONTENT_FOCUS',
hasPageContentFocus: false,
} );
} );
} );
22 changes: 11 additions & 11 deletions packages/edit-site/src/store/test/reducer.js
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ import {
editedPost,
blockInserterPanel,
listViewPanel,
hasPageContentLock,
hasPageContentFocus,
} from '../reducer';

import { setIsInserterOpened, setIsListViewOpened } from '../actions';
@@ -137,14 +137,14 @@ describe( 'state', () => {
} );
} );

describe( 'hasPageContentLocked()', () => {
describe( 'hasPageContentFocus()', () => {
it( 'defaults to false', () => {
expect( hasPageContentLock( undefined, {} ) ).toBe( false );
expect( hasPageContentFocus( undefined, {} ) ).toBe( false );
} );

it( 'becomes false when editing a template', () => {
expect(
hasPageContentLock( true, {
hasPageContentFocus( true, {
type: 'SET_EDITED_POST',
postType: 'wp_template',
} )
@@ -153,7 +153,7 @@ describe( 'state', () => {

it( 'becomes true when editing a page', () => {
expect(
hasPageContentLock( false, {
hasPageContentFocus( false, {
type: 'SET_EDITED_POST',
postType: 'wp_template',
context: {
@@ -166,15 +166,15 @@ describe( 'state', () => {

it( 'can be set', () => {
expect(
hasPageContentLock( false, {
type: 'SET_HAS_PAGE_CONTENT_LOCK',
hasPageContentLock: true,
hasPageContentFocus( false, {
type: 'SET_HAS_PAGE_CONTENT_FOCUS',
hasPageContentFocus: true,
} )
).toBe( true );
expect(
hasPageContentLock( true, {
type: 'SET_HAS_PAGE_CONTENT_LOCK',
hasPageContentLock: false,
hasPageContentFocus( true, {
type: 'SET_HAS_PAGE_CONTENT_FOCUS',
hasPageContentFocus: false,
} )
).toBe( false );
} );
16 changes: 8 additions & 8 deletions packages/edit-site/src/store/test/selectors.js
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ import {
isListViewOpened,
__unstableGetPreference,
isPage,
hasPageContentLock,
hasPageContentFocus,
} from '../selectors';

describe( 'selectors', () => {
@@ -169,16 +169,16 @@ describe( 'selectors', () => {
} );
} );

describe( 'hasPageContentLock', () => {
describe( 'hasPageContentFocus', () => {
it( 'returns true if locked and the edited post type is a page', () => {
const state = {
editedPost: {
postType: 'wp_template',
context: { postType: 'page', postId: 123 },
},
hasPageContentLock: true,
hasPageContentFocus: true,
};
expect( hasPageContentLock( state ) ).toBe( true );
expect( hasPageContentFocus( state ) ).toBe( true );
} );

it( 'returns false if not locked and the edited post type is a page', () => {
@@ -187,19 +187,19 @@ describe( 'selectors', () => {
postType: 'wp_template',
context: { postType: 'page', postId: 123 },
},
hasPageContentLock: false,
hasPageContentFocus: false,
};
expect( hasPageContentLock( state ) ).toBe( false );
expect( hasPageContentFocus( state ) ).toBe( false );
} );

it( 'returns false if locked and the edited post type is a template', () => {
const state = {
editedPost: {
postType: 'wp_template',
},
hasPageContentLock: true,
hasPageContentFocus: true,
};
expect( hasPageContentLock( state ) ).toBe( false );
expect( hasPageContentFocus( state ) ).toBe( false );
} );
} );
} );

1 comment on commit fd19c59

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in fd19c59.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5205958419
📝 Reported issues:

Please sign in to comment.