From 78d00b600dd2694a25cab488cc75f9b18d193e93 Mon Sep 17 00:00:00 2001 From: Gerardo Pacheco Date: Thu, 1 Dec 2022 18:00:50 +0100 Subject: [PATCH] [Mobile] - Update Heading block E2E test (#46220) * Mobile - Add Heading block integration test with snapshot * Mobile - Update Heading block empty snapshot * Update HTML test content of reusable block Co-authored-by: Carlos Garcia --- .../src/block/test/edit.native.js | 2 +- .../test/__snapshots__/index.native.js.snap | 7 +++ .../src/heading/test/index.native.js | 44 +++++++++++++++++++ .../__device-tests__/helpers/test-data.js | 2 +- 4 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 packages/block-library/src/heading/test/__snapshots__/index.native.js.snap create mode 100644 packages/block-library/src/heading/test/index.native.js diff --git a/packages/block-library/src/block/test/edit.native.js b/packages/block-library/src/block/test/edit.native.js index b7f4fc93b842e9..4652f8ba20f385 100644 --- a/packages/block-library/src/block/test/edit.native.js +++ b/packages/block-library/src/block/test/edit.native.js @@ -23,7 +23,7 @@ const getMockedReusableBlock = ( id ) => ( { content: { raw: ` -

First Reusable block

+

First Reusable block

diff --git a/packages/block-library/src/heading/test/__snapshots__/index.native.js.snap b/packages/block-library/src/heading/test/__snapshots__/index.native.js.snap new file mode 100644 index 00000000000000..8f3d3518636d3f --- /dev/null +++ b/packages/block-library/src/heading/test/__snapshots__/index.native.js.snap @@ -0,0 +1,7 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Heading block inserts block 1`] = ` +" +

+" +`; diff --git a/packages/block-library/src/heading/test/index.native.js b/packages/block-library/src/heading/test/index.native.js new file mode 100644 index 00000000000000..fce294cf9c9920 --- /dev/null +++ b/packages/block-library/src/heading/test/index.native.js @@ -0,0 +1,44 @@ +/** + * External dependencies + */ +import { + fireEvent, + getEditorHtml, + initializeEditor, + addBlock, + getBlock, +} from 'test/helpers'; + +/** + * WordPress dependencies + */ +import { getBlockTypes, unregisterBlockType } from '@wordpress/blocks'; +import { registerCoreBlocks } from '@wordpress/block-library'; + +beforeAll( () => { + // Register all core blocks + registerCoreBlocks(); +} ); + +afterAll( () => { + // Clean up registered blocks + getBlockTypes().forEach( ( block ) => { + unregisterBlockType( block.name ); + } ); +} ); + +describe( 'Heading block', () => { + it( 'inserts block', async () => { + const screen = await initializeEditor(); + + // Add block + await addBlock( screen, 'Heading' ); + + // Get block + const headingBlock = await getBlock( screen, 'Heading' ); + fireEvent.press( headingBlock ); + expect( headingBlock ).toBeVisible(); + + expect( getEditorHtml() ).toMatchSnapshot(); + } ); +} ); diff --git a/packages/react-native-editor/__device-tests__/helpers/test-data.js b/packages/react-native-editor/__device-tests__/helpers/test-data.js index eea093081df18a..db84a7ad02926c 100644 --- a/packages/react-native-editor/__device-tests__/helpers/test-data.js +++ b/packages/react-native-editor/__device-tests__/helpers/test-data.js @@ -143,7 +143,7 @@ exports.audioBlockPlaceholder = ` `; exports.headerBlockEmpty = ` -

+

`; exports.separatorBlockEmpty = `