Skip to content

Commit 57e98bc

Browse files
committed
Merge pull request #375 from ReadAlongs/dev.del-feat-e2e
Bring end to end tests to Studio-Web
2 parents f0d844a + c46a5ec commit 57e98bc

35 files changed

+1572
-21
lines changed

.github/workflows/end-to-end-tests.yml

Lines changed: 79 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ jobs:
2121
node-version: 20
2222
- name: Install everything
2323
run: npm install
24-
- name: Always test with the latest browserslist db
25-
run: |
26-
npx update-browserslist-db@latest
24+
2725
- name: Ng test for studio-web
2826
run: |
2927
npx nx build web-component
@@ -56,3 +54,81 @@ jobs:
5654
npx nx bundle web-component
5755
git status
5856
git diff --word-diff=porcelain --word-diff-regex=... --color | perl -ple 's/^(\x1b[^ -+]{0,6})? (.{81,})$/$1 . " " . substr($2, 0, 40) . " [... " . (length($2)-80) . " bytes ...] " . substr($2, -40)/ex'
57+
playwright-tests:
58+
name: Run Playwright test-suites
59+
timeout-minutes: 60
60+
runs-on: ubuntu-latest
61+
strategy:
62+
fail-fast: false
63+
matrix:
64+
shardIndex: [1, 2, 3, 4]
65+
shardTotal: [4]
66+
steps:
67+
- uses: actions/checkout@v4
68+
- uses: actions/setup-node@v4
69+
with:
70+
node-version: lts/*
71+
- name: Install and run the back-end API, needed for end-to-end testing
72+
run: |
73+
git clone https://github.com/ReadAlongs/Studio
74+
cd Studio
75+
pip install -e . -r requirements.api.txt
76+
./run-web-api.sh &
77+
# wait for the API to be up
78+
curl --retry 20 --retry-delay 1 --retry-all-errors http://localhost:8000/api/v1/langs
79+
- name: Install everything
80+
run: npm install
81+
- name: Install dependencies
82+
run: npm ci
83+
- name: Run studio-web in the background
84+
run: |
85+
npx nx build web-component
86+
npx nx run-many --targets=serve,serve-fr,serve-es --projects=web-component,studio-web --parallel 6 &
87+
88+
# wait for the studio web to be up
89+
sleep 100
90+
curl --retry 20 --retry-delay 30 --retry-all-errors http://localhost:4200
91+
- name: Run Playwright tests for studio-web
92+
run: |
93+
npx playwright install --with-deps chromium
94+
npx nx e2e studio-web --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
95+
- name: Upload blob report to GitHub Actions Artifacts
96+
if: ${{ !cancelled() }}
97+
uses: actions/upload-artifact@v4
98+
with:
99+
name: blob-report-${{ matrix.shardIndex }}
100+
path: packages/studio-web/blob-report
101+
retention-days: 1
102+
merge-reports:
103+
# Merge reports after playwright-tests, even if some shards have failed
104+
if: ${{ !cancelled() }}
105+
needs: [playwright-tests]
106+
name: "Merge playwright reports"
107+
runs-on: ubuntu-latest
108+
steps:
109+
- uses: actions/checkout@v4
110+
- uses: actions/setup-node@v4
111+
with:
112+
node-version: lts/*
113+
- name: Install everything
114+
run: npm install
115+
- name: Install dependencies
116+
run: npm ci
117+
- name: Install playwright
118+
run: npx playwright install
119+
- name: Download blob reports from GitHub Actions Artifacts
120+
uses: actions/download-artifact@v4
121+
with:
122+
path: all-blob-reports
123+
pattern: blob-report-*
124+
merge-multiple: true
125+
126+
- name: Merge into HTML Report
127+
run: npx playwright merge-reports --reporter=html,github ./all-blob-reports
128+
129+
- name: Upload HTML report
130+
uses: actions/upload-artifact@v4
131+
with:
132+
name: html-report--attempt-${{ github.run_attempt }}
133+
path: playwright-report
134+
retention-days: 5

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ www
99
*~
1010
**/version.ts
1111
packages/web-component/wordpress-plugin/read-along-web-app-loader/js/*
12+
packages/studio-web/playwright-report
13+
**/test-results

.husky/post-install

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npx playwright install --with-deps firefox chromium webkit

package-lock.json

Lines changed: 121 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"@nx/jest": "18.3.4",
1616
"@nx/storybook": "18.3.4",
1717
"@nxext/stencil": "^18",
18+
"@playwright/test": "^1.36.0",
1819
"@stencil/angular-output-target": "^0.8.4",
1920
"@stencil/core": "^4.15.0",
2021
"@stencil/sass": "^3.0.11",
@@ -43,6 +44,7 @@
4344
"prettier": "^3.2.5",
4445
"pretty-quick": "^4.0.0",
4546
"ts-jest": "^29",
47+
"ts-node": "^10.9.2",
4648
"tsx": "^4.7.3"
4749
},
4850
"dependencies": {
@@ -62,6 +64,7 @@
6264
"jszip": "^3.10.1",
6365
"mime": "^4.0.1",
6466
"ngx-toastr": "^18.0.0",
67+
"root": "file:",
6568
"shepherd.js": "^11.2.0",
6669
"soundswallower": "^0.6.3",
6770
"standardized-audio-context": "^25.3.70",

packages/studio-web/package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,14 @@
99
"helpme": "echo This project is part of a monorepo managed using nx. Run the targets in project.json using npx nx target studio-web at the root of the monorepo.",
1010
"ng": "ng",
1111
"test:ng": "ng test",
12-
"test:once": "ng test --watch=false --browsers ChromeHeadlessCI"
12+
"test:once": "ng test --watch=false --browsers ChromeHeadlessCI",
13+
"e2e": "playwright test",
14+
"e2e-ui": "playwright test --ui"
1315
},
1416
"private": true,
1517
"singleFileBundleVersion": "1.5.2",
16-
"singleFileBundleTimestamp": "2024-11-18+11-19-49"
18+
"singleFileBundleTimestamp": "2024-11-18+11-19-49",
19+
"dependencies": {
20+
"readalong-studio": "file:"
21+
}
1722
}

0 commit comments

Comments
 (0)