Skip to content

Commit 9d62749

Browse files
committed
minor #3014 Create E2E app for browsers tests (Kocal)
This PR was merged into the 2.x branch. Discussion ---------- Create E2E app for browsers tests | Q | A | ------------- | --- | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Docs? | no <!-- required for new features --> | Issues | Fix #3009 <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT <!-- Replace this notice by a description of your feature/bugfix. This will help reviewers and should be a good start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - For new features, provide some code snippets to help understand usage. - Features and deprecations must be submitted against branch main. - Update/add documentation as required (we can help!) - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry - Never break backward compatibility (see https://symfony.com/bc). --> This pull request updates the browser testing workflow and related configuration to improve reliability, consistency, and maintainability across UX packages. The main changes include refactoring the browser test workflow to use a matrix strategy for Symfony versions, standardizing dependency installation steps, removing unused dependencies, and renaming the Playwright configuration for easier reuse. **Workflow and CI improvements:** * Refactored `.github/workflows/browser-tests.yml` to use a matrix strategy for Symfony versions, added concurrency controls to cancel in-progress runs, and split setup steps for JS and PHP dependencies, Docker containers, and E2E app configuration. Artifact uploads now only occur on browser test failures. [[1]](diffhunk://#diff-255cac5fcd7ae015d5bc1ccf14bfa2fff33bcabb653402be014e6668db1036ceR23-R38) [[2]](diffhunk://#diff-255cac5fcd7ae015d5bc1ccf14bfa2fff33bcabb653402be014e6668db1036ceL36-R116) * Standardized JS dependency installation across workflows by replacing direct `pnpm install` commands with named steps (`Install root JS dependencies`) in code quality, unit test, dist files, and release workflows. [[1]](diffhunk://#diff-4a2765c2cfcbd3804a66aab805cb92ddda74de1730923cc5bf53671d0beccf06R27-R36) [[2]](diffhunk://#diff-b117ce55777f198ed74d5eb1cd6319c0b63837e2e9eed5c44b2477658e12248fR24) [[3]](diffhunk://#diff-b117ce55777f198ed74d5eb1cd6319c0b63837e2e9eed5c44b2477658e12248fL32-R38) [[4]](diffhunk://#diff-8e3deeaeb0bdfc6967ff8173f1d99e5001fe75dc497cbfb85fe64ceaade5e399L33-R34) [[5]](diffhunk://#diff-6e608e02c595d53ab6b70822a2bf19abcfc6ddcc976c2f536ad5bfca20f0443fR148) [[6]](diffhunk://#diff-6e608e02c595d53ab6b70822a2bf19abcfc6ddcc976c2f536ad5bfca20f0443fL157-R161) **Testing and configuration changes:** * Updated `package.json` to run browser tests in all workspaces concurrently, removed the unused `webdriverio` dependency, and improved the `test:browser` script for workspace aggregation. [[1]](diffhunk://#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519L13-R13) [[2]](diffhunk://#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519L28-R28) * Renamed `playwright.config.ts` to `playwright.config.base.ts`, added documentation for usage in UX packages, and improved test matching patterns and output directory configuration. [[1]](diffhunk://#diff-8f3b25b652873317fa4aa36b920f753b44dc82f5c1f0d2ff5e6b1781ef1dc90fL1-R30) [[2]](diffhunk://#diff-8f3b25b652873317fa4aa36b920f753b44dc82f5c1f0d2ff5e6b1781ef1dc90fL30-L36) **Dependency management:** * Removed `webdriverio` from the lockfile and marked many transitive dependencies as optional in `pnpm-lock.yaml`, reducing the install footprint and improving clarity for unused packages. [[1]](diffhunk://#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL54-L56) [[2]](diffhunk://#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbR3991) [[3]](diffhunk://#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbR4242) [[4]](diffhunk://#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL4260-R4260) [[5]](diffhunk://#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL4270-R4276) [[6]](diffhunk://#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbR4429) [[7]](diffhunk://#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbR4438-R4451) [[8]](diffhunk://#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbR4472-R4480) [[9]](diffhunk://#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbR4530) [[10]](diffhunk://#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbR4541) [[11]](diffhunk://#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL4543-R4556) [[12]](diffhunk://#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL4578-R4597) [[13]](diffhunk://#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL4597-R4613) [[14]](diffhunk://#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbR4622) [[15]](diffhunk://#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbR4670) [[16]](diffhunk://#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbR4685) [[17]](diffhunk://#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL4704-R4724) [[18]](diffhunk://#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbR4733) [[19]](diffhunk://#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL4725-R4756) [[20]](diffhunk://#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbR4779-R4793) [[21]](diffhunk://#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL4778-R4807) [[22]](diffhunk://#diff-32824c984905bb02bc7ffcef96a77addd1f1602cff71a11fbbfdd7f53ee026bbL4791-R4828) These changes make the browser testing workflow more robust and maintainable, ensure consistent dependency installation, and clean up unused or optional packages to streamline CI runs. Commits ------- dd1c13a Create E2E app & run it in CI
2 parents c1450ed + dd1c13a commit 9d62749

