test: add Playwright + Vitest harness with first E2E and unit suites#1
Merged
Conversation
…en recipe Replace stale "CI auto-generates linux baseline on first run" copy in tests/README.md and the inline banner.spec.ts comment with the current approach: the committed Linux PNG is the source of truth, CI only verifies, and contributors must use the Playwright Docker image to regenerate it. Also adds .pnpm-store/ to .gitignore (created by the Docker recipe).
… add no-Docker fallback
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Bootstraps an end-to-end testing harness for the MV3 extension using Playwright (real Chromium with the unpacked extension loaded), plus a small Vitest unit suite for pure scheduling logic. Adds a CI
e2ejob that runs afterbuild.decideRefresh/decideReminddistartifact (no double build) and runspnpm test:e2e --headless=newWhy now
There was zero test infrastructure. The recent banner font fix (
bfc20cc) is exactly the kind of regression a screenshot test catches; this PR adds that net plus enough behavioral coverage to ship changes with confidence.Architecture decisions
chrome.alarmsminimum period is 1 minute.decideRefreshanddecideRemindmoved from inline branches inservice-worker.tsintosrc/background/scheduler.tsas pure functions. Makes the unit suite possible without mockingchrome.*.manifest.config.tshas nokeyfield, so the fixture parses the ID fromserviceWorker.url()after waiting oncontext.waitForEvent('serviceworker').page.route. Chromium matchescontent_scriptsby URL not response origin, so the content script injects normally on a stub HTML response.*-darwin.pngvariants are gitignored.Bundled SW changes (heads-up)
a6d398ais labeled "extract scheduling helpers" but the diff also carries pre-existing in-progress work that was on the working tree:ensureAlarm()helper — alarm creation is now idempotent (checkschrome.alarms.getfirst)periodInMinutes: 0.5to1(matches the chrome.alarms minimum)log(...)debug logging added throughout (tick, alarm fire, tab activation, blur, reload)These are real product improvements, not testing scaffolding. I bundled them into the extraction commit because they were already in the working tree when SDD apply ran. Open to splitting into a separate
feat(background): idempotent alarm + structured logscommit if reviewer prefers — say the word.Test coverage
toHaveScreenshotLinux baseline committed; macOS/Windows local-onlygh-refresh-tickregistered after initprefs-updatedack;refresh-nowfrom non-tab sender no-ops but acksKnown gaps (intentional, not blockers)
tick()not exercised end-to-end — unit tests cover the decision math, message-passing test covers the wiring, but the integration "alarm fires → walk all tabs → reload the right ones" is unverified. Closing this needstick()exported for direct invocation. Filed as follow-up.tests/README.md. CI does not auto-update.webNavigation.onHistoryStateUpdatedare untested. Lower priority.Test plan
buildjob passes (existing)e2ejob runs and passes against the committed Linux baselinetests/README.md, commit the updatedreminder-banner-chromium-linux.pngpnpm typecheck && pnpm lint && pnpm buildgreenpnpm test:unit12/12pnpm test:e2e7/7 locally on macOSFiles
New:
playwright.config.ts,vitest.config.tssrc/background/scheduler.tstests/e2e/fixtures/extension.ts,tests/e2e/fixtures/github-stub.htmltests/e2e/popup.spec.ts,tests/e2e/banner.spec.ts,tests/e2e/service-worker.spec.tstests/unit/scheduler.spec.ts,tests/unit/setup.tstests/README.mdModified:
src/background/service-worker.ts(helper imports + bundled improvements above)package.json(devDeps:@playwright/test,vitest; scripts:test,test:unit,test:e2e,test:e2e:ui)eslint.config.js(tests/ override forreact-hooks/rules-of-hookson Playwright fixtures).github/workflows/ci.yml(newe2ejob).gitignore(test artifacts + OS-specific snapshots)CHANGELOG.md