From 7eaba51656da3dd78ce9805290fa8b7506f1b87d Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Tue, 25 Jul 2023 10:45:06 -0400 Subject: [PATCH 1/2] test: Mock required styles for Cover block tests JavaScript logic fails due to undefined references from mocked Sass files. --- test/native/__mocks__/styleMock.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/native/__mocks__/styleMock.js b/test/native/__mocks__/styleMock.js index e06c41cf1f95e..e0c690b628234 100644 --- a/test/native/__mocks__/styleMock.js +++ b/test/native/__mocks__/styleMock.js @@ -202,4 +202,6 @@ module.exports = { embed__icon: { fill: 'black', }, + picker: {}, + pickerPointer: {}, }; From be989b606562817e371f78320ffc1574572e40ea Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Tue, 25 Jul 2023 10:52:04 -0400 Subject: [PATCH 2/2] test: Fix Cover block HEX test assertions Synchronous queries of user-facing text is generally preferred over test IDs or asynchronous queries. Additionally, the `react-native-hsv-color-picker` must be mocked to trigger the required interaction events. Lastly, selecting the white color results in a non-custom color, which does not appear to display the HEX value in the picker footer label. --- .../src/cover/test/edit.native.js | 36 +++++++++---------- .../src/color-palette/index.native.js | 1 - .../src/color-picker/index.native.js | 6 +--- test/native/setup.js | 8 +++-- 4 files changed, 23 insertions(+), 28 deletions(-) diff --git a/packages/block-library/src/cover/test/edit.native.js b/packages/block-library/src/cover/test/edit.native.js index 190570efff0f9..e742a4052d0b0 100644 --- a/packages/block-library/src/cover/test/edit.native.js +++ b/packages/block-library/src/cover/test/edit.native.js @@ -1,7 +1,7 @@ /** * External dependencies */ -import { Image } from 'react-native'; +import { Image, Pressable } from 'react-native'; import { getEditorHtml, initializeEditor, @@ -12,6 +12,7 @@ import { getBlock, openBlockSettings, } from 'test/helpers'; +import HsvColorPicker from 'react-native-hsv-color-picker'; /** * WordPress dependencies @@ -65,7 +66,6 @@ const COVER_BLOCK_CUSTOM_HEIGHT_HTML = `