Run the `surfsense_web` unit tests in CI
The gap
docs/architecture/sunset.md lists this under Known gaps:
The web app's unit tests,
tests/unit/sunset-redirect.test.tsamong them, are not run in CI.
Why it matters
There are around thirty unit test files under surfsense_web/tests/unit/ and nothing runs them on a pull request. Docker Tests gives the web tree one job, Web Lint, which runs Biome and stops. So a PR can break the redirect that decides whether every hosted route goes to /sunset, the chat streaming state or the artifact queries, and still show a green tick.
They are cheap to run — pnpm test:unit is tsx --test, with no browser, no database and no services — which makes the absence pure oversight rather than a trade. The tests are already written and already pass.
Where
.github/workflows/docker-tests.yml— theweb-lintjob already checks out the repo, sets up pnpm pinned fromsurfsense_web/package.json, installs Node 20 and runspnpm install --frozen-lockfileinsurfsense_web. Everything a unit test run needs is already there.- The
changesjob'swebfilter already coverssurfsense_web/**, so nothing new is needed to decide when it should run. - The
gatejob lists every job it waits on inneeds. A new job that is not in that list cannot fail the build. surfsense_web/package.json—test:unitis the script to call; do not invent a second one.
What done looks like
- A pull request that breaks a
surfsense_webunit test fails CI. - A pull request that touches nothing under
surfsense_webdoes not start the job, in line with the comment at the top of the workflow about one filter per job. - Whether this is a step inside
web-lintor a job of its own is yours to decide. A separate job reports failures separately but needs its own setup and its ownneedsentry on the gate; a step reuses the install that is already there. Say which you picked and why. - Delete the Known gaps line from
docs/architecture/sunset.mdin the same PR.
What not to change
Leave test:e2e where it is. Playwright needs the whole compose stack, which is why it lives in the e2e job behind its own filter, and folding it in here would put several minutes and a database on every web-only PR.
How to verify
No new test to write — the point of this one is that existing tests start running. Confirm the command passes locally first, then confirm in CI that the job appears, that it fails when a test is deliberately broken, and that it is skipped on a backend-only PR.
cd surfsense_web
pnpm install --frozen-lockfile
pnpm test:unit
Before you start
Read CONTRIBUTING.md and the sunset doc. Workflow changes take effect from the pull request itself, so your own PR is the proof. Open it against dev, not main. Comment here to claim this.
I'd like to take this one. Plan: run pnpm test:unit from the existing web-lint job so it reuses the pnpm/Node setup and install that are already there, rather than adding a separate job with its own setup and a new needs entry on the gate. I'll confirm locally that pnpm test:unit passes in surfsense_web, delete the Known gaps line from docs/architecture/sunset.md in the same PR, and open against dev. This work is AI-assisted; no independent human review is claimed.
Fixed by #2024, ci(web): run the surfsense_web unit tests on pull requests, by @MannXo. Merged into dev.
Closing by hand rather than by keyword: Fixes #2007 only auto-closes on a merge to the default branch, and this repo merges through dev (CONTRIBUTING), so this would have stayed open and claimable while the work was already done. It reaches main with the next release.
Nothing left to pick up here.