mirrored from git://develop.git.wordpress.org/
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Playwright e2e test for edit page
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 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
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 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
Check failure on line 12 in tests/e2e/specs/pages/edit-page.test.js 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
|
||
|
||
// 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(); | ||
} ); | ||
} ); |