diff --git a/package.json b/package.json index 96aca6616d425e..3bb7af3551ea1e 100644 --- a/package.json +++ b/package.json @@ -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_*", diff --git a/test/visreg/example.spec.js b/test/visreg/example.spec.js new file mode 100644 index 00000000000000..dcb8a987af9536 --- /dev/null +++ b/test/visreg/example.spec.js @@ -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 } ); +} ); diff --git a/test/visreg/example.spec.js-snapshots/test-1-darwin.png b/test/visreg/example.spec.js-snapshots/test-1-darwin.png new file mode 100644 index 00000000000000..26a2d203e0450e Binary files /dev/null and b/test/visreg/example.spec.js-snapshots/test-1-darwin.png differ