WS-2281 Migrate a Few Homepage E2E Tests from Cypress to Playwright and Integrate with CI#13670
WS-2281 Migrate a Few Homepage E2E Tests from Cypress to Playwright and Integrate with CI#13670MeriemMechri wants to merge 60 commits intolatestfrom
Conversation
…right-sample-tests
…right-sample-tests
…right-sample-tests
…right-sample-tests
…right-sample-tests
…right-sample-tests
f0b411a to
3a08945
Compare
510d0f8 to
100939e
Compare
100939e to
c1e217f
Compare
5050a62 to
d7e7319
Compare
There was a problem hiding this comment.
Pull request overview
Migrates the Next.js Home Page E2E coverage from Cypress patterns toward Playwright using the BBC unified web E2E framework, alongside Yarn/CI adjustments to support installing a private GitHub dependency in CI.
Changes:
- Add Playwright + unified E2E framework dependencies and initial Home Page Playwright spec/helpers.
- Introduce a dedicated Playwright GitHub Actions workflow and adjust existing workflows’ install step to authenticate GitHub dependency fetches.
- Bump Yarn version/config and update Jest/TS configs to avoid picking up Playwright files in unit test runs.
Reviewed changes
Copilot reviewed 15 out of 37 changed files in this pull request and generated 17 comments.
Show a summary per file
| File | Description |
|---|---|
| yarn.lock | Adds Playwright + unified E2E framework (and related transitive deps) to the lockfile. |
| ws-nextjs-app/package.json | Adds @playwright/test and @bbc/unified-web-e2e-framework to the Next.js app. |
| ws-nextjs-app/playwright.config.ts | Wires unified framework config to point at playwright/specs. |
| ws-nextjs-app/playwright/specs/homePage.spec.ts | Adds initial Playwright Home Page smoke spec. |
| ws-nextjs-app/playwright/support/helpers/runUrlValidationTest.ts | Adds a Playwright URL validation helper mirroring existing Cypress coverage. |
| ws-nextjs-app/playwright/support/runtTestForPage.playwright.ts | Adds a Playwright analogue of the Cypress runTestsForPage harness. |
| ws-nextjs-app/playwright/README.md | Adds minimal Playwright run instructions. |
| ws-nextjs-app/playwright/.eslintrc | Adds Playwright-folder ESLint overrides. |
| ws-nextjs-app/jest.config.ts | Ignores the playwright directory for Jest runs in ws-nextjs-app. |
| tsconfig.json | Excludes ws-nextjs-app Playwright TS files from the root TS project. |
| package.json | Updates unit-test scripts’ ignore patterns and bumps Yarn packageManager version. |
| .yarnrc.yml | Updates Yarn config formatting and yarnPath to Yarn 4.13.0. |
| .gitignore | Adds an ignore entry intended for Playwright report assets. |
| .github/workflows/simorgh-unit-tests.yml | Updates install step to support private GitHub dependency fetch. |
| .github/workflows/simorgh-misc-checks.yml | Updates install step to support private GitHub dependency fetch. |
| .github/workflows/simorgh-local-server-tests.yml | Updates install step to support private GitHub dependency fetch. |
| .github/workflows/simorgh-integration-tests.yml | Updates install step to support private GitHub dependency fetch. |
| .github/workflows/simorgh-e2e-playwright.yml | Adds a dedicated Playwright workflow to run E2E checks and upload reports. |
| .yarn/cache/fsevents-patch-6b67494872-10.zip | Adds Yarn offline cache artifact for fsevents patch. |
| .yarn/cache/fsevents-patch-19706e7e35-10.zip | Adds Yarn offline cache artifact for fsevents patch (variant). |
| .yarn/cache/fsevents-npm-2.3.2-a881d6ac9f-6b5b6f5692.zip | Adds Yarn offline cache artifact for fsevents 2.3.2. |
| .yarn/cache/@playwright-test-npm-1.59.1-8a59644a90-27a894c4d4.zip | Adds Yarn offline cache artifact for @playwright/test. |
| .yarn/cache/@unrs-resolver-binding-linux-x64-gnu-npm-1.11.0-f4a171e974-10.zip | Adds Yarn offline cache artifact (platform binding). |
| .yarn/cache/@img-sharp-linux-x64-npm-0.34.5-06b002e5f6-10.zip | Adds Yarn offline cache artifact (sharp binary). |
| .yarn/cache/@img-sharp-libvips-linux-x64-npm-1.2.4-105fd6d44d-10.zip | Adds Yarn offline cache artifact (libvips). |
| .yarn/cache/@esbuild-linux-x64-npm-0.27.2-11f1a3d9db-10.zip | Adds Yarn offline cache artifact (esbuild binary). |
ws-nextjs-app/playwright/support/helpers/runUrlValidationTest.ts
Outdated
Show resolved
Hide resolved
…right-sample-tests
…right-sample-tests
…right-sample-tests
…right-sample-tests
…right-sample-tests
…right-sample-tests
ws-nextjs-app/playwright/support/helpers/runUrlValidationTest.ts
Outdated
Show resolved
Hide resolved
ws-nextjs-app/playwright/.eslintrc
Outdated
| // these rules seem to be used as the common pattern for looping elemnts in playwright | ||
| "no-restricted-syntax": ["off", "ForOfStatement"], | ||
| "no-await-in-loop": "off", | ||
| }, |
There was a problem hiding this comment.
This .eslintrc file is likely to fail parsing: it’s extensionless (YAML/JSON legacy format), but it contains // comments and trailing commas (e.g. after "no-await-in-loop": "off"). Consider switching to a .eslintrc.js (or valid YAML/JSON without trailing commas) and set the rule values using ESLint’s expected shapes (e.g. no-restricted-syntax: "off").
| // these rules seem to be used as the common pattern for looping elemnts in playwright | |
| "no-restricted-syntax": ["off", "ForOfStatement"], | |
| "no-await-in-loop": "off", | |
| }, | |
| "no-restricted-syntax": "off", | |
| "no-await-in-loop": "off" | |
| } |
| base.beforeAll(async ({ page }) => { | ||
| for (const fn of beforeAll) fn(); | ||
| await page.goto(path, { waitUntil: 'domcontentloaded' }); | ||
| }); | ||
|
|
||
| base.beforeEach(async () => { | ||
| for (const fn of beforeEachFns) fn(); | ||
| // Add any Playwright-specific setup here | ||
| }); |
There was a problem hiding this comment.
The beforeAll / beforeEachFns hooks are invoked without await, and they’re typed as synchronous () => void. If any of these setup functions need to be async (common for Playwright), the current implementation will race. Consider allowing () => void | Promise<void> and awaiting each function inside the Playwright hooks.
|
@alex-magana , @andrewscfc I am ignoring the copilot comments about |
…right-sample-tests
…right-sample-tests
remove unused helper for now, and add command to package
…right-sample-tests
…right-sample-tests
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 24 changed files in this pull request and generated 6 comments.
Comments suppressed due to low confidence (1)
.github/workflows/simorgh-unit-tests.yml:48
- This workflow now relies on repo secrets (
WS_UTF_*) duringpull_requestruns. For PRs from forks, GitHub Actions does not provide secrets, soyarn installwill fail when it tries to fetch the private GitHub dependency. Consider gating the job (or at least the secret-dependent install snippet) to same-repo PRs, similar to how other steps already checkgithub.event.pull_request.head.repo.full_name.
- 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: Build Simorgh - Express App
run: yarn build
- name: Build Simorgh - Next.JS App
working-directory: ./ws-nextjs-app
| - 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 |
There was a problem hiding this comment.
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.
| - 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 |
There was a problem hiding this comment.
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.
| - 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 |
There was a problem hiding this comment.
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.
Resolves JIRA: WS-2015
Summary
Code changes
I got into several issues in this upgrade since this project uses yarn, unlike other internal projects that use npm, evenutally - after a LOT of failed attempts - I had to:
Testing
Useful Links