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

NEW e2e environment using playground cli #810

Open
wants to merge 108 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
de23420
Install needed packages & setup new e2e scripts
carstingaxion Aug 11, 2024
493c9aa
REMOVE special port settings for wp-env (which may be a problem, I'm …
carstingaxion Aug 11, 2024
c38da61
Add configuration files to run Playwright tests
carstingaxion Aug 11, 2024
673e566
Update Github workflow to use wp-env for e2e tests
carstingaxion Aug 11, 2024
e20f215
Rename folder with tests
carstingaxion Aug 11, 2024
1ed3bd1
NEW (WIP) e2e-tests utilising the wordpress/e2e-test-utils-playwright…
carstingaxion Aug 11, 2024
da4fe13
Fix script name to start wp-env
carstingaxion Aug 11, 2024
6a4ea6f
Add basic dev-documentation about e2e-tests
carstingaxion Aug 11, 2024
9477ecc
Run BUILD before Playwright tests
carstingaxion Aug 12, 2024
94d99f6
DO NOT MERGE // FOR DEBUGGING ONLY // simple Gutenberg paragraph bloc…
carstingaxion Aug 12, 2024
eb8dbdc
Remove custom globalSetup & env vars in favor of Gutenbergs defaults
carstingaxion Aug 12, 2024
a888cc2
TRY: Disable blank mappings for themes & plugins in wp-env
carstingaxion Aug 12, 2024
ee9544c
Add caching to the Playwright browser download step
carstingaxion Aug 12, 2024
d1b3b3a
Creating a short lived node_modules cache to be used by multiple accr…
carstingaxion Aug 12, 2024
308ca4e
DISABLED TEMPORARY // REVERT BEFORE MERGE // to make debugging easier
carstingaxion Aug 12, 2024
9cd89ad
Fix the artifacts upload on CI, to get traces and screenshots from fa…
carstingaxion Aug 12, 2024
ea0739d
Update actions/checkout to v4
carstingaxion Aug 12, 2024
6f2c8f5
Run npm install, only when really needed
carstingaxion Aug 12, 2024
f3c6ad4
Remove steps, that are being done via npm pre-script runs
carstingaxion Aug 12, 2024
b7fad4b
Cleanup
carstingaxion Aug 12, 2024
421c3b0
Move doc into contributor folder
carstingaxion Aug 16, 2024
ed4ff96
Rename scripts to align with screenshot-workflow
carstingaxion Aug 16, 2024
cb6e65b
Remove debug stuff
carstingaxion Aug 16, 2024
c7dae87
Clean up
carstingaxion Aug 16, 2024
345fd9e
Re-Enable 'publish event through admin side' (WIP)
carstingaxion Aug 16, 2024
cab2d14
Resolve merge conflicts
carstingaxion Aug 17, 2024
d8e59a0
Re-Add test:e2e scripts
carstingaxion Aug 17, 2024
158a7ef
Merge branch 'main' into feature/e2e-tests-workflow
carstingaxion Aug 17, 2024
082f6c5
Fix indention
carstingaxion Aug 17, 2024
eb7125d
Lint JS
carstingaxion Aug 17, 2024
cff4a82
Enable Firefox & webkit test-browsers
carstingaxion Aug 17, 2024
2a04279
WIP with wp-now
carstingaxion Aug 17, 2024
ded313f
Update URL to settings
carstingaxion Aug 17, 2024
eef93cb
Hide admin notice during tests
carstingaxion Aug 17, 2024
2cb69d4
Update docs
carstingaxion Aug 17, 2024
b751c87
WIP Migrate tests to e2e-test-utils-playwright
carstingaxion Aug 17, 2024
a0d7e0a
WIP Migrate tests to e2e-test-utils-playwright (2/2)
carstingaxion Aug 18, 2024
53e1f80
Restrict workflow run to relevant triggers
carstingaxion Aug 18, 2024
b82dc1c
Fix: missing required deps
carstingaxion Aug 18, 2024
3aab03d
Remove deprecated "virtualize" param
carstingaxion Aug 18, 2024
45fdc50
Lint & Fix CS issues
carstingaxion Aug 18, 2024
1ae3beb
Import demo-data to test use-cases without having to create a bunch o…
carstingaxion Aug 18, 2024
5fb31e2
WIP Migrate tests to e2e-test-utils-playwright (3/3)
carstingaxion Aug 18, 2024
c1482b0
DRY out code & fix CS
carstingaxion Aug 18, 2024
87984da
WIP Migrate tests to e2e-test-utils-playwright (4/4)
carstingaxion Aug 18, 2024
b7a2bcd
Apply to CS
carstingaxion Aug 18, 2024
b5f0bda
Do not delete posts
carstingaxion Aug 18, 2024
024fe15
Do not delete posts (2/2)
carstingaxion Aug 18, 2024
a99cdb6
Remove dated-post-title as not-needed in virtual envs
carstingaxion Aug 18, 2024
08539d8
Update actions/upload-artifact to v4
carstingaxion Aug 18, 2024
0810258
Enable networking to prevent 404 (and hopefully the import errors as …
carstingaxion Aug 18, 2024
86f3b73
Replace importWxr step with 5 (!) steps (Regarding to https://github.…
carstingaxion Aug 18, 2024
ac8c02a
TRY
carstingaxion Aug 18, 2024
13d8c4d
Add login step
carstingaxion Aug 18, 2024
978afa1
DISABLE TEMP // Reduce browser to increase time-to-next-debug-msg
carstingaxion Aug 18, 2024
503b669
Disable superflous atts
carstingaxion Aug 18, 2024
7f4aac6
Remove superflous code
carstingaxion Aug 18, 2024
1ac130d
TRY number 763
carstingaxion Aug 18, 2024
009bc60
Replace wp-now with wp-playground/cli !!!
carstingaxion Aug 20, 2024
24f174b
Add env vars
carstingaxion Aug 20, 2024
9c7afb0
Try reducing timeouts
carstingaxion Aug 20, 2024
3af1d2e
Fix CS
carstingaxion Aug 21, 2024
1717903
Add debuging example to docs
carstingaxion Aug 21, 2024
67cf8db
Update docs with 'Playground CLI'
carstingaxion Aug 21, 2024
907e977
TRY FIX // webkit // Gutenberg: "Headless webkit won't receive dataTr…
carstingaxion Aug 22, 2024
d1ad138
Define a matrix of php versions to test against
carstingaxion Sep 4, 2024
ab1c527
Start the Playground before Playwright
carstingaxion Sep 4, 2024
148b7f9
Cleanup
carstingaxion Sep 4, 2024
8fa2c46
DRY out npm scripts
carstingaxion Sep 4, 2024
d962362
switch from isVisible to toBeVisible
carstingaxion Sep 4, 2024
baaf0c5
Update docs
carstingaxion Sep 5, 2024
75e481b
Prepare preferredVersions for blueprint (until is resolved: https://g…
carstingaxion Sep 5, 2024
cf4f399
Merge branch 'main' into feature/e2e-tests-workflow-wp-now
carstingaxion Sep 18, 2024
3647106
TRYOUT .click({ force: true }) which is ugly, but works :(
carstingaxion Sep 18, 2024
b85315a
TRY same technique like for the screenshots, use sleep to avoid a rac…
carstingaxion Sep 24, 2024
c07b419
Merge branch 'main' into feature/e2e-tests-workflow-wp-now
carstingaxion Sep 24, 2024
b07b065
Fix invalid workflow file
carstingaxion Sep 24, 2024
687a0d1
DRY out WP_BASE_URL definition into package.json
carstingaxion Sep 24, 2024
efdb4e1
Fix for CS
carstingaxion Sep 24, 2024
e405a0f
TRYOUT .click({ force: true }) which is ugly, but works :(
carstingaxion Sep 24, 2024
265cf4e
Merge branch 'main' into feature/e2e-tests-workflow-wp-now
carstingaxion Sep 24, 2024
b8fd761
Fix for CS
carstingaxion Sep 24, 2024
2b4cc31
Add inline-docs & Cleanup
carstingaxion Sep 24, 2024
939eb1a
COPY test-reporting (1/2) from Gutenberg
carstingaxion Sep 24, 2024
9dfd54c
Fix for CS
carstingaxion Sep 24, 2024
5f986d9
Simplify test by relying on Playwrights actionability checks (auto-wa…
carstingaxion Sep 25, 2024
50f84b6
Simplify test because the getByRole locator supports expanded selector
carstingaxion Sep 25, 2024
569c7c8
Replace isVisible() with expect( ... ).toBeVisible(), as per the sugg…
carstingaxion Sep 27, 2024
08d3b13
The "$" method is discouraged, Locator should be used
carstingaxion Sep 27, 2024
9719773
The URL attribute should be asserted via the toHaveAttribute locator …
carstingaxion Sep 27, 2024
442e6cb
Disable "Merge Artifacts" step
carstingaxion Oct 6, 2024
917f485
Update workflow echo
carstingaxion Oct 6, 2024
439a794
Fix test: A logged in user can perform RSVP action (which failed in TT5)
carstingaxion Oct 6, 2024
6bb65de
Clean up
carstingaxion Oct 7, 2024
7574542
Clean up
carstingaxion Oct 7, 2024
d7e8c3f
Fix test: By re-enabling force click
carstingaxion Oct 7, 2024
b087736
WIP event tests
carstingaxion Oct 7, 2024
a1f8574
Run for different WP versions
carstingaxion Oct 7, 2024
d46fc40
Fix for CS
carstingaxion Oct 7, 2024
fd0cd22
Remove comma
carstingaxion Oct 7, 2024
3e4c8de
Reduce WP-version matrix to "minimum required"
carstingaxion Oct 7, 2024
d23bfea
Login step can be removed (because its part of importWxr)
carstingaxion Oct 7, 2024
079cfd2
TRY test for non-logged-in users (FAILED)
carstingaxion Oct 7, 2024
c414abe
Clean up
carstingaxion Oct 7, 2024
602d590
Splitting the problematic test into smaller pieces
carstingaxion Oct 7, 2024
66aa030
wp-scripts package-update
carstingaxion Oct 7, 2024
f8d255c
BUILD
carstingaxion Oct 7, 2024
5a4b97f
Merge branch 'main' into feature/e2e-tests-workflow-wp-now
carstingaxion Oct 7, 2024
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
205 changes: 171 additions & 34 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,180 @@
name: E2E Tests

on:
workflow_dispatch:
push:
branches:
- main
pull_request:
paths:
- '.github/workflows/e2e-tests.yml'
- 'build/**'
- 'includes/**'
- 'src/**'
- 'test/e2e/**'
- '*.php'
- 'package.*'

# 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:
playwright:
name: Playwright Tests
e2e-tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 1 # Prevent parallel runs to make use of the caching for node_modules and playwright browsers
matrix:
php: [
'7.4',
'8.3'
]
wp: [
'6.6',
'latest'
]

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Log debug information
run: |
npm --version
node --version
git --version
php --version
composer --version

- name: Install NodeJS
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
# Enable built-in functionality for caching and restoring dependencies, which is disabled by default.
# The actions/setup-node uses actions/cache under the hood.
# https://github.com/actions/setup-node#caching-global-packages-data
cache: 'npm'

- name: NPM install
run: npm ci --legacy-peer-deps

- name: Playwright install
run: npx playwright install --with-deps

- name: Run Playwright
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WP_ADMIN_PASSWORD: ${{ secrets.WP_ADMIN_PASSWORD }}
run: npm run test:e2e
if: ${{ success() || failure() }}
- name: Checkout
uses: actions/checkout@v4

- uses: actions/cache@v4
id: playwright-cache
with:
path: |
~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ hashFiles('**/package-lock.json') }}

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
# Enable built-in functionality for caching and restoring dependencies, which is disabled by default.
# The actions/setup-node uses actions/cache under the hood.
# https://github.com/actions/setup-node#caching-global-packages-data
cache: 'npm'

# Restoring the short lived node_modules cache
# to be used across all workflows running on the last commit.
# https://github.com/actions/cache/blob/main/caching-strategies.md#creating-a-short-lived-cache
- uses: actions/cache/restore@v4
id: node_modules-cache
with:
path: |
./node_modules
key: ${{ runner.os }}-node_modules-${{ github.sha }}-${{ hashFiles('package-lock.json') }}

- name: NPM install
if: steps.node_modules-cache.outputs.cache-hit != 'true'
run: npm ci --legacy-peer-deps

# Creating a short lived node_modules cache
- uses: actions/cache/save@v4
if: steps.node_modules-cache.outputs.cache-hit != 'true'
with:
path: |
./node_modules
key: ${{ steps.node_modules-cache.outputs.cache-primary-key }}

- name: Install Playwright dependencies
run: npx playwright install --with-deps
if: steps.playwright-cache.outputs.cache-hit != 'true'
- run: npx playwright install-deps
if: steps.playwright-cache.outputs.cache-hit == 'true'

- name: Prepare preferredVersions for blueprint
# playground/cli ignores --php & --wp flags when --blueprint is set
#
# I created an issue at:
# https://github.com/WordPress/playground-tools/issues/352
run: |
preferredVersions='{
"php": "${{ matrix.php }}",
"wp": "${{ matrix.wp }}"
}'
echo "Use jq to prepend the preferred versions to the existing blueprint JSON file."
jq --argjson preferredVersions "$preferredVersions" '{preferredVersions: $preferredVersions} + .' ./test/e2e/blueprint.json > temp.blueprint.json

- name: Starting Playground, staring Playwright & running the tests
# This is kind of a hack PART 1/2,
# to make sure Playwright DOES NOT start the webserver on its own.
#
# Part 2/2 is the "command: undefined," declaration
# in test/e2e/playwright.config.ts
#
# While auto-loading the webserver when needed sounded nice, it introduced a race-condition
# between the setup of Playground and Playwrights own start event.
# Playwright listens for the availability of the webserver relatively simple,
# as soon as there is a status code 200, Playwright starts all engines.
#
# Unfortunately Playground is not ready at this point, it hast started WordPress
# and is going to start stepping through the blueprint, but hasn't loaded GatherPress nor imported any data;
# Resulting in failing tests.
#
# It was not possible (for me) to keep the setup of Playground in a separate step,
# why this "run > sleep > run" became necessary.
# The setup process usually takes about 20sec, so 60 is just a good extra, to not run into errors.
#
# The sleep step, should help making sure Playwright runs only, when this is DONE & READY.
#
# Because it seems to be a problem to "wait on webServer.command" https://github.com/microsoft/playwright/issues/11811
# & "it seems that globalSetup runs before webServer is started." https://github.com/microsoft/playwright/issues/11811#issuecomment-1040732201

run: |
npm run playground:mount -- --blueprint=./temp.blueprint.json & \
sleep 60 && \
echo 'Playground is ready now, lets run some end-to-end tests.' && \
# DEBUG=pw:api,pw:webserver \
xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- \
npm run test:e2e


- name: Archive debug artifacts (screenshots, traces)
uses: actions/upload-artifact@v4
if: ${{ ! cancelled() }}
with:
name: failures-artifacts--php-${{ matrix.php }}-wp-${{ matrix.wp }}
path: artifacts/test-results/
if-no-files-found: ignore


- name: Archive flaky tests report
uses: actions/upload-artifact@v4
if: ${{ ! cancelled() }}
with:
name: flaky-tests-report--php-${{ matrix.php }}-wp-${{ matrix.wp }}
path: flaky-tests
if-no-files-found: ignore


# merge-artifacts:
# name: Merge Artifacts
# if: ${{ ! cancelled() }}
# needs: [e2e-tests]
# runs-on: ubuntu-latest
# outputs:
# has-flaky-test-report: ${{ !!steps.merge-flaky-tests-reports.outputs.artifact-id }}
# steps:
# - name: Merge failures artifacts
# uses: actions/upload-artifact/merge@v4
# # Don't fail the job if there aren't any artifacts to merge.
# continue-on-error: true
# with:
# name: failures-artifacts
# # Retain the merged artifacts in case of a rerun.
# pattern: failures-artifacts*
# delete-merged: true

# - name: Merge flaky tests reports
# id: merge-flaky-tests-reports
# uses: actions/upload-artifact/merge@v4
# continue-on-error: true
# with:
# name: flaky-tests-report
# pattern: flaky-tests-report*
# delete-merged: true
2 changes: 1 addition & 1 deletion build/272.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/481.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/535.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/980.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/blocks/add-to-calendar/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-i18n'), 'version' => '754b4dfa4e592032751e');
<?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-i18n'), 'version' => 'd363e7f0b415ef3e95a3');
2 changes: 1 addition & 1 deletion build/blocks/add-to-calendar/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/blocks/event-date/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('moment', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-date', 'wp-element', 'wp-i18n'), 'version' => '2a87e9e9bf69563aeae1');
<?php return array('dependencies' => array('moment', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-date', 'wp-element', 'wp-i18n'), 'version' => 'fbdfb147c6c684a7d803');
Loading
Loading