Skip to content

Commit

Permalink
E2E: Add test to check invisibility of warning when sufficient contrast
Browse files Browse the repository at this point in the history
  • Loading branch information
himanshupathak95 committed Jan 31, 2025
1 parent 2635c70 commit 2e79395
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions test/e2e/specs/editor/various/contrast-checker.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ test.describe( 'ContrastChecker', () => {
} ) => {
await editor.openDocumentSettingsSidebar();

const lowContrastWarning = page.locator(
'.block-editor-contrast-checker'
);

await test.step( 'Check black text on black background', async () => {
await editor.insertBlock( {
name: 'core/paragraph',
Expand All @@ -29,9 +33,6 @@ test.describe( 'ContrastChecker', () => {
await page.getByRole( 'button', { name: 'Background' } ).click();
await page.getByRole( 'option', { name: 'Black' } ).click();

const lowContrastWarning = page.locator(
'.block-editor-contrast-checker'
);
await expect( lowContrastWarning ).toBeVisible();
await expect( lowContrastWarning ).toContainText( WARNING_TEXT );
} );
Expand All @@ -47,11 +48,31 @@ test.describe( 'ContrastChecker', () => {
.click();
await page.getByRole( 'option', { name: 'White' } ).click();

const lowContrastWarning = page.locator(
'.block-editor-contrast-checker'
);
await expect( lowContrastWarning ).toBeVisible();
await expect( lowContrastWarning ).toContainText( WARNING_TEXT );
} );
} );

test( 'should not show warning for sufficient contrast', async ( {
editor,
page,
} ) => {
await editor.openDocumentSettingsSidebar();

const lowContrastWarning = page.locator(
'.block-editor-contrast-checker'
);

await editor.insertBlock( {
name: 'core/paragraph',
attributes: { content: 'Black text on White background' },
} );

await page.getByRole( 'button', { name: 'Text', exact: true } ).click();
await page.getByRole( 'option', { name: 'Black' } ).click();
await page.getByRole( 'button', { name: 'Background' } ).click();
await page.getByRole( 'option', { name: 'White' } ).click();

await expect( lowContrastWarning ).not.toBeVisible();
} );
} );

0 comments on commit 2e79395

Please sign in to comment.