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 to add a new page
- Loading branch information
Showing
1 changed file
with
49 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,49 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); | ||
|
||
test.describe( 'Add New wp page', () => { | ||
test.beforeEach( async ( { admin, requestUtils } ) => { | ||
// delete all pages | ||
await requestUtils.deleteAllPages(); | ||
// Open the new page editor | ||
await admin.createNewPost( { postType: 'page' } ); | ||
Check failure on line 11 in tests/e2e/specs/pages/add-new-page.test.js GitHub Actions / Test with SCRIPT_DEBUG enabled / Run E2E tests[chromium] › pages/add-new-page.test.js:14:2 › Add New wp page › Should create new page
Check failure on line 11 in tests/e2e/specs/pages/add-new-page.test.js GitHub Actions / Test with SCRIPT_DEBUG enabled / Run E2E tests[chromium] › pages/add-new-page.test.js:14:2 › Add New wp page › Should create new page
|
||
} ); | ||
|
||
test( 'Should create new page', async ( { page, admin } ) => { | ||
// Check if the template modal is visible and close it | ||
/* if ( page.locator( '.components-modal__content' ).isVisible() ) { | ||
await page.getByLabel( 'Close', { exact: true } ).click(); | ||
} */ | ||
|
||
// Fill the title of the page | ||
await page | ||
.frameLocator( 'iframe[name="editor-canvas"]' ) | ||
.getByRole( 'textbox', { name: 'Add title' } ) | ||
.fill( 'Test Page' ); | ||
|
||
// Move to the next field means the description field | ||
await page.keyboard.press( 'ArrowDown' ); | ||
|
||
// Add the description for the page | ||
await page.keyboard.type( 'Test page description' ); | ||
|
||
//Click on publish button | ||
await page.click( '.editor-post-publish-panel__toggle' ); | ||
|
||
//Double check, click again on publish button | ||
await page.click( '.editor-post-publish-button' ); | ||
|
||
// A success notice should show up | ||
await expect( page.locator( '.components-snackbar' ) ).toBeVisible(); | ||
|
||
// visit all pages page | ||
await admin.visitAdminPage( '/edit.php?post_type=page' ); | ||
|
||
// validate that the created page is present | ||
await expect( | ||
page.getByRole( 'link', { name: '“Test Page” (Edit)' } ) | ||
).toBeVisible(); | ||
} ); | ||
} ); |