Skip to content

Commit

Permalink
Update selectors to classes and remove selectors from non-existent qu…
Browse files Browse the repository at this point in the history
…eries
  • Loading branch information
brookewp committed Aug 18, 2023
1 parent e19a9b5 commit 2f3b2dd
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions packages/components/src/color-palette/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,6 @@ describe( 'ColorPalette', () => {

it( 'should display the selected color name and value', async () => {
const user = userEvent.setup();
// selector for Truncate component to make test queries more explicit
const truncateComponent = {
selector: 'span[data-wp-component="Truncate"]',
};

render( <ControlledColorPalette /> );

Expand All @@ -243,10 +239,14 @@ describe( 'ColorPalette', () => {

// Confirm the correct color name, color value, and button label are used
expect(
screen.getByText( colorName, truncateComponent )
screen.getByText( colorName, {
selector: '.components-color-palette__custom-color-name',
} )
).toBeVisible();
expect(
screen.getByText( colorCode, truncateComponent )
screen.getByText( colorCode, {
selector: '.components-color-palette__custom-color-value',
} )
).toBeVisible();
expect(
screen.getByRole( 'button', {
Expand All @@ -258,13 +258,8 @@ describe( 'ColorPalette', () => {
// Clear the color, confirm that the relative values are cleared/updated.
await user.click( screen.getByRole( 'button', { name: 'Clear' } ) );
expect( screen.getByText( 'No color selected' ) ).toBeVisible();

expect(
screen.queryByText( colorName, truncateComponent )
).not.toBeInTheDocument();
expect(
screen.queryByText( colorCode, truncateComponent )
).not.toBeInTheDocument();
expect( screen.queryByText( colorName ) ).not.toBeInTheDocument();
expect( screen.queryByText( colorCode ) ).not.toBeInTheDocument();
expect(
screen.getByRole( 'button', {
name: /^Custom color picker.$/,
Expand Down

0 comments on commit 2f3b2dd

Please sign in to comment.