diff --git a/packages/block-library/src/cover/test/edit.js b/packages/block-library/src/cover/test/edit.js index 72f51150c27443..0a18d2cf3f9f8e 100644 --- a/packages/block-library/src/cover/test/edit.js +++ b/packages/block-library/src/cover/test/edit.js @@ -48,7 +48,7 @@ async function setup( attributes, useCoreBlocks, customSettings ) { async function createAndSelectBlock() { await userEvent.click( screen.getByRole( 'option', { - name: 'Color: Black', + name: 'Black', } ) ); await userEvent.click( @@ -73,7 +73,7 @@ describe( 'Cover block', () => { test( 'can set overlay color using color picker on block placeholder', async () => { const { container } = await setup(); const colorPicker = screen.getByRole( 'option', { - name: 'Color: Black', + name: 'Black', } ); await userEvent.click( colorPicker ); const color = colorPicker.style.backgroundColor; @@ -97,7 +97,7 @@ describe( 'Cover block', () => { await userEvent.click( screen.getByRole( 'option', { - name: 'Color: Black', + name: 'Black', } ) ); @@ -390,7 +390,7 @@ describe( 'Cover block', () => { test( 'should toggle is-light class if background changed from light to dark', async () => { await setup(); const colorPicker = screen.getByRole( 'option', { - name: 'Color: White', + name: 'White', } ); await userEvent.click( colorPicker ); @@ -406,7 +406,7 @@ describe( 'Cover block', () => { ); await userEvent.click( screen.getByText( 'Overlay' ) ); const popupColorPicker = screen.getByRole( 'option', { - name: 'Color: Black', + name: 'Black', } ); await userEvent.click( popupColorPicker ); expect( coverBlock ).not.toHaveClass( 'is-light' ); @@ -414,7 +414,7 @@ describe( 'Cover block', () => { test( 'should remove is-light class if overlay color is removed', async () => { await setup(); const colorPicker = screen.getByRole( 'option', { - name: 'Color: White', + name: 'White', } ); await userEvent.click( colorPicker ); const coverBlock = screen.getByLabelText( 'Block: Cover' ); @@ -429,7 +429,7 @@ describe( 'Cover block', () => { // The default color is black, so clicking the black color option will remove the background color, // which should remove the isDark setting and assign the is-light class. const popupColorPicker = screen.getByRole( 'option', { - name: 'Color: White', + name: 'White', } ); await userEvent.click( popupColorPicker ); expect( coverBlock ).not.toHaveClass( 'is-light' ); diff --git a/packages/components/src/border-control/test/index.js b/packages/components/src/border-control/test/index.js index ec7fb18837f97d..ff9007be28f1a2 100644 --- a/packages/components/src/border-control/test/index.js +++ b/packages/components/src/border-control/test/index.js @@ -1,7 +1,13 @@ /** * External dependencies */ -import { fireEvent, render, screen, waitFor } from '@testing-library/react'; +import { + fireEvent, + render, + screen, + waitFor, + within, +} from '@testing-library/react'; import userEvent from '@testing-library/user-event'; /** @@ -56,7 +62,7 @@ const getButton = ( name ) => { }; const getColorOption = ( color ) => { - return screen.getByRole( 'option', { name: `Color: ${ color }` } ); + return screen.getByRole( 'option', { name: `${ color }` } ); }; const queryButton = ( name ) => { @@ -131,9 +137,11 @@ describe( 'BorderControl', () => { await openPopover( user ); const customColorPicker = getButton( /Custom color picker/ ); - const colorSwatchButtons = screen.getAllByRole( 'option', { - name: /^Color:/, + const circularOptionPicker = screen.getByRole( 'listbox', { + name: 'Custom color picker.', } ); + const colorSwatchButtons = + within( circularOptionPicker ).getAllByRole( 'option' ); const styleLabel = screen.getByText( 'Style' ); const solidButton = getButton( 'Solid' ); const dashedButton = getButton( 'Dashed' );