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

Add Playwright e2e test for edit page #7997

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
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
45 changes: 45 additions & 0 deletions tests/e2e/specs/pages/edit-page.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* WordPress dependencies
*/
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );

test.describe( 'Edit a wp page', () => {
// Create a new page before updating it
test.beforeEach( async ( { admin, requestUtils, editor } ) => {
await requestUtils.deleteAllPages();

//Create a new page
await admin.createNewPost( { postType: 'page', title: 'Test page' } );

Check failure on line 12 in tests/e2e/specs/pages/edit-page.test.js

View workflow job for this annotation

GitHub Actions / Test with SCRIPT_DEBUG disabled / Run E2E tests

[chromium] › pages/edit-page.test.js:18:2 › Edit a wp page › should be able to edit page

2) [chromium] › pages/edit-page.test.js:18:2 › Edit a wp page › should be able to edit page ────── Error: Not logged in 10 | 11 | //Create a new page > 12 | await admin.createNewPost( { postType: 'page', title: 'Test page' } ); | ^ 13 | 14 | // publish page 15 | await editor.publishPost(); at Admin.visitAdminPage (/home/runner/work/wordpress-develop/wordpress-develop/node_modules/@wordpress/e2e-test-utils-playwright/src/admin/visit-admin-page.ts:36:9) at Admin.createNewPost (/home/runner/work/wordpress-develop/wordpress-develop/node_modules/@wordpress/e2e-test-utils-playwright/src/admin/create-new-post.ts:41:2) at /home/runner/work/wordpress-develop/wordpress-develop/tests/e2e/specs/pages/edit-page.test.js:12:3

Check failure on line 12 in tests/e2e/specs/pages/edit-page.test.js

View workflow job for this annotation

GitHub Actions / Test with SCRIPT_DEBUG disabled / Run E2E tests

[chromium] › pages/edit-page.test.js:18:2 › Edit a wp page › should be able to edit page

2) [chromium] › pages/edit-page.test.js:18:2 › Edit a wp page › should be able to edit page ────── Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: Not logged in 10 | 11 | //Create a new page > 12 | await admin.createNewPost( { postType: 'page', title: 'Test page' } ); | ^ 13 | 14 | // publish page 15 | await editor.publishPost(); at Admin.visitAdminPage (/home/runner/work/wordpress-develop/wordpress-develop/node_modules/@wordpress/e2e-test-utils-playwright/src/admin/visit-admin-page.ts:36:9) at Admin.createNewPost (/home/runner/work/wordpress-develop/wordpress-develop/node_modules/@wordpress/e2e-test-utils-playwright/src/admin/create-new-post.ts:41:2) at /home/runner/work/wordpress-develop/wordpress-develop/tests/e2e/specs/pages/edit-page.test.js:12:3

// publish page
await editor.publishPost();
} );

test( 'should be able to edit page', async ( { page, admin } ) => {
// navigate to all pages
await admin.visitAdminPage( '/edit.php?post_type=page' );

// Click on the edit link
await page.hover( 'role=link[name="“Test page” (Edit)"i]' );
await page
.getByRole( 'link', { name: 'Edit “Test page”' } )
.first()
.click();

// Update the exiting page title
await page
.frameLocator( 'iframe[name="editor-canvas"]' )
.getByRole( 'textbox', { name: 'Add title' } )
.fill( 'Test Page - Edited' );

// Click on save button
await page.getByRole( 'button', { name: 'Save', exact: true } ).click();

// A success notice should show up
await expect( page.getByTestId( 'snackbar' ) ).toBeVisible();
await admin.visitAdminPage( '/edit.php?post_type=page' );
expect(
page.getByRole( 'link', { name: 'Test Page – Edited” (Edit)' } )
).toBeVisible();
} );
} );
Loading