# Testing playbook Every pull request ships with tests at several layers, and every trap on the Start here tab gets a test that would have caught it. Nothing in the default test run touches the network or production data. ## Test layers Each layer catches a different kind of mistake. CI runs the first six on every push; the rest run locally or by hand at the points listed. | Layer | Catches | How | When | | --- | --- | --- | --- | | Unit | Wrong logic in pure functions: parser, licence codes, number and quote checks, BM25, sessions | Plain pytest, no app, no network | Every push | | Integration | Wiring: routes, templates, SQLite, switches, limits, replication specs | `TestClient(app)` on the temporary database from `tests/conftest.py`, with fakes for HTTP and the model | Every push | | Golden | The parser drifting on real pages | Trimmed CC BY arXiv pages with expected JSON beside them | Every push | | Static guards | Rule breaks that look harmless in review | AST and text checks like `test_event_loop_blocking.py` (list below) | Every push | | Resilience | Failures that should stay quiet | Fakes returning 429, 503, timeouts, malformed HTML, Turso down, a full disk | Every push | | Security | XSS, SSRF, path traversal, image bombs, prompt injection, abuse | Shared payload lists in `tests/security_payloads.py` | Every push | | Browser | What only a real browser shows: swaps, focus, layout, overflow, console errors, layout shift | Playwright, marker `browser`, against a scratch server | Each UI PR, locally. CI doesn't install Playwright | | Visual | Drift from the target screens | Screenshots at 1440, 1180, 900 and 390 px, light and dark, attached to the PR | Each UI PR | | Performance | Slower pages | `scripts/perf_paper_page.py` (new) and the feed timings | Each PR that touches `/p/` or the feed | | Model evaluation | Bad briefings and answers | `eval_briefings.py`, `eval_ask.py`, owner ratings | Before PR 7 or 8 turns on | | Live smoke | The deployed Space working | `pytest -m live`, read-only | After each deploy, by hand | **Static guards to add:** - Calling `arxiv_html.parse` or `Image.open` inside an `async def` fails (extend the existing AST test). - `async with http_client.get_client()` anywhere fails, because it would close the shared pool. - A bare `asyncio.create_task(` in a new module fails unless its result is stored. - `|safe` in any template added after this plan fails. - An `http://` or `https://` URL in `app/static/` or a `