-
Notifications
You must be signed in to change notification settings - Fork 272
WS-2281 Migrate a Few Homepage E2E Tests from Cypress to Playwright and Integrate with CI #13670
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
Changes from all commits
30ff686
9fb58ff
1fd6733
78179d7
e7b5da6
d874188
935f8e6
6acc7dd
3a08945
66510d1
40da1ab
98daebe
eae14d7
5ead5fa
33797a2
c1e217f
e23b582
e408d08
b595d5c
84e4788
9077462
2c14ea8
8323dc4
e08365d
0c8bf06
4dd8ec2
df0cc6f
8ccaca0
6935adb
2e27dfd
5444e23
1274a30
da3c3b8
d9eacb1
3eb49ad
f5b161e
a9ec091
e222c8c
9740865
91c2b27
199ce9f
3fa8bd6
e1a7565
e4da992
be08253
ed50721
f80cbc5
c542fcf
382d635
28841b7
2d30a86
c4a89cb
0ba9d12
5b01e60
537c87e
b13c636
f78ef41
d171ebc
9040a06
11fb587
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| name: Playwright E2E - Simorgh | ||
| on: | ||
| pull_request: | ||
| branches: | ||
| - '**' | ||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| node-version: [22.x] | ||
| env: | ||
| CI: true | ||
| LOG_LEVEL: 'error' | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Use Node.js ${{ matrix.node-version }} | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: ${{ matrix.node-version }} | ||
|
|
||
| - name: Cache Node Modules | ||
| id: cache | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: | | ||
| node_modules | ||
| ws-nextjs-app/node_modules | ||
| key: node-modules-${{ hashFiles('yarn.lock', 'ws-nextjs-app/yarn.lock') }} | ||
|
|
||
| - name: Install Node Modules | ||
| if: steps.cache.outputs.cache-hit != 'true' | ||
| run: | | ||
| rm -rf node_modules | ||
| git config --global user.name "${{ secrets.WS_UTF_USERNAME }}" | ||
| git config --global user.email "${{ secrets.WS_UTF_EMAIL }}" | ||
| git config --global url."https://${{ secrets.WS_UTF_AUTH }}@github.com/".insteadOf "https://github.com/" | ||
| ./scripts/installNodeModules.sh | ||
|
|
||
| - name: Install Playwright Browsers | ||
|
MeriemMechri marked this conversation as resolved.
|
||
| working-directory: ws-nextjs-app | ||
| run: npx playwright install --with-deps | ||
|
|
||
| - name: Run Playwright tests | ||
| working-directory: ws-nextjs-app | ||
| run: HEADLESS=true npx playwright test --project="WorldService - Chrome" | ||
|
|
||
| - uses: actions/upload-artifact@v4 | ||
| if: ${{ !cancelled() }} | ||
| with: | ||
| name: playwright-report | ||
| path: ws-nextjs-app/playwright-report | ||
| retention-days: 30 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,7 +35,12 @@ jobs: | |
|
|
||
| - name: Install Node Modules | ||
| if: steps.cache.outputs.cache-hit != 'true' | ||
| run: ./scripts/installNodeModules.sh | ||
| run: | | ||
| rm -rf node_modules | ||
| git config --global user.name "${{ secrets.WS_UTF_USERNAME }}" | ||
| git config --global user.email "${{ secrets.WS_UTF_EMAIL }}" | ||
| git config --global url."https://${{ secrets.WS_UTF_AUTH }}@github.com/".insteadOf "https://github.com/" | ||
| ./scripts/installNodeModules.sh | ||
|
MeriemMechri marked this conversation as resolved.
Comment on lines
36
to
+43
|
||
|
|
||
| - name: Integration Tests - Express | ||
| run: yarn test:integration:ci | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,7 +35,12 @@ jobs: | |
|
|
||
| - name: Install Node Modules | ||
| if: steps.cache.outputs.cache-hit != 'true' | ||
| run: ./scripts/installNodeModules.sh | ||
| run: | | ||
| rm -rf node_modules | ||
| git config --global user.name "${{ secrets.WS_UTF_USERNAME }}" | ||
| git config --global user.email "${{ secrets.WS_UTF_EMAIL }}" | ||
| git config --global url."https://${{ secrets.WS_UTF_AUTH }}@github.com/".insteadOf "https://github.com/" | ||
| ./scripts/installNodeModules.sh | ||
|
MeriemMechri marked this conversation as resolved.
Comment on lines
36
to
+43
|
||
|
|
||
| - name: Build Simorgh - Express App | ||
| run: yarn build:local | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -40,7 +40,12 @@ jobs: | |||||
|
|
||||||
| - name: Install Node Modules | ||||||
| if: steps.cache.outputs.cache-hit != 'true' | ||||||
| run: ./scripts/installNodeModules.sh | ||||||
| run: | | ||||||
| rm -rf node_modules | ||||||
| git config --global user.name "${{ secrets.WS_UTF_USERNAME }}" | ||||||
| git config --global user.email "${{ secrets.WS_UTF_EMAIL }}" | ||||||
| git config --global url.https://${{ secrets.WS_UTF_AUTH }}@github.com/.insteadOf https://github.com/ | ||||||
|
||||||
| git config --global url.https://${{ secrets.WS_UTF_AUTH }}@github.com/.insteadOf https://github.com/ | |
| git config --global url."https://${{ secrets.WS_UTF_AUTH }}@github.com/".insteadOf "https://github.com/" |
Copilot
AI
Apr 14, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This workflow now relies on repo secrets (WS_UTF_*) during pull_request runs. For PRs from forks, GitHub Actions does not provide secrets, so yarn install will fail when it tries to fetch the private GitHub dependency. Consider gating the job (or the secret-dependent install snippet) to same-repo PRs to avoid failing forked PRs unexpectedly.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -34,7 +34,12 @@ jobs: | |||||
|
|
||||||
| - name: Install Node Modules | ||||||
| if: steps.cache.outputs.cache-hit != 'true' | ||||||
| run: ./scripts/installNodeModules.sh | ||||||
| run: | | ||||||
| rm -rf node_modules | ||||||
| git config --global user.name "${{ secrets.WS_UTF_USERNAME }}" | ||||||
| git config --global user.email "${{ secrets.WS_UTF_EMAIL }}" | ||||||
| git config --global url.https://${{ secrets.WS_UTF_AUTH }}@github.com/.insteadOf https://github.com/ | ||||||
|
||||||
| git config --global url.https://${{ secrets.WS_UTF_AUTH }}@github.com/.insteadOf https://github.com/ | |
| git config --global url."https://${{ secrets.WS_UTF_AUTH }}@github.com/".insteadOf "https://github.com/" |
Large diffs are not rendered by default.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import { config } from '@bbc/unified-web-e2e-framework'; | ||
|
|
||
| config.testDir = 'playwright/specs'; | ||
| if (config.use) { | ||
| config.use.baseURL = 'https://www.bbc.com'; | ||
| } | ||
|
|
||
|
MeriemMechri marked this conversation as resolved.
|
||
| export default config; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "rules": { | ||
| // these rules seem to be used as the common pattern for looping elements in playwright | ||
| "no-restricted-syntax": ["off", "ForOfStatement"], | ||
| "no-await-in-loop": "off", | ||
| }, | ||
| } | ||
|
MeriemMechri marked this conversation as resolved.
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # Playwright | ||
|
|
||
| To run the Playwright tests for the World Service Chrome project, change to the `ws-nextjs-app` directory and use the package script: | ||
| `cd ws-nextjs-app && yarn test:e2e:playwright --project="WorldService - Chrome"` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| import SERVICES from '#app/lib/config/services'; | ||
| import { test } from '@bbc/unified-web-e2e-framework'; | ||
| import { expect } from '@playwright/test'; | ||
|
|
||
| const SERVICES_PATTERN = SERVICES.join('|'); | ||
|
|
||
| const VALID_HREF_REGEX = new RegExp( | ||
| `^https://www\\.bbc\\.com/(?:${SERVICES_PATTERN}|usingthebbc/[^/]+(?:/.*)?|programmes/[a-z0-9]{8,15})(?:/.*)?$`, | ||
| ); | ||
|
|
||
|
Comment on lines
+2
to
+10
|
||
| const testSuites = [ | ||
| { | ||
| path: '/arabic', | ||
| service: 'arabic', | ||
| }, | ||
| { | ||
| path: '/dari', | ||
| service: 'dari', | ||
| }, | ||
| { | ||
| path: '/kyrgyz', | ||
| service: 'kyrgyz', | ||
| }, | ||
| { | ||
| path: '/magyarul', | ||
| service: 'magyarul', | ||
| expectedPath: '/magyarul/articles/cwywderkzy2o', | ||
| }, | ||
| { | ||
| path: '/polska', | ||
| service: 'polska', | ||
| }, | ||
| { | ||
| path: '/portuguese', | ||
| service: 'portuguese', | ||
| }, | ||
| { | ||
| path: '/romania', | ||
| service: 'romania', | ||
| expectedPath: '/romania/articles/c993yged1xno', | ||
| }, | ||
| { | ||
| path: '/serbian/lat', | ||
| service: 'serbian', | ||
| variant: 'lat', | ||
| }, | ||
| { | ||
| path: '/serbian/cyr', | ||
| service: 'serbian', | ||
| variant: 'cyr', | ||
| }, | ||
| { | ||
| path: '/uzbek/lat', | ||
| service: 'uzbek', | ||
| variant: 'lat', | ||
| }, | ||
| { | ||
| path: '/uzbek/cyr', | ||
| service: 'uzbek', | ||
| variant: 'cyr', | ||
| }, | ||
| ]; | ||
|
|
||
| testSuites.forEach(suite => { | ||
| test.describe(`Home Page - ${suite.service}${suite.variant ?? ''}`, () => { | ||
| test('all links within <main> element should be a valid World Service URL', async ({ | ||
| page, | ||
| }) => { | ||
| const expectedPath = suite.expectedPath || suite.path; | ||
|
|
||
| await page.goto(suite.path); | ||
| await expect(page).toHaveURL(expectedPath); | ||
|
|
||
| const pageLinks = await page | ||
| .locator('main a[href^="https://www.bbc.com"]') | ||
| .all(); | ||
|
|
||
| for (const link of pageLinks) { | ||
| const href = await link.getAttribute('href'); | ||
| expect(href).not.toBeNull(); | ||
| expect(href).toMatch(VALID_HREF_REGEX); | ||
| } | ||
| }); | ||
| }); | ||
| }); | ||
Uh oh!
There was an error while loading. Please reload this page.