File tree

160 files changed

+11607
-327
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

160 files changed

+11607
-327
lines changed

.github/workflows/browser-tests.yml

Lines changed: 78 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,22 @@ on:
2020
- '.github/workflows/app-tests.yaml'
2121
- '.github/workflows/unit-tests.yaml'
2222

23+
concurrency:
24+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
25+
cancel-in-progress: true
26+
2327
jobs:
24-
js:
28+
test:
2529
runs-on: ubuntu-latest
30+
strategy:
31+
fail-fast: false
32+
matrix:
33+
symfony: ['6.4', '7.3']
34+
env:
35+
SYMFONY_REQUIRE: '${{ matrix.symfony }}.*'
2636
steps:
2737
- uses: actions/checkout@v4
38+
2839
- run: npm i -g corepack && corepack enable
2940
- uses: actions/setup-node@v4
3041
with:
@@ -33,21 +44,76 @@ jobs:
3344
cache-dependency-path: |
3445
pnpm-lock.yaml
3546
package.json
36-
src/**/package.json
37-
- run: pnpm install --frozen-lockfile
3847
39-
- name: Install custom browsers
40-
run: node ./bin/get_browsers.mjs
48+
- name: Install root JS dependencies
49+
run: pnpm install --frozen-lockfile
50+
51+
- name: Install custom browsers
52+
run: node ./bin/get_browsers.mjs
53+
54+
- name: Install browsers with Playwright
55+
run: pnpm exec playwright install firefox ffmpeg
56+
57+
- uses: shivammathur/setup-php@v2
58+
with:
59+
php-version: 8.2
60+
tools: symfony-cli, flex
61+
62+
- name: Install root PHP dependencies
63+
uses: ramsey/composer-install@v3
64+
with:
65+
working-directory: ${{ github.workspace }}
66+
67+
- name: Build root packages
68+
run: php .github/build-packages.php
4169

42-
- name: Install browsers with Playwright
43-
run: pnpm exec playwright install firefox ffmpeg
70+
- name: Start Docker containers
71+
run: docker compose up -d --build
72+
working-directory: test_apps/e2e-app
4473

45-
# TODO: Install the E2E app + run webserver
46-
- run: pnpm run test:browser
74+
- name: Configure E2E app
75+
run: |
76+
echo 'APP_ENV=prod' >> .env.local
77+
echo 'APP_DEBUG=0' >> .env.local
78+
echo 'APP_SECRET=df4c071596e64cc75a349456f2887ae2419ae650' >> .env.local
79+
working-directory: test_apps/e2e-app
80+
81+
- name: Install E2E PHP dependencies
82+
uses: ramsey/composer-install@v3
83+
with:
84+
working-directory: test_apps/e2e-app
85+
dependency-versions: highest
86+
composer-options: --no-dev
87+
custom-cache-suffix: symfony-${{ matrix.symfony }}
88+
89+
- name: Prepare E2E app
90+
run: |
91+
symfony composer dump-autoload --classmap-authoritative --no-dev
92+
symfony composer dump-env
93+
symfony console asset-map:compile
94+
symfony console ux:icons:warm-cache
95+
working-directory: test_apps/e2e-app
96+
97+
- name: Start E2E app
98+
run: symfony serve --daemon
99+
working-directory: test_apps/e2e-app
100+
101+
- name: Run browser tests
102+
run: pnpm run test:browser
103+
id: browser-tests
104+
105+
- uses: actions/upload-artifact@v4
106+
if: ${{ always() && steps.browser-tests.conclusion == 'failure' }}
107+
with:
108+
name: Playwright report and output (${{ matrix.symfony }})
109+
path: |
110+
src/**/assets/.playwright-report/
111+
src/**/assets/.playwright-output/
112+
retention-days: 7
47113

