Skip to content

Commit

Permalink
Fix: Notice blocks don't match template doesn't appear; Add test case;
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgefilipecosta committed May 6, 2019
1 parent be8add9 commit 31c6db6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
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

0 comments on commit 31c6db6

Please sign in to comment.