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 preview a 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( 'Preview page', () => { | ||
test.beforeEach( async ( { admin, editor, requestUtils } ) => { | ||
requestUtils.deleteAllPages(); | ||
|
||
await admin.createNewPost( { postType: 'page', title: 'qa page' } ); | ||
Check failure on line 10 in tests/e2e/specs/pages/preview-page.test.js GitHub Actions / Test with SCRIPT_DEBUG disabled / Run E2E tests[chromium] › pages/preview-page.test.js:16:2 › Preview page › Should be able to preview page in different viewport
|
||
|
||
// publish post | ||
await editor.publishPost(); | ||
} ); | ||
|
||
test( 'Should be able to preview page in different viewport', async ( { | ||
page, | ||
admin, | ||
} ) => { | ||
await admin.visitAdminPage( '/edit.php?post_type=page' ); | ||
|
||
await page.getByRole( 'link', { name: '“qa page” (Edit)' } ).click(); | ||
|
||
// Click Preview button | ||
await page.getByRole( 'button', { name: 'View', exact: true } ).click(); | ||
|
||
//Check for tablet preview | ||
await page.getByRole( 'menuitemradio', { name: 'Tablet' } ).click(); | ||
await expect( page.isVisible( '.is-tablet-preview' ) ).toBeTruthy(); | ||
|
||
//Check for Mobile preview | ||
await page.getByRole( 'menuitemradio', { name: 'Mobile' } ).click(); | ||
await expect( page.isVisible( '.is-mobile-preview' ) ).toBeTruthy(); | ||
|
||
// Check for Desktop preview | ||
await page.getByRole( 'menuitemradio', { name: 'Desktop' } ).click(); | ||
await expect( page.isVisible( '.is-mobile-preview' ) ).toBeTruthy(); | ||
|
||
// click on the preview in new tab link and wait for new tab to be triggered | ||
const [ newPage ] = await Promise.all( [ | ||
page.waitForEvent( 'popup' ), | ||
page.locator( 'text=Preview in new tab' ).click(), | ||
] ); | ||
|
||
// wait for the new page to load and validate the URL | ||
await newPage.waitForLoadState(); | ||
await expect( newPage ).toHaveURL( /preview=true/ ); | ||
} ); | ||
} ); |