48114
- uses: actions/upload-artifact@v4
49-
if: ${{ !cancelled() }}
115+
if: ${{ always() && steps.browser-tests.conclusion == 'failure' }}
50116
with:
51-
name: playwright-report
52-
path: .playwright-report/
117+
name: Symfony logs (${{ matrix.symfony }})
118+
path: test_apps/e2e-app/var/log/
53119
retention-days: 7

.github/workflows/code-quality.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,16 @@ jobs:
2424
runs-on: ubuntu-latest
2525
steps:
2626
- uses: actions/checkout@v4
27+
2728
- run: npm i -g corepack && corepack enable
2829
- uses: actions/setup-node@v4
2930
with:
3031
node-version-file: '.nvmrc'
3132
cache: 'pnpm'
32-
- run: pnpm install --frozen-lockfile
33+
34+
- name: Install root JS dependencies
35+
run: pnpm install --frozen-lockfile
36+
3337
- run: pnpm run ci
3438

3539
phpstan:

.github/workflows/dist-files-unbuilt.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
runs-on: ubuntu-latest
2222
steps:
2323
- uses: actions/checkout@v4
24+
2425
- run: npm i -g corepack && corepack enable
2526
- uses: actions/setup-node@v4
2627
with:
@@ -29,7 +30,12 @@ jobs:
2930
cache-dependency-path: |
3031
pnpm-lock.yaml
3132
**/package.json
32-
- run: pnpm install --frozen-lockfile && pnpm run build
33+
34+
- name: Install root JS dependencies
35+
run: pnpm install --frozen-lockfile
36+
37+
- name: Build
38+
run: pnpm run build
3339

3440
- name: Check if JS dist files are current
3541
run: |

.github/workflows/release-on-npm.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ jobs:
3030
pnpm-lock.yaml
3131
package.json
3232
src/**/package.json
33-
- run: pnpm install --frozen-lockfile
33+
- name: Install root JS dependencies
34+
run: pnpm install --frozen-lockfile
3435

3536
- name: Update version of JS packages
3637
run: pnpm version ${{ env.VERSION }} --no-git-tag-version --workspaces --no-workspaces-update

.github/workflows/unit-tests.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ jobs:
145145
runs-on: ubuntu-latest
146146
steps:
147147
- uses: actions/checkout@v4
148+
148149
- run: npm i -g corepack && corepack enable
149150
- uses: actions/setup-node@v4
150151
with:
@@ -154,5 +155,8 @@ jobs:
154155
pnpm-lock.yaml
155156
package.json
156157
src/**/package.json
157-
- run: pnpm install --frozen-lockfile
158+
159+
- name: Install root JS dependencies
160+
run: pnpm install --frozen-lockfile
161+
158162
- run: pnpm run test:unit

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ node_modules
88
/vendor
99

1010
/browsers
11-
.last-run.json
1211
.playwright-report/
12+
.playwright-output/

bin/test_package.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ fi
4040
runTestSuite() {
4141
if [ "$testType" == "unit" ]; then
4242
echo -e "🧪 Running unit tests for $workspace...\n"
43-
pnpm exec vitest --run "${args[@]}" || { all_tests_passed=false; }
43+
(cd "$location"; pnpm exec vitest --run "${args[@]}") || { all_tests_passed=false; }
4444
elif [ "$testType" == "browser" ]; then
4545
echo -e "🧪 Running browser tests for $workspace...\n"
46-
# TODO: to implement
46+
(cd "$location"; pnpm exec playwright test "${args[@]}") || { all_tests_passed=false; }
4747
fi
4848
}
4949

