Skip to content

Commit

Permalink
feat: Add initial test case setup for link color support
Browse files Browse the repository at this point in the history
  • Loading branch information
im3dabasia committed Feb 11, 2025
1 parent 484ace3 commit 05c8450
Showing 1 changed file with 85 additions and 0 deletions.
85 changes: 85 additions & 0 deletions test/e2e/specs/editor/various/link-color-support.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/**
* WordPress dependencies
*/
import { test, expect } from '@wordpress/e2e-test-utils-playwright';

test.describe( 'Link color in themes', () => {
test.beforeEach( async ( { admin } ) => {
await admin.createNewPost();
} );

test( 'should apply selected link color in editor and frontend', async ( {
page,
editor,
pageUtils,
} ) => {
await editor.insertBlock( {
name: 'core/paragraph',
} );

await page.keyboard.type(
'This paragraph will have a custom link color set'
);

await page.keyboard.down( 'Shift' );
for ( let i = 0; i < 21; i++ ) {
await page.keyboard.press( 'ArrowLeft' );
}
await page.keyboard.up( 'Shift' );

await editor.clickBlockToolbarButton( 'Link' );

await page.keyboard.type( 'https://example.com' );
await pageUtils.pressKeys( 'Enter' );

await expect.poll( editor.getBlocks ).toMatchObject( [
{
name: 'core/paragraph',
attributes: {
content:
'This paragraph will have a <a href="https://example.com">custom link color set</a>',
},
},
] );

const colorOptionsButton = editor.page.locator(
'[aria-label="Color options"]'
);
await colorOptionsButton.click();

Check failure on line 48 in test/e2e/specs/editor/various/link-color-support.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 4

[chromium] › editor/various/link-color-support.spec.js:11:6 › Link color in themes › should apply selected link color in editor and frontend

1) [chromium] › editor/various/link-color-support.spec.js:11:6 › Link color in themes › should apply selected link color in editor and frontend TimeoutError: locator.click: Timeout 10000ms exceeded. Call log: - waiting for locator('[aria-label="Color options"]') 46 | '[aria-label="Color options"]' 47 | ); > 48 | await colorOptionsButton.click(); | ^ 49 | 50 | const linkButton = editor.page.locator( 51 | 'button[aria-label="Show Link"]' at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/link-color-support.spec.js:48:28

Check failure on line 48 in test/e2e/specs/editor/various/link-color-support.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 4

[chromium] › editor/various/link-color-support.spec.js:11:6 › Link color in themes › should apply selected link color in editor and frontend

1) [chromium] › editor/various/link-color-support.spec.js:11:6 › Link color in themes › should apply selected link color in editor and frontend Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── TimeoutError: locator.click: Timeout 10000ms exceeded. Call log: - waiting for locator('[aria-label="Color options"]') 46 | '[aria-label="Color options"]' 47 | ); > 48 | await colorOptionsButton.click(); | ^ 49 | 50 | const linkButton = editor.page.locator( 51 | 'button[aria-label="Show Link"]' at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/link-color-support.spec.js:48:28

Check failure on line 48 in test/e2e/specs/editor/various/link-color-support.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 4

[chromium] › editor/various/link-color-support.spec.js:11:6 › Link color in themes › should apply selected link color in editor and frontend

1) [chromium] › editor/various/link-color-support.spec.js:11:6 › Link color in themes › should apply selected link color in editor and frontend Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── TimeoutError: locator.click: Timeout 10000ms exceeded. Call log: - waiting for locator('[aria-label="Color options"]') 46 | '[aria-label="Color options"]' 47 | ); > 48 | await colorOptionsButton.click(); | ^ 49 | 50 | const linkButton = editor.page.locator( 51 | 'button[aria-label="Show Link"]' at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/link-color-support.spec.js:48:28

const linkButton = editor.page.locator(
'button[aria-label="Show Link"]'
);
await linkButton.click();

const linkMenuButton = page.locator(
'.components-button.block-editor-panel-color-gradient-settings__dropdown',
{
hasText: 'Link',
}
);
await linkMenuButton.click();

const vividCyanBlueButton = editor.page.locator(
'[aria-label="Vivid cyan blue"]'
);
await vividCyanBlueButton.click();

await pageUtils.pressKeys( 'Escape' );

const paragraphBlockLinkColor = await editor.getBlocks();

await expect(
paragraphBlockLinkColor[ 0 ].attributes.style.elements.link.color
.text
).toContain( 'var:preset|color|vivid-cyan-blue' );

await editor.openPreviewPage();

const paragraphWithLinkColor = editor.page.locator( '.has-link-color' );
expect( paragraphWithLinkColor ).not.toBeNull();

const anchorTag = editor.page.locator( '.has-link-color a' );
expect( anchorTag ).not.toBeNull();
} );
} );

0 comments on commit 05c8450

Please sign in to comment.