From 31c6db69a45a3409dd79b7f592fc3cf165add55f Mon Sep 17 00:00:00 2001 From: Jorge Date: Fri, 3 May 2019 15:37:56 +0100 Subject: [PATCH] Fix: Notice blocks don't match template doesn't appear; Add test case; --- .../e2e-tests/specs/plugins/cpt-locking.test.js | 15 +++++++++++++++ packages/editor/src/components/provider/index.js | 1 + 2 files changed, 16 insertions(+) diff --git a/packages/e2e-tests/specs/plugins/cpt-locking.test.js b/packages/e2e-tests/specs/plugins/cpt-locking.test.js index 4239716c6c1a48..74f8f81bf67e3f 100644 --- a/packages/e2e-tests/specs/plugins/cpt-locking.test.js +++ b/packages/e2e-tests/specs/plugins/cpt-locking.test.js @@ -9,6 +9,7 @@ import { getEditedPostContent, insertBlock, pressKeyTimes, + setPostContent, } from '@wordpress/e2e-test-utils'; describe( 'cpt locking', () => { @@ -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( '' ); + 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', () => { diff --git a/packages/editor/src/components/provider/index.js b/packages/editor/src/components/provider/index.js index 54405f61247b8f..31dbc721bf822f 100644 --- a/packages/editor/src/components/provider/index.js +++ b/packages/editor/src/components/provider/index.js @@ -89,6 +89,7 @@ class EditorProvider extends Component { 'isRTL', 'maxWidth', 'styles', + 'template', 'templateLock', 'titlePlaceholder', ] ),