Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Notice blocks don't match template doesn't appear; Add test case; #15418

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions packages/e2e-tests/specs/plugins/cpt-locking.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
getEditedPostContent,
insertBlock,
pressKeyTimes,
setPostContent,
} from '@wordpress/e2e-test-utils';

describe( 'cpt locking', () => {
Expand Down Expand Up @@ -67,6 +68,20 @@ describe( 'cpt locking', () => {
await pressKeyTimes( 'Backspace', textToType.length + 1 );
expect( await getEditedPostContent() ).toMatchSnapshot();
} );

it( 'should show invalid template notice if the blocks do not match the templte', async () => {
const content = await getEditedPostContent();
const [ , contentWithoutImage ] = content.split( '<!-- /wp:image -->' );
await setPostContent( contentWithoutImage );
const VALIDATION_PARAGRAPH_SELECTOR = '.editor-template-validation-notice .components-notice__content p';
await page.waitForSelector( VALIDATION_PARAGRAPH_SELECTOR );
expect(
await page.evaluate(
( element ) => element.textContent,
await page.$( VALIDATION_PARAGRAPH_SELECTOR )
)
).toEqual( 'The content of your post doesn’t match the template assigned to your post type.' );
} );
} );

describe( 'template_lock insert', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/editor/src/components/provider/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class EditorProvider extends Component {
'isRTL',
'maxWidth',
'styles',
'template',
'templateLock',
'titlePlaceholder',
] ),
Expand Down