Tests

What devpage's test suite covers, module by module, how the tests are written, and what has no test. It is a reference page under Developing devpage, for someone about to change a module or wondering whether a behaviour is pinned.

$ cargo test                  # 222 tests in the four crates; needs no network and no Chrome
$ cargo test -- --ignored     # the 53 tests that drive Chrome or call GPT-Live

How they are written

cargo test runs every crate in the workspace: 148 in devpage, 66 in the engine devpage-design, 6 in devpage-design-wasm, whose tests run natively, and 2 in devpage-design-module. Tests are written as #[cfg(test)] modules beside the code they test — the canvas's Chrome tests in src/designs/canvas_tests.rs, a child module of designs; the tests/ folder holds only fixtures — tests/fixtures/sync-design, a doc of three chapters that the doc and PDF tests load, and tests/fixtures/narrated-talk, a deck of three slides with notes that the live video test records. Route tests start the real router on a free port on 127.0.0.1 and talk to it with reqwest; external-link tests point the checker at a local web server, so the suite needs no network.

Of the 53 tests marked #[ignore], all drive Chrome, and one of them also calls GPT-Live. All but the two video tests drive chrome-headless-shell through chromiumoxide — the copy devpage pdf downloads into devpage's cache folder, fetched by the first test that needs it — never a Chrome installed on the machine, so a run puts nothing in the macOS Dock. They run in parallel. Run them with --ignored after changing the page script, the design script, the module, the stylesheet, a widget, print mode, devpage pdf or a slide's PNG. The two video tests drive Chrome for Testing instead — the copy devpage video downloads, fetched the same way; run them after changing devpage video or its recorder, assets/video.js. The live one records tests/fixtures/narrated-talk with GPT-Live, which bills per minute, and passes without doing anything unless DEVPAGE_OPENAI_API_KEY is set. The canvas tests and a slide's PNG start it with --enable-unsafe-webgpu and --enable-gpu: the shell keeps its GPU process off without the second, and then a screenshot holds black where a WebGPU canvas is; with it, WebGPU gets the machine's real adapter and the screenshot is the canvas as a reader sees it.

Tests that need files write them into folders under the system temp directory, named with the test process's id, and don't all remove them.

The watcher's tests need file-system events

Nine tests save a file and wait for devpage to hear of it through notify:

Where the platform delivers no events to the test process — notify itself receives nothing, as can happen in some sandboxed or restricted sessions on macOS — those tests fail while everything else passes. That says nothing about the change under test; run them where file events work before calling the suite green.

By module

check

17 tests.

comments

4 tests, 6 in Chrome.

In Chrome:

designs

19 tests, 28 in Chrome.

In Chrome:

document

9 tests.

icons

1 test.

index

4 tests.

main

1 test.

6 tests.

3 tests.

pdf

2 tests, 16 in Chrome.

In Chrome:

render

16 tests.

server

14 tests.

slide_png

1 test in Chrome.

video

19 tests, 2 in Chrome.

In Chrome:

watch

8 tests.

widgets

25 tests.

The design engine's crates

devpage-design

66 tests.

devpage-design-wasm

6 tests.

devpage-design-module

2 tests.

What has no test

syntax highlighting except through the render tests; a canvas reopening its stream after devpage restarts, closing streams in a hidden tab, and drag-to-pan and pinch on the canvas; chrome-headless-shell's and Chrome for Testing's first download (it needs an empty cache folder); GPT-Live on Azure; devpage video stopping on a signal; fullscreen on a deck (headless Chrome refuses it without a real user gesture); and how the light and dark themes look, which is checked by eye.