Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing: Add e2e test for basic ContrastChecker functionality #68856

Open
wants to merge 8 commits into
base: trunk
Choose a base branch
from
57 changes: 57 additions & 0 deletions test/e2e/specs/editor/various/contrast-checker.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* WordPress dependencies
*/
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );

const WARNING_TEXT = 'This color combination may be hard for people to read';

test.describe( 'ContrastChecker', () => {
test.beforeEach( async ( { admin } ) => {
await admin.createNewPost();
} );

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

await test.step( 'Check black text on black background', async () => {
await editor.insertBlock( {
name: 'core/paragraph',
attributes: { content: 'Black text on Black 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: 'Black' } ).click();

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

await test.step( 'Check white text on default background', async () => {
await editor.insertBlock( {
name: 'core/paragraph',
attributes: { content: 'White text on Default background' },
} );

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

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

Check failure on line 53 in test/e2e/specs/editor/various/contrast-checker.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 3

[chromium] › editor/various/contrast-checker.spec.js:13:2 › ContrastChecker › should show warning for insufficient contrast

1) [chromium] › editor/various/contrast-checker.spec.js:13:2 › ContrastChecker › should show warning for insufficient contrast › Check white text on default background Error: Timed out 5000ms waiting for expect(locator).toBeVisible() Locator: locator('.block-editor-contrast-checker') Expected: visible Received: <element(s) not found> Call log: - expect.toBeVisible with timeout 5000ms - waiting for locator('.block-editor-contrast-checker') 51 | '.block-editor-contrast-checker' 52 | ); > 53 | await expect( lowContrastWarning ).toBeVisible(); | ^ 54 | await expect( lowContrastWarning ).toContainText( WARNING_TEXT ); 55 | } ); 56 | } ); at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/contrast-checker.spec.js:53:39 at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/contrast-checker.spec.js:39:3

Check failure on line 53 in test/e2e/specs/editor/various/contrast-checker.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 3

[chromium] › editor/various/contrast-checker.spec.js:13:2 › ContrastChecker › should show warning for insufficient contrast

1) [chromium] › editor/various/contrast-checker.spec.js:13:2 › ContrastChecker › should show warning for insufficient contrast › Check white text on default background Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: Timed out 5000ms waiting for expect(locator).toBeVisible() Locator: locator('.block-editor-contrast-checker') Expected: visible Received: <element(s) not found> Call log: - expect.toBeVisible with timeout 5000ms - waiting for locator('.block-editor-contrast-checker') 51 | '.block-editor-contrast-checker' 52 | ); > 53 | await expect( lowContrastWarning ).toBeVisible(); | ^ 54 | await expect( lowContrastWarning ).toContainText( WARNING_TEXT ); 55 | } ); 56 | } ); at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/contrast-checker.spec.js:53:39 at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/contrast-checker.spec.js:39:3

Check failure on line 53 in test/e2e/specs/editor/various/contrast-checker.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 3

[chromium] › editor/various/contrast-checker.spec.js:13:2 › ContrastChecker › should show warning for insufficient contrast

1) [chromium] › editor/various/contrast-checker.spec.js:13:2 › ContrastChecker › should show warning for insufficient contrast › Check white text on default background Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: Timed out 5000ms waiting for expect(locator).toBeVisible() Locator: locator('.block-editor-contrast-checker') Expected: visible Received: <element(s) not found> Call log: - expect.toBeVisible with timeout 5000ms - waiting for locator('.block-editor-contrast-checker') 51 | '.block-editor-contrast-checker' 52 | ); > 53 | await expect( lowContrastWarning ).toBeVisible(); | ^ 54 | await expect( lowContrastWarning ).toContainText( WARNING_TEXT ); 55 | } ); 56 | } ); at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/contrast-checker.spec.js:53:39 at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/contrast-checker.spec.js:39:3
await expect( lowContrastWarning ).toContainText( WARNING_TEXT );
} );
} );
} );
Loading