Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate/e2e to playwright round one #38949

Closed
wants to merge 41 commits into from
Closed
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
8510f24
WIP
kevin940726 Jan 25, 2022
67aeaa8
Try to fix transitionend
kevin940726 Feb 7, 2022
91689ab
Deactivate the disable-css-animations test plugin
kevin940726 Feb 10, 2022
424a9a8
Upgrade role-selector to use DTL under the hood
kevin940726 Feb 10, 2022
93435f4
Add playwright install to pre script
kevin940726 Feb 10, 2022
2a31bb8
Try to fix flaky test
kevin940726 Feb 10, 2022
06d05db
Use toBeHidden()
kevin940726 Feb 11, 2022
1b184c6
Address code reviews
kevin940726 Feb 11, 2022
0f5ab10
Remove waitForPreviewFrame
kevin940726 Feb 11, 2022
b15edd7
Add --with-deps to GHA and remove pre install script
kevin940726 Feb 11, 2022
83a0708
Add globalPage and globalTestUtils for beforeAll and afterAll
kevin940726 Feb 16, 2022
68f9cea
Fix linting issues
kevin940726 Feb 16, 2022
1abaa8d
Separate utils into PageUtils and RequestUtils
kevin940726 Feb 21, 2022
6c9db41
Ignore errors if storage state is not found
kevin940726 Feb 21, 2022
311d9a0
Annyoing are-we-there-yet
kevin940726 Feb 21, 2022
7607c48
Only install chromium on CI
kevin940726 Feb 21, 2022
03daa37
Merge branch 'try/playwright-test' into migrate/e2e-to-playwright-rou…
JustinyAhin Feb 21, 2022
d9e58b4
Create a11y.spec.js Playwright
JustinyAhin Feb 21, 2022
3a8a6f5
Update a11y.spec.js
JustinyAhin Feb 21, 2022
a49932d
Create canvas.js Playwright
JustinyAhin Feb 21, 2022
30a0e11
Create get-edited-post-content.js Playwright
JustinyAhin Feb 21, 2022
096c75d
Create wp-data-select.js Playwright
JustinyAhin Feb 21, 2022
ed8f56a
Update index.ts
JustinyAhin Feb 21, 2022
cd523e5
Create style-variation.spec.js Playwright
JustinyAhin Feb 21, 2022
d622be1
Create inserter.js Playwright
JustinyAhin Feb 21, 2022
ebe9086
Update inserter.js
JustinyAhin Feb 21, 2022
ad58c4d
Update utilities exports
JustinyAhin Feb 22, 2022
e4b4677
Update style-variation.spec.js
JustinyAhin Feb 22, 2022
0ac0d4c
Add click-on-more-menu-items.js Playwright
JustinyAhin Feb 23, 2022
6a2bb40
Add toggle-more-menu.js Playwright
JustinyAhin Feb 23, 2022
61822de
Create click-on-close-modal-button.js Playwright
JustinyAhin Feb 23, 2022
3ce9878
Update index.ts
JustinyAhin Feb 23, 2022
c3c9003
Create shortcut-help.spec.js
JustinyAhin Feb 23, 2022
da1ee84
Update shortcut-help.spec.js
JustinyAhin Feb 23, 2022
1e0c264
Update package-lock.json
JustinyAhin Feb 25, 2022
4bfb8e9
Move inserter functions to a new folder
JustinyAhin Feb 25, 2022
4458cc5
Update style-variation.spec.js
JustinyAhin Feb 25, 2022
30543cd
Update package-lock.json
JustinyAhin Mar 1, 2022
d8c2665
Create block-api.spec.js
JustinyAhin Mar 1, 2022
f2a7777
Create allowed-blocks.spec.js
JustinyAhin Mar 1, 2022
0bfea0f
Merge branch 'trunk' into migrate/e2e-to-playwright-round-one
JustinyAhin Mar 14, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,39 @@ module.exports = {
extends: [ 'plugin:@wordpress/eslint-plugin/test-unit' ],
},
{
files: [ 'packages/e2e-test*/**/*.js' ],
files: [
'packages/e2e-tests/**/*.js',
'packages/e2e-test-utils/**/*.js',
],
extends: [ 'plugin:@wordpress/eslint-plugin/test-e2e' ],
rules: {
'jest/expect-expect': 'off',
},
},
{
files: [
'packages/e2e-tests-playwright/**/*.[tj]s',
'packages/e2e-test-utils-playwright/**/*.[tj]s',
],
extends: [ 'plugin:@wordpress/eslint-plugin/test-e2e-playwright' ],
rules: {
'@wordpress/no-global-active-element': 'off',
'@wordpress/no-global-get-selection': 'off',
'no-restricted-syntax': [
'error',
{
selector: 'CallExpression[callee.name="$"]',
message:
'`$` is discouraged, please use `locator` instead',
},
{
selector: 'CallExpression[callee.name="$$"]',
message:
'`$$` is discouraged, please use `locator` instead',
},
],
},
},
{
files: [ 'bin/**/*.js', 'packages/env/**' ],
rules: {
Expand Down
60 changes: 46 additions & 14 deletions .github/report-flaky-tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const metaData = {

for ( const flakyTest of flakyTests ) {
const {
runner: testRunner = 'jest-circus',
title: testTitle,
path: testPath,
results: testResults,
Expand Down Expand Up @@ -92,7 +93,11 @@ const metaData = {
body.indexOf( TEST_RESULTS_LIST.close )
) +
[
renderTestErrorMessage( { testPath, testResults } ),
renderTestErrorMessage( {
testRunner,
testPath,
testResults,
} ),
TEST_RESULTS_LIST.close,
].join( '\n' );

Expand Down Expand Up @@ -121,6 +126,7 @@ const metaData = {
title: issueTitle,
body: renderIssueBody( {
meta,
testRunner,
testTitle,
testPath,
testResults,
Expand Down Expand Up @@ -187,10 +193,16 @@ function getIssueTitle( testTitle ) {
return `[Flaky Test] ${ testTitle }`;
}

function renderIssueBody( { meta, testTitle, testPath, testResults } ) {
function renderIssueBody( {
meta,
testRunner,
testTitle,
testPath,
testResults,
} ) {
return (
renderIssueDescription( { meta, testTitle, testPath } ) +
renderTestResults( { testPath, testResults } )
renderTestResults( { testRunner, testPath, testResults } )
);
}

Expand All @@ -211,14 +223,41 @@ ${ testTitle }
`;
}

function renderTestResults( { testPath, testResults } ) {
function renderTestResults( { testRunner, testPath, testResults } ) {
return `${ TEST_RESULTS_LIST.open }
${ renderTestErrorMessage( { testPath, testResults } ) }
${ renderTestErrorMessage( { testRunner, testPath, testResults } ) }
${ TEST_RESULTS_LIST.close }
`;
}

function renderTestErrorMessage( { testPath, testResults } ) {
function renderTestResults( { testRunner, testResults, testPath } ) {
switch ( testRunner ) {
case '@playwright/test': {
// Could do a slightly better formatting than this.
return stripAnsi(
testResults.map( ( result ) => result.error.stack ).join( '\n' )
);
}
case 'jest-circus':
default: {
return stripAnsi(
formatResultsErrors(
testResults,
{
rootDir: path.join(
process.cwd(),
'packages/e2e-tests'
),
},
{},
testPath
)
);
}
}
}

function renderTestErrorMessage( { testRunner, testPath, testResults } ) {
const date = new Date().toISOString();
// It will look something like this without formatting:
// ▶ [2021-08-31T16:15:19.875Z] Test passed after 2 failed attempts on trunk
Expand All @@ -231,14 +270,7 @@ function renderTestErrorMessage( { testPath, testResults } ) {
</summary>

\`\`\`
${ stripAnsi(
formatResultsErrors(
testResults,
{ rootDir: path.join( process.cwd(), 'packages/e2e-tests' ) },
{},
testPath
)
) }
${ renderTestResults( { testRunner, testPath, testResults } ) }
\`\`\`
</details>${ TEST_RESULT.close }`;
}
Expand Down
68 changes: 68 additions & 0 deletions .github/workflows/end2end-test-playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: End-to-End Tests Playwright

on:
pull_request:
push:
branches:
- trunk
- 'release/**'
- 'wp/**'

# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
# The concurrency group contains the workflow name and the branch name for pull requests
# or the commit hash for any other events.
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true

jobs:
e2e:
name: E2E Tests
runs-on: ubuntu-latest
if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request' }}
strategy:
fail-fast: false
matrix:
node: ['14']

steps:
- uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4

- name: Use desired version of NodeJS
uses: actions/setup-node@38d90ce44d5275ad62cc48384b3d8a58c500bb5f # v2.2.2
with:
node-version: ${{ matrix.node }}
cache: npm

- name: Npm install and build
run: |
npm ci
npm run build

- name: Install Playwright dependencies
run: |
npx playwright install chromium --with-deps

- name: Install WordPress and start the server
run: |
npm run wp-env start

- name: Run the tests
run: |
npm run test-e2e:playwright

- name: Archive debug artifacts (screenshots, traces)
uses: actions/upload-artifact@e448a9b857ee2131e752b06002bf0e093c65e571 # v2.2.2
if: always()
with:
name: failures-artifacts
path: artifacts
if-no-files-found: ignore

- name: Archive flaky tests report
uses: actions/upload-artifact@e448a9b857ee2131e752b06002bf0e093c65e571 # v2.2.2
if: always()
with:
name: flaky-tests-report
path: flaky-tests
if-no-files-found: ignore
2 changes: 2 additions & 0 deletions .github/workflows/flaky-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Report Flaky Tests

on:
workflow_run:
# We should also add 'End-to-End Tests Playwright' here but that
# wil run this workflow whenever either one of them completes.
workflows: ['End-to-End Tests']
types:
- completed
Expand Down
12 changes: 12 additions & 0 deletions docs/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -1493,12 +1493,24 @@
"markdown_source": "../packages/dom/README.md",
"parent": "packages"
},
{
"title": "@wordpress/e2e-test-utils-playwright",
"slug": "packages-e2e-test-utils-playwright",
"markdown_source": "../packages/e2e-test-utils-playwright/README.md",
"parent": "packages"
},
{
"title": "@wordpress/e2e-test-utils",
"slug": "packages-e2e-test-utils",
"markdown_source": "../packages/e2e-test-utils/README.md",
"parent": "packages"
},
{
"title": "@wordpress/e2e-tests-playwright",
"slug": "packages-e2e-tests-playwright",
"markdown_source": "../packages/e2e-tests-playwright/README.md",
"parent": "packages"
},
{
"title": "@wordpress/e2e-tests",
"slug": "packages-e2e-tests",
Expand Down
Loading