Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
Adds Playwright visual (screenshot) coverage for the landing page “banner” in English and Urdu, and wires up snapshot storage + a Docker-based script to generate/update those snapshots.
Changes:
- Add a new Playwright visual test spec for the landing page banner (English + Urdu).
- Commit baseline screenshots for Chromium/Firefox/WebKit.
- Update Playwright config to customize snapshot paths and set a global screenshot diff tolerance; add a Docker script to generate snapshots.
Reviewed changes
Copilot reviewed 2 out of 9 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| playwright/tests/visual-tests/banner.spec.ts | Introduces visual assertions for the landing page banner in English and Urdu. |
| playwright.config.ts | Configures global toHaveScreenshot diff tolerance and a custom snapshot output path template. |
| package.json | Adds a Docker-based script intended to generate/update banner visual snapshots. |
| playwright/screenshots/** | Adds baseline PNG snapshots for all 3 browser projects. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Im not sure that's the best approach, I think there should be a way to create and run screenshot tests so everyone can run these locally and they run in CI fine. Otherwise, it would be quite annoying to have to push code to github in order to test it. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 10 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 10 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| await expect(landingPage.heroBanner).toHaveScreenshot( | ||
| "landing-page-banner-english.png", | ||
| { maxDiffPixelRatio: 0.05 } | ||
| ); |
There was a problem hiding this comment.
maxDiffPixelRatio is configured globally (playwright.config.ts) but these assertions override it with a different value (0.05). Having two tolerances makes the visual baseline harder to reason about and 5% can mask real regressions. Consider relying on the global default and only overriding per-test when there’s a documented reason (or align the per-test value with the global setting).
|
|
||
| /* Standardize viewport and pixel density across local and CI environments */ | ||
| viewport: { width: 1280, height: 720 }, | ||
| deviceScaleFactor: 1, |
There was a problem hiding this comment.
The added viewport and deviceScaleFactor in the root use block are likely being overridden by the per-project use: { ...devices[...] } settings (those device presets include their own viewport/scale). As a result, this may not actually standardize rendering for screenshots across environments. Consider either (1) setting viewport/deviceScaleFactor explicitly inside each project’s use, or (2) not spreading devices[...] presets and instead set only browserName + the standardized viewport/scale in one place.
| /* Standardize viewport and pixel density across local and CI environments */ | |
| viewport: { width: 1280, height: 720 }, | |
| deviceScaleFactor: 1, |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 13 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| playwright: | ||
| build: | ||
| context: . | ||
| dockerfile: Dockerfile.test |
There was a problem hiding this comment.
The compose file references Dockerfile.test, but this PR adds DockerFile.test (capital F). On case-sensitive filesystems (most Linux/CI), Docker won’t find the file and the build will fail. Rename the file to Dockerfile.test (or update docker-compose.test.yml to match) so the path is consistent.
| dockerfile: Dockerfile.test | |
| dockerfile: DockerFile.test |
|
|
||
| /* Standardize viewport and pixel density across local and CI environments */ | ||
| viewport: { width: 1280, height: 720 }, | ||
| deviceScaleFactor: 1, |
There was a problem hiding this comment.
Viewport and deviceScaleFactor are set globally here and also repeated inside each project’s use block. This duplication increases maintenance and can cause confusion about which values are authoritative. Consider keeping these settings in only one place (global use if shared by all projects; per-project only if they differ).
| /* Standardize viewport and pixel density across local and CI environments */ | |
| viewport: { width: 1280, height: 720 }, | |
| deviceScaleFactor: 1, |
There was a problem hiding this comment.
You told me to do it this way. I had it right before lol
There was a problem hiding this comment.
I believe copilot is suggesting that we should only set viewport in a single spot. Right now it's currently configured here globally for all projects and then overriden down below for each project/browser configuration.
It doesn't appear that Copilot is actually suggesting one method over the other -- just that we should only set viewport once.
| this.mainHeading = page.getByRole("heading", { | ||
| name: "Apply for a Library Card Online", | ||
| name: /Apply for a Library Card Online|للائبریری کارڈ کے لیے آن لائن اپلائی کریں/, | ||
| level: 1, | ||
| }); |
There was a problem hiding this comment.
The page object’s mainHeading locator is now coupled to specific localized strings. This makes the page object less reusable and can create false positives if copy changes. A more maintainable approach is to locate the H1 structurally (e.g., role+level only) and assert the exact text per test (English vs Urdu) in the spec.
| #!/bin/bash | ||
|
|
||
| # 1. Extract Playwright version from package.json | ||
| PW_VERSION=$(node -p "require('./package.json').devDependencies['@playwright/test'].replace(/[^0-9.]/g, '')") |
There was a problem hiding this comment.
This script would be more reliable if it failed fast and cleaned up resources: add set -euo pipefail and consider using a trap to run docker-compose ... down on exit to avoid leaving containers/networks around after failures. Also, docker-compose is deprecated in many environments in favor of docker compose (Compose v2), so switching improves compatibility.
| # 1. Extract Playwright version from package.json | ||
| PW_VERSION=$(node -p "require('./package.json').devDependencies['@playwright/test'].replace(/[^0-9.]/g, '')") | ||
|
|
||
| echo "🚀 Detected Playwright v$PW_VERSION. Starting Docker environment..." | ||
|
|
||
| # 2. Run the tests using the matching Docker image | ||
| # We use 'up --build' to ensure any code changes are reflected | ||
| PW_VERSION=$PW_VERSION docker-compose -f docker-compose.test.yml up --build --exit-code-from playwright No newline at end of file |
There was a problem hiding this comment.
This script would be more reliable if it failed fast and cleaned up resources: add set -euo pipefail and consider using a trap to run docker-compose ... down on exit to avoid leaving containers/networks around after failures. Also, docker-compose is deprecated in many environments in favor of docker compose (Compose v2), so switching improves compatibility.
| # 1. Extract Playwright version from package.json | |
| PW_VERSION=$(node -p "require('./package.json').devDependencies['@playwright/test'].replace(/[^0-9.]/g, '')") | |
| echo "🚀 Detected Playwright v$PW_VERSION. Starting Docker environment..." | |
| # 2. Run the tests using the matching Docker image | |
| # We use 'up --build' to ensure any code changes are reflected | |
| PW_VERSION=$PW_VERSION docker-compose -f docker-compose.test.yml up --build --exit-code-from playwright | |
| set -euo pipefail | |
| # 1. Extract Playwright version from package.json | |
| PW_VERSION=$(node -p "require('./package.json').devDependencies['@playwright/test'].replace(/[^0-9.]/g, '')") | |
| echo "🚀 Detected Playwright v$PW_VERSION. Starting Docker environment..." | |
| # Ensure Docker resources are cleaned up on exit, even on failure | |
| trap 'docker compose -f docker-compose.test.yml down || true' EXIT | |
| # 2. Run the tests using the matching Docker image | |
| # We use 'up --build' to ensure any code changes are reflected | |
| PW_VERSION=$PW_VERSION docker compose -f docker-compose.test.yml up --build --exit-code-from playwright |

Description
Added screenshot tests for the hero component banner for English and Urdu
Added a script to the package.json to use docker to create screenshots
Added Dockerfile.test
Added docker-compose-test.yml
Tickets:
Motivation and Context
How Has This Been Tested?
npm run devnpm run test:visual -- playwright/tests/visual-tests/banner.spec.tsCommand to run tests
npm run test:visual -- playwright/tests/visual-tests/banner.spec.tsCommand to update screenshots
pm run test:visual:update -- tests/banner.spec.ts --update-snapshotsChecklist: