Skip to content

Commit

Permalink
Create example visreg test using Playground
Browse files Browse the repository at this point in the history
  • Loading branch information
WunderBart committed Jun 21, 2024
1 parent bb73da7 commit 449a2d5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@
"test:e2e:playwright:debug": "npm run test:e2e:debug",
"test:e2e:storybook": "playwright test --config test/storybook-playwright/playwright.config.ts",
"test:e2e:watch": "npm run test:e2e -- --watch",
"test:visreg": "npx playwright test test/visreg/example.spec.js",
"test:native": "cross-env NODE_ENV=test jest --config test/native/jest.config.js",
"test:native:watch": "npm run test:native -- --watch",
"test:native:clean": "jest --clearCache --config test/native/jest.config.js; rm -rf $TMPDIR/jest_*",
Expand Down
27 changes: 27 additions & 0 deletions test/visreg/example.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* External dependencies
*/
import { test, expect } from '@playwright/test';

test( 'test', async ( { context, page } ) => {
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' );

await page.waitForFunction( 'window?.playground?.absoluteUrl' );

const wpIframeURL = await page.evaluate(
async () => await window.playground.absoluteUrl
);

const wpPage = await context.newPage();

await wpPage.goto( wpIframeURL + '/wp-admin/post-new.php' );
await wpPage.getByLabel( 'Close', { exact: true } ).click();

await wpPage.waitForTimeout( 5_000 );
await expect( wpPage ).toHaveScreenshot( { fullPage: true } );
} );
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 449a2d5

Please sign in to comment.