-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create example visreg test using Playground
- Loading branch information
1 parent
bb73da7
commit 3c2989a
Showing
3 changed files
with
38 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
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,37 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
test( 'WP Editor default view', async ( { context, page } ) => { | ||
// 1. Go to the Gutenberg PR Preview page and submit the PR number. | ||
await page.goto( 'https://playground.wordpress.net/gutenberg.html' ); | ||
|
||
const prInput = page.getByLabel( 'Pull request number or URL:' ); | ||
|
||
await prInput.fill( process.env.PR_NUMBER ); | ||
await prInput.press( 'Enter' ); | ||
|
||
// 2. Get the URL of the iframed WordPress instance so we can strip the | ||
// Playground UI off. | ||
await page.waitForFunction( 'window?.playground?.absoluteUrl' ); | ||
const wpIframeURL = await page.evaluate( | ||
async () => await window.playground.absoluteUrl | ||
); | ||
|
||
// 3. Open WordPress in a new page in the same context. We need to keep the | ||
// original page open so the Playground instance is not destroyed. | ||
const wpPage = await context.newPage(); | ||
|
||
await wpPage.goto( wpIframeURL + '/wp-admin/post-new.php' ); | ||
await wpPage.getByLabel( 'Close', { exact: true } ).click(); | ||
|
||
// 4. Add an extra wait for the UI to stabilize. | ||
await wpPage.waitForTimeout( 5_000 ); | ||
|
||
// 5. Here, some UI manipulation can be done. For example: | ||
await wpPage.keyboard.type( 'Hello, World!' ); | ||
|
||
// 6. Compare the screenshot of the full page. | ||
await expect( wpPage ).toHaveScreenshot( { fullPage: true } ); | ||
} ); |
Binary file added
BIN
+48.1 KB
test/visreg/example.spec.js-snapshots/WP-Editor-default-view-1-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.