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

WIP - Migrate mentions test Playwright #39264

Closed
wants to merge 46 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 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
ca8d02c
Try to fix flaky preview frame test
Feb 25, 2022
eeb3d11
Merge branch 'try/playwright-test' into migrate/e2e-playwright-tests
juhi123 Mar 1, 2022
2313f80
WIP
kevin940726 Jan 25, 2022
225058f
Try to fix transitionend
kevin940726 Feb 7, 2022
d31f0a4
Deactivate the disable-css-animations test plugin
kevin940726 Feb 10, 2022
2bbf8c8
Upgrade role-selector to use DTL under the hood
kevin940726 Feb 10, 2022
f977fec
Add playwright install to pre script
kevin940726 Feb 10, 2022
6e7c7d9
Try to fix flaky test
kevin940726 Feb 10, 2022
7ee4aa1
Use toBeHidden()
kevin940726 Feb 11, 2022
c3a3a32
Address code reviews
kevin940726 Feb 11, 2022
668e6e9
Remove waitForPreviewFrame
kevin940726 Feb 11, 2022
c95ec67
Add --with-deps to GHA and remove pre install script
kevin940726 Feb 11, 2022
7e8aeb4
Add globalPage and globalTestUtils for beforeAll and afterAll
kevin940726 Feb 16, 2022
2a66ce9
Fix linting issues
kevin940726 Feb 16, 2022
7a46883
Separate utils into PageUtils and RequestUtils
kevin940726 Feb 21, 2022
6092441
Ignore errors if storage state is not found
kevin940726 Feb 21, 2022
5f9ca6b
Annyoing are-we-there-yet
kevin940726 Feb 21, 2022
e784864
Only install chromium on CI
kevin940726 Feb 21, 2022
511b8d8
Try to fix flaky preview frame test
Feb 25, 2022
7ded25c
Move test and expect to e2e-tests-utils
kevin940726 Mar 1, 2022
da19cb1
Fix welcome guide store migration
kevin940726 Mar 2, 2022
80d40ab
Fix static and unit tests
kevin940726 Mar 2, 2022
7f533fb
Add storageState to playwright.config
kevin940726 Mar 2, 2022
4ad53eb
Try to fix annoying package-lock.json
kevin940726 Mar 2, 2022
5a76609
Change back to src/
kevin940726 Mar 3, 2022
fb341de
Change internal selectors to use role selectors
kevin940726 Mar 3, 2022
2569ae5
Add mention-spec.js
juhi123 Mar 7, 2022
a38153a
Add mention-spec.js
juhi123 Mar 7, 2022
ed6d373
Update files with new changes
juhi123 Mar 7, 2022
4fb9c76
WIP : Addd Mention-spec.js e2e test case
juhi123 Mar 7, 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
1 change: 1 addition & 0 deletions bin/packages/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ if ( files.length ) {
`**/benchmark/**`,
`**/{__mocks__,__tests__,test}/**`,
`**/{storybook,stories}/**`,
`**/e2e-test-utils-playwright/**`,
],
onlyFiles: true,
}
Expand Down
2 changes: 1 addition & 1 deletion bin/packages/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function isSourceFile( filename ) {
return (
/\/src\/.+\.(js|json|scss|ts|tsx)$/.test( relativePath ) &&
! [
/\/(benchmark|__mocks__|__tests__|test|storybook|stories)\/.+/,
/\/(benchmark|__mocks__|__tests__|test|storybook|stories|e2e-test-utils-playwright)\/.+/,
/.\.(spec|test)\.js$/,
].some( ( regex ) => regex.test( relativePath ) )
);
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