From 81abcec6c5248dd048df5a35d01cefcab1e83247 Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Wed, 26 Jul 2023 20:01:13 -0400 Subject: [PATCH] test: Fix Cover block color picker test (#52943) * test: Mock required styles for Cover block tests JavaScript logic fails due to undefined references from mocked Sass files. * 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/__mocks__/styleMock.js | 2 ++ test/native/setup.js | 8 +++-- 5 files changed, 25 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 = `