fix(edge-apps): use Playwright Clock API for idempotent screenshots#712
fix(edge-apps): use Playwright Clock API for idempotent screenshots#712nicomiguelino merged 2 commits intomasterfrom
Conversation
- Add FIXED_SCREENSHOT_DATE constant and setupClockMock() utility to edge-apps-library - Apply setupClockMock() in all screenshot specs (clock, simple-timer, weather, menu-board, qr-code, grafana, cap-alerting, and bun-create template) - Regenerate screenshots for clock, simple-timer, and weather with frozen clock Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
PR Reviewer Guide 🔍(Review updated until commit eebae78)Here are some key observations to aid the review process:
|
|
Persistent review updated to latest commit eebae78 |
PR Code Suggestions ✨Latest suggestions up to eebae78
Previous suggestionsSuggestions up to commit eebae78
|
There was a problem hiding this comment.
Pull request overview
This PR implements idempotent screenshot generation by freezing the browser clock to a fixed date using Playwright's Clock API. The change ensures that running screenshot tests multiple times produces pixel-identical output regardless of execution time, which is critical for apps that render current date/time information.
Changes:
- Added
FIXED_SCREENSHOT_DATEconstant andsetupClockMock()utility function to the edge-apps-library test module - Applied clock freezing in all 8 screenshot test specs before page navigation
- Regenerated screenshots for clock, simple-timer, and weather apps with the frozen clock
Reviewed changes
Copilot reviewed 9 out of 39 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| edge-apps/edge-apps-library/src/test/screenshots.ts | Added FIXED_SCREENSHOT_DATE constant and setupClockMock() utility function |
| edge-apps/clock/e2e/screenshots.spec.ts | Added setupClockMock() call before page.goto() |
| edge-apps/simple-timer/e2e/screenshots.spec.ts | Added setupClockMock() call before page.goto() |
| edge-apps/weather/e2e/screenshots.spec.ts | Added setupClockMock() call before page.goto() |
| edge-apps/menu-board/e2e/screenshots.spec.ts | Added setupClockMock() call before page.goto() |
| edge-apps/qr-code/e2e/screenshots.spec.ts | Added setupClockMock() call before page.goto() |
| edge-apps/grafana/e2e/screenshots.spec.ts | Added setupClockMock() call before page.goto() |
| edge-apps/cap-alerting/e2e/screenshots.spec.ts | Added setupClockMock() call before page.goto() |
| edge-apps/.bun-create/edge-app-template/e2e/screenshots.spec.ts | Added setupClockMock() call before page.goto() |
| edge-apps/clock/screenshots/*.webp | Regenerated screenshot files with frozen clock |
| edge-apps/simple-timer/screenshots/*.webp | Regenerated screenshot files with frozen clock |
| edge-apps/weather/screenshots/*.webp | Regenerated screenshot files with frozen clock |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Summary
Idempotent screenshots means that running
bun run screenshotsmultiple times always produces pixel-identical output, regardless of when the tests are executed. Without a frozen clock, apps that render the current date or time produce different screenshots on every run.FIXED_SCREENSHOT_DATEconstant andsetupClockMock()utility toedge-apps-libraryusing Playwright's Clock API (setFixedTime)setupClockMock()in all 8 screenshot specs (clock, simple-timer, weather, menu-board, qr-code, grafana, cap-alerting, bun-create template) beforepage.goto()to freeze time prior to any JS execution