mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-11-10 04:46:07 -08:00
* refactor(main): move first-run setup into an assembly * refactor(main): move playback and subtitle pipeline state into an assembly Moves the mpv runtime composer wiring together with the subtitle processing, prefetch, sidebar playback-state, seek-intent, secondary-subtitle and autoplay-priming state it mutates into createPlaybackAssembly. Replaces the main-wiring regex tests for the moved code with behaviour tests that drive real mpv events through a fake client. * refactor(main): move overlay windows and visibility into an assembly * refactor(main): read Electron screen lazily in the overlay assembly deps * docs: describe overlay, playback, and first-run setup assemblies * test(playback): clear scheduled prefetch refresh in warm-tokenization tests
2.5 KiB
2.5 KiB
Testing Guidelines
Status: active
Last verified: 2026-10-04
Owner: Kyle Yasuda
Read when: adding or changing tests
Which lanes to run lives in Verification. This page covers what a good test looks like here.
Test Behavior, Not Wiring
- Exercise a module through its public interface and assert outcomes: return values, resulting state, files written, rows in sqlite, messages sent to a fake process.
- Prefer real collaborators that are cheap: tmp dirs, in-memory or tmp sqlite, fake executables, pure parsers. Fake only the edges (Electron, mpv socket, network).
- Assert call order only when order is the behavior (startup sequencing, ABA races), and then assert relative order, not the whole call log.
Do Not Write
- Pass-through tests: a handler or adapter that only forwards deps
(
*-runtime-handlers.ts) needs no test. TypeScript already checks the shape. - Source-text tests: reading
.ts,.css,.html,.lua,.swift, or workflow YAML and asserting with regexes. If the invariant matters, extract the logic and run it (seesrc/preload-ipc-listeners.ts). Policy lints over workflow YAML are the exception and belong in one parsed-YAML check. - "Stays deleted" tests for removed modules, flags, or selectors.
tscand review catch reintroduction. - Tests that restate constants, defaults, labels, or window options.
- The same rule at several layers. Test a rule once where it lives; keep one end-to-end case (for the tokenizer, the golden corpus) for integration.
Keep Tests Small
- Shared setup goes in a
makeDeps(overrides)helper or a*-test-harness.tsfile, not pasted into every test. - Near-identical cases become a table:
for (const c of cases) test(c.name, ...). - Inject timers, clocks, and loggers instead of patching globals or private members.
- A bug fix gets a regression test for the behavior that broke, named after the behavior, not the ticket.
Known Debt
src/main/main-wiring.test.tsandsrc/renderer/renderer-init-order.test.tsstill regexmain.ts/renderer.tsto guard startup ordering. Replace each test with a behavioral one as the logic moves out ofmain.tsclosures.src/main/runtime/overlay-geometry-runtime.tsandsrc/main/runtime/visible-overlay-interaction-runtime.tsvalue-import Electron, so they cannot load underbun testand stay outsidesrc/main/assemblies/overlay.ts. Injectscreen/dialogto make them testable and movable.