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

Migrate 'nux' e2e tests to Playwright #57542

Merged
merged 2 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
162 changes: 0 additions & 162 deletions packages/e2e-tests/specs/editor/various/nux.test.js

This file was deleted.

138 changes: 138 additions & 0 deletions test/e2e/specs/editor/various/nux.spec.js
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();
} );
} );
Loading