SurfSense icon indicating copy to clipboard operation
SurfSense copied to clipboard

Run the `surfsense_web` unit tests in CI

Open MODSetter opened this issue 2 months ago • 2 comments

The gap

docs/architecture/sunset.md lists this under Known gaps:

The web app's unit tests, tests/unit/sunset-redirect.test.ts among 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 — the web-lint job already checks out the repo, sets up pnpm pinned from surfsense_web/package.json, installs Node 20 and runs pnpm install --frozen-lockfile in surfsense_web. Everything a unit test run needs is already there.
  • The changes job's web filter already covers surfsense_web/**, so nothing new is needed to decide when it should run.
  • The gate job lists every job it waits on in needs. A new job that is not in that list cannot fail the build.
  • surfsense_web/package.json — test:unit is the script to call; do not invent a second one.

What done looks like

  • A pull request that breaks a surfsense_web unit test fails CI.
  • A pull request that touches nothing under surfsense_web does 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-lint or a job of its own is yours to decide. A separate job reports failures separately but needs its own setup and its own needs entry 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.md in 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.

MODSetter avatar Sep 28 '26 22:09 MODSetter

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.

Yi-111-a avatar Sep 29 '26 17:09 Yi-111-a

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.

MODSetter avatar Sep 29 '26 20:09 MODSetter