-
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.
Migrate 'nux' e2e tests to Playwright (#57542)
* Migrate 'nux' e2e tests to Playwright * Remove old test file Co-authored-by: Sandesh <sandesh2643@gmail.com>
- Loading branch information
1 parent
1ba116b
commit fc3715f
Showing
2 changed files
with
138 additions
and
162 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,138 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); | ||
|
||
test.describe( 'New User Experience (NUX)', () => { | ||
test( 'should show the guide to first-time users', async ( { | ||
admin, | ||
editor, | ||
page, | ||
} ) => { | ||
await admin.createNewPost( { showWelcomeGuide: true } ); | ||
|
||
const welcomeGuide = page.getByRole( 'dialog', { | ||
name: 'Welcome to the block editor', | ||
} ); | ||
const guideHeading = welcomeGuide.getByRole( 'heading', { level: 1 } ); | ||
const nextButton = welcomeGuide.getByRole( 'button', { name: 'Next' } ); | ||
const prevButton = welcomeGuide.getByRole( 'button', { | ||
name: 'Previous', | ||
} ); | ||
|
||
await expect( guideHeading ).toHaveText( | ||
'Welcome to the block editor' | ||
); | ||
|
||
await nextButton.click(); | ||
await expect( guideHeading ).toHaveText( 'Make each block your own' ); | ||
|
||
await prevButton.click(); | ||
// Guide should be on page 1 of 4 | ||
await expect( guideHeading ).toHaveText( | ||
'Welcome to the block editor' | ||
); | ||
|
||
// Press the button for Page 2. | ||
await welcomeGuide | ||
.getByRole( 'button', { name: 'Page 2 of 4' } ) | ||
.click(); | ||
await expect( guideHeading ).toHaveText( 'Make each block your own' ); | ||
|
||
// Press the right arrow key for Page 3. | ||
await page.keyboard.press( 'ArrowRight' ); | ||
await expect( guideHeading ).toHaveText( | ||
'Get to know the block library' | ||
); | ||
|
||
// Press the right arrow key for Page 4. | ||
await page.keyboard.press( 'ArrowRight' ); | ||
await expect( guideHeading ).toHaveText( | ||
'Learn how to use the block editor' | ||
); | ||
|
||
// Click on the *visible* 'Get started' button. | ||
await welcomeGuide | ||
.getByRole( 'button', { name: 'Get started' } ) | ||
.click(); | ||
|
||
// Guide should be closed. | ||
await expect( welcomeGuide ).toBeHidden(); | ||
|
||
// Reload the editor. | ||
await page.reload(); | ||
|
||
// Guide should be closed. | ||
await expect( | ||
editor.canvas.getByRole( 'textbox', { name: 'Add title' } ) | ||
).toBeVisible(); | ||
await expect( welcomeGuide ).toBeHidden(); | ||
} ); | ||
|
||
test( 'should not show the welcome guide again if it is dismissed', async ( { | ||
admin, | ||
editor, | ||
page, | ||
} ) => { | ||
await admin.createNewPost( { showWelcomeGuide: true } ); | ||
|
||
const welcomeGuide = page.getByRole( 'dialog', { | ||
name: 'Welcome to the block editor', | ||
} ); | ||
|
||
await expect( welcomeGuide ).toBeVisible(); | ||
await welcomeGuide.getByRole( 'button', { name: 'Close' } ).click(); | ||
|
||
// Reload the editor. | ||
await page.reload(); | ||
await expect( | ||
editor.canvas.getByRole( 'textbox', { name: 'Add title' } ) | ||
).toBeFocused(); | ||
|
||
await expect( welcomeGuide ).toBeHidden(); | ||
} ); | ||
|
||
test( 'should focus post title field after welcome guide is dismissed and post is empty', async ( { | ||
admin, | ||
editor, | ||
page, | ||
} ) => { | ||
await admin.createNewPost( { showWelcomeGuide: true } ); | ||
|
||
const welcomeGuide = page.getByRole( 'dialog', { | ||
name: 'Welcome to the block editor', | ||
} ); | ||
|
||
await expect( welcomeGuide ).toBeVisible(); | ||
await welcomeGuide.getByRole( 'button', { name: 'Close' } ).click(); | ||
|
||
await expect( | ||
editor.canvas.getByRole( 'textbox', { name: 'Add title' } ) | ||
).toBeFocused(); | ||
} ); | ||
|
||
test( 'should show the welcome guide if it is manually opened', async ( { | ||
admin, | ||
page, | ||
} ) => { | ||
await admin.createNewPost(); | ||
const welcomeGuide = page.getByRole( 'dialog', { | ||
name: 'Welcome to the block editor', | ||
} ); | ||
|
||
await expect( welcomeGuide ).toBeHidden(); | ||
|
||
// Manually open the guide | ||
await page | ||
.getByRole( 'region', { | ||
name: 'Editor top bar', | ||
} ) | ||
.getByRole( 'button', { name: 'Options' } ) | ||
.click(); | ||
await page | ||
.getByRole( 'menuitemcheckbox', { name: 'Welcome Guide' } ) | ||
.click(); | ||
|
||
await expect( welcomeGuide ).toBeVisible(); | ||
} ); | ||
} ); |
fc3715f
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 fc3715f.
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/7409988357
📝 Reported issues:
/test/e2e/specs/widgets/customizing-widgets.spec.js