# Testing

LLMS index: [llms.txt](/docs/llms.txt)

---

```sh
make test               # Rust decoder + Python encoder + web unit tests
make test-rust          # regenerates the golden fixture, then cargo test
make encoder-rust-test  # native encoder unit tests + byte-identity golden (needs GDAL, libclang)
make test-e2e           # Playwright (needs `npx playwright install chromium`)
wasm-pack test --headless --chrome rust/xue-wasm   # the decoder in a real browser
```

Single tests:

```sh
.venv/bin/python -m unittest tests.test_bin -v
.venv/bin/python -m unittest tests.test_bin.SomeCase.test_method
cd rust && cargo test -p xue golden
npx vitest run tests/web/manifest.test.ts
npx playwright test tests/e2e/app.spec.ts -g "scrub"
```

## What holds what

- **Python** (`tests/test_*.py`): codebooks, modulo-256 residuals, the
  container writer's bytes and the bundle metadata validator, the manifest
  and pointer contracts, every source's crop fixture through both encoders,
  the Zarr store writer and reader, the STAC documents and the point
  products against committed goldens. A source test builds what
  production publishes, the shared stores, and reads its bundles back out
  of them (`tests._support.stored_bundle`); a test that has to read a
  `.xue` opens it with the wheel's decoder (`xue.Bundle`), the only
  container reader on the Python side.
- **Encoder parity**: `tests/test_native.py` and every source test compare
  every artifact of one build through the `xuepy` wheel against the
  reference pipeline, byte for byte: the shared stores, the manifest and
  the pointer. One case, `NativeContainerParityTests`, builds with the
  container too (`--xue`) and holds the `.xue` bytes of both encoders to
  each other. `tests/test_assemble.py` holds a split build and a top-up
  identical to a whole one.
- **Rust**: `rust/xue/tests/golden.rs` decodes the containers
  `tests/prepare_bin_fixture.py` writes to the codes they were written
  from (read back out of the shared store by the NumPy reader), plus the
  container rejection paths and mutation fuzzing.
- **Registry snapshots** (`rust/xue/registry.json`, the shell's
  `web/src/data/registry.ts`) hold the three implementations to one set of ids,
  identities and codebooks; `tests/test_registry.py` fails until
  `xue registry --output rust/xue/registry.json --shell web/src/data/registry.ts`
  regenerates them.
- **Web** (`tests/web/`, Vitest): manifest validation, the Zarr reader
  (every frame and series identical to the wasm bundle reader), the
  variable table, URL state, discovery files.
- **Browser** (`tests/e2e/`, Playwright): synthetic fixtures built by
  `tests/prepare_web_fixture.py` (no network, no GDAL); download,
  streaming, playback, scrubbing, error recovery, and the store-only path.

Fixture provenance and regeneration are in
[`tests/fixtures/README.md`](../../tests/fixtures/README.md). Goldens are
regenerated by the `tests/prepare_*_golden.py` scripts after a deliberate
change (the tc and sounding ones need `bufr_dump`).

## CI

`.github/workflows/test.yml` runs the Python (3.14), Rust, web
and browser jobs on every push and pull request except prose-only changes
(`**.md`, `docs/**`). On `release/**` branches the Python job builds the
wheel from the tree instead of installing PyPI's, since the encoders there
run ahead of the published wheel (see [releasing](releasing.md)). The Rust
job also runs `make encoder-rust-test` on every run: plain `cargo test`
leaves the `encoder` feature off, so the native encoder's unit tests and
its golden run only there. The web job, after `npm run build`, holds the
viewer's first-load JavaScript to `web/tooling/size-budget.json`
(`node web/tooling/entrysize.ts`; see
[frontend](frontend.md#first-load)).
