-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Link control: migrate tests to Playwright. Can be created by selectin…
…g text and using keyboard shortcuts (#50996) * initial setup * fixed utils * update snapshots, commented waitForURLFieldAutoFocus * removed old test * removed unneeded code * removed old snapshots * use locator instead of component class * remove appender function * use locators instead of tabbing around * rename button * avoid snapshots and fix locator for Save button * removed snapshots * added comment
- Loading branch information
1 parent
2746bda
commit 069d541
Showing
3 changed files
with
69 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); | ||
|
||
test.describe( 'Links', () => { | ||
test.beforeEach( async ( { admin } ) => { | ||
await admin.createNewPost(); | ||
} ); | ||
|
||
test( `can be created by selecting text and using keyboard shortcuts`, async ( { | ||
page, | ||
editor, | ||
pageUtils, | ||
} ) => { | ||
// Create a block with some text. | ||
await editor.insertBlock( { | ||
name: 'core/paragraph', | ||
} ); | ||
await page.keyboard.type( 'This is Gutenberg' ); | ||
|
||
// Select some text. | ||
await pageUtils.pressKeys( 'shiftAlt+ArrowLeft' ); | ||
|
||
// Press Cmd+K to insert a link. | ||
await pageUtils.pressKeys( 'primary+K' ); | ||
|
||
// Type a URL. | ||
await page.keyboard.type( 'https://wordpress.org/gutenberg' ); | ||
|
||
// Open settings. | ||
await page.getByRole( 'button', { name: 'Link Settings' } ).click(); | ||
|
||
// Navigate to and toggle the "Open in new tab" checkbox. | ||
const checkbox = page.getByLabel( 'Open in new tab' ); | ||
await checkbox.click(); | ||
|
||
// Toggle should still have focus and be checked. | ||
await expect( checkbox ).toBeChecked(); | ||
await expect( checkbox ).toBeFocused(); | ||
|
||
// Ensure that the contents of the post have not been changed, since at | ||
// this point the link is still not inserted. | ||
await expect.poll( editor.getBlocks ).toMatchObject( [ | ||
{ | ||
name: 'core/paragraph', | ||
attributes: { content: 'This is Gutenberg' }, | ||
}, | ||
] ); | ||
|
||
// Tab back to the Submit and apply the link. | ||
await page | ||
//TODO: change to a better selector when https://github.com/WordPress/gutenberg/issues/51060 is resolved. | ||
.locator( '.block-editor-link-control' ) | ||
.getByRole( 'button', { name: 'Save' } ) | ||
.click(); | ||
|
||
// The link should have been inserted. | ||
await expect.poll( editor.getBlocks ).toMatchObject( [ | ||
{ | ||
name: 'core/paragraph', | ||
attributes: { | ||
content: | ||
'This is <a href="https://wordpress.org/gutenberg" target="_blank" rel="noreferrer noopener">Gutenberg</a>', | ||
}, | ||
}, | ||
] ); | ||
} ); | ||
} ); |
069d541
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flaky tests detected in 069d541.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.
🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5113693395
📝 Reported issues:
/test/e2e/specs/editor/various/autocomplete-and-mentions.spec.js