@@ -99,16 +99,18 @@ processWorkspace() {
9999
trimmed_version=$(echo "$version" | tr -d '[:space:]')
100100
if [ -n "$trimmed_version" ]; then
101101
# Install each version of the library separately
102-
echo -e " - Install $library@$trimmed_version for $workspace\n"
103-
pnpm add "$library@$trimmed_version" --save-peer --filter "$workspace"
102+
echo -e " - Installing $library@$trimmed_version for $workspace\n"
103+
(cd "$location" || exit 1; pnpm add "$library@$trimmed_version" --save-peer --silent)
104+
echo -e " - Building $workspace assets...\n"
105+
(cd "$location" || exit 1; pnpm run build)
104106

105107
runTestSuite
106108
fi
107109
done
108110
done
109111

110-
echo " -> Reverting version changes from $package_json_path"
111-
git checkout -- "$package_json_path" "$PROJECT_DIR/pnpm-lock.yaml"
112+
echo " -> Reverting changes"
113+
git checkout -- "$package_json_path" "$location/dist" "$PROJECT_DIR/pnpm-lock.yaml"
112114
else
113115
echo -e " -> No peerDependencies found with multiple versions defined\n"
114116
runTestSuite

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"build": "pnpm run --filter @symfony/ux-map build && pnpm run -r --aggregate-output build",
1111
"test": "pnpm run -r --workspace-concurrency=1 test",
1212
"test:unit": "pnpm run -r --aggregate-output test:unit",
13-
"test:browser": "pnpm exec playwright test",
13+
"test:browser": "pnpm run -r --workspace-concurrency=1 test:browser",
1414
"check": "biome check",
1515
"ci": "biome ci"
1616
},
@@ -25,8 +25,7 @@
2525
"pkg-types": "^2.2.0",
2626
"tinyglobby": "^0.2.14",
2727
"tsup": "^8.5.0",
28-
"vitest": "^3.2.4",
29-
"webdriverio": "^9.19.1"
28+
"vitest": "^3.2.4"
3029
},
3130
"version": "2.27.0"
3231
}

playwright.config.ts renamed to playwright.config.base.ts

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,33 @@
1-
import { defineConfig, devices } from '@playwright/test';
1+
/**
2+
* Playwright base configuration for UX packages, for browser testing.
3+
*
4+
* This file is not intended to be used directly, but to be used by UX packages themselves.
5+
* For example:
6+
* ```typescript
7+
* // src/Autocomplete/assets/playwright.config.ts
8+
*
9+
* import baseConfig from '../../../../../../playwright.config.base';
10+
*
11+
* export default baseConfig;
12+
* ```
13+
*/
214

15+
import { defineConfig, devices } from '@playwright/test';
316
import { browsers } from './bin/get_browsers.mjs';
417

518
export default defineConfig({
6-
testMatch:[
7-
'src/**/assets/test/browser/**/*.{test,spec}.ts',
8-
'src/**/assets/test/**/*.browser.{test,spec}.ts',
9-
],
10-
testIgnore: [
11-
// TODO: Temporary, as the Map tests require some TypeScript code to be compiled
12-
// and so fails (which is expected). To remove once the tests are real E2E.
13-
/Map/
19+
testMatch: [
20+
'**/test/browser/**/*.{test,spec}.ts',
21+
'**/test/**/*.browser.{test,spec}.ts',
1422
],
1523

1624
reporter: [
1725
['list'],
1826
['html', { open: process.env.CI ? 'never' : 'on-failure', outputFolder: '.playwright-report' }],
1927
],
2028

29+
outputDir: '.playwright-output',
30+
2131
use: {
2232
// Base URL to use in actions like `await page.goto('/')`.
2333
baseURL: 'http://localhost:9876',
@@ -27,13 +37,6 @@ export default defineConfig({
2737
trace: 'retain-on-failure'
2838
},
2939

30-
//webServer: {
31-
// command: 'cd test_apps/e2e-app && symfony serve',
32-
// url: 'http://localhost:9876',
33-
// reuseExistingServer: !process.env.CI,
34-
// stderr: 'pipe',
35-
//},
36-
3740
projects: [
3841
{
3942
name: 'chrome-lowest',

0 commit comments

Comments
 (0)