Skip to content

Commit 510b288

Browse files
bfintalkaeizen
andauthored
E2e testing with Playwright (#3389)
* initial commit for e2e * updated readme * activate only stackable for all tests * add tsconfig * add tests for settings page and editor page * add tests for site editor, global settings * minor change to tests for admin and block editor * use custom test utils * run tests * update playwright workflows * add .wp-env.json * add env * fix env slug * log plugins installed * update steps, slug * install playwright browsers * comment out site editor tests, add reporter * add try catch for newly installed plugin * update admin test * update stackable fixture * comment on PR * fix PR comment * add id for upload artifact, update comment body * update yml file * include site editor tests * minor update in yml file * always update comment * upload traces * test script * update comment content * get failed tests * use $GITHUB_OUTPUT * update to multiline * update output name * fix failed tests content * escape special characters * use markdown to output * run mto even on fail * strip Ansi Escapes * try multiple upload * test multiple upload * use test ids and trace file path * update reporter * test matrix * update .wp-env.json and name * update php version, remove unit tests * continue matrix even if one job fails * use different artifact name based on matrix * try all test env * remove comments, update matrix * update php version * update conditions, log wp and php version * add quotes * update php version * run other tests * test custom reporter * update condition * add report to summary * comment site editor tests temporarily * update report url * update wp version * update block editor test * use custom way to get block attributes * fix missing global settings for older wp versions * add comments, update tests * update tests * test with existing post * update command * use tests-cli * run wp-env first * update file path * check post content * update file path * update file path * update reporter * update locator for global settings block defaults --------- Co-authored-by: [email protected] <> Co-authored-by: mxkae <[email protected]>
1 parent c068e61 commit 510b288

27 files changed

+4904
-414
lines changed

.github/workflows/js-unit-test.yml

Lines changed: 0 additions & 45 deletions
This file was deleted.

.github/workflows/php-5.6.39.yml

Lines changed: 0 additions & 79 deletions
This file was deleted.

.github/workflows/php-7.3.5.yml

Lines changed: 0 additions & 80 deletions
This file was deleted.

.github/workflows/php-8.0.0.yml

Lines changed: 0 additions & 75 deletions
This file was deleted.

.github/workflows/playwright.yml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
name: Playwright Tests
2+
on:
3+
push:
4+
branches: [ master, develop ]
5+
pull_request:
6+
branches: [ master, develop ]
7+
jobs:
8+
test:
9+
timeout-minutes: 60
10+
runs-on: ubuntu-latest
11+
strategy:
12+
fail-fast: false # Ensures the matrix doesn't stop if one job fails
13+
matrix:
14+
include:
15+
- php_version: '7.3'
16+
wp_version: 6.4.5
17+
18+
- php_version: '7.3'
19+
wp_version: null
20+
21+
- php_version: '8.2'
22+
wp_version: 6.4.5
23+
24+
- php_version: '8.2'
25+
wp_version: 6.5.5
26+
27+
- php_version: '8.2'
28+
wp_version: 6.6.2
29+
30+
- php_version: '8.2'
31+
wp_version: null
32+
33+
name: PHP ${{ matrix.php_version }} and WP ${{ matrix.wp_version || 'latest' }}
34+
steps:
35+
- uses: actions/checkout@v4
36+
- uses: actions/setup-node@v4
37+
with:
38+
node-version: lts/*
39+
- name: Set the version suffix for the output
40+
run: echo VERSION_SUFFIX=${GITHUB_REF_NAME//\//-} >> $GITHUB_ENV
41+
- name: Set WP Version and create .wp-env.json
42+
run: |
43+
WP_VERSION="${{ matrix.wp_version }}"
44+
core='"Wordpress/Wordpress#'${{ matrix.wp_version }}'"'
45+
46+
if [[ -z "$WP_VERSION" || "$WP_VERSION" == "null" ]]; then
47+
WP_VERSION="latest"
48+
core=null
49+
fi
50+
51+
echo "WP_VERSION=$WP_VERSION" >> $GITHUB_ENV
52+
53+
echo '{
54+
"core": '$core',
55+
"phpVersion": "${{ matrix.php_version }}",
56+
"plugins": [ "." ],
57+
"config": {
58+
"SCRIPT_DEBUG": false
59+
}
60+
}' > .wp-env.json
61+
62+
cat .wp-env.json
63+
- name: Build Stackable Free Plugin
64+
run: |
65+
npm ci --legacy-peer-deps
66+
npm run build:no-translate
67+
- name: Install Playwright Browsers
68+
run: npx playwright install chromium --with-deps
69+
- name: Install wp-env
70+
run: |
71+
npm install -g @wordpress/env
72+
- name: Start wp-env
73+
run: wp-env start
74+
- name: Create post with existing blocks
75+
run: |
76+
POST_ID=$(wp-env run tests-cli wp post create wp-content/plugins/Stackable/e2e/config/post-content.txt --post_title="Existing Blocks" --post_status=publish --porcelain)
77+
echo "WP_TEST_POSTID=$POST_ID" >> $GITHUB_ENV
78+
continue-on-error: true
79+
- name: Run playwright tests
80+
id: run-playwright-tests
81+
env:
82+
WP_BASE_URL: http://localhost:8889
83+
WP_AUTH_STORAGE: wp-auth.json
84+
WP_USERNAME: admin
85+
WP_PASSWORD: password
86+
STACKABLE_SLUG: Stackable/plugin
87+
WP_TEST_POSTID: ${{ env.WP_TEST_POSTID }}
88+
run: npm run test
89+
- uses: actions/upload-artifact@v4
90+
if: ${{ !cancelled() && steps.run-playwright-tests.outcome == 'failure' }}
91+
id: artifact-upload-step
92+
with:
93+
name: playwright-report-php_${{ matrix.php_version }}-wp_${{ env.WP_VERSION }}-${{ env.VERSION_SUFFIX }}
94+
path: playwright-report/
95+
overwrite: true
96+
retention-days: 30
97+
- uses: markpatterson27/markdown-to-output@v1
98+
id: mto
99+
if: ${{ !cancelled() && steps.run-playwright-tests.outcome == 'failure' }}
100+
with:
101+
filepath: ./playwright-stk/errors.md
102+
- name: Add test results to summary
103+
if: ${{ !cancelled() && steps.run-playwright-tests.outcome == 'failure' }}
104+
run: |
105+
echo "${{ steps.mto.outputs.body }}" >> $GITHUB_STEP_SUMMARY
106+
echo "Report: [playwright-report-php_${{ matrix.php_version }}-wp_${{ env.WP_VERSION }}-${{ env.VERSION_SUFFIX }}.zip](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts/${{ steps.artifact-upload-step.outputs.artifact-id }})" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)