test(maestro): give the SPA a test runner and a reachable pure core
The browser app had no tests and no way to run any: package.json shipped dev/build/preview/typecheck, and CI installed Node and pnpm but never ran anything with them. Its densest logic was module-private, so even with a runner none of it was reachable. Extracts four pure modules out of DOM-heavy ones — tree.ts (directory grouping), keys.ts (terminal escape encoding), paths.ts (completion arithmetic), html.ts (one escaper, replacing four copies). Extraction rather than `export` because attach.ts imports xterm's CSS at module level, which a node test cannot load. CatalogStore takes an injectable socket factory, scheduler and refetch, so the reducer and the backoff schedule run without a server. snapshot() now returns a copy: it returned the live object while events mutated it in place, so listeners could not diff and every event rebuilt the whole tree. 36 tests across 6 files, and a `web` CI job running typecheck, test and build. vitest is pinned to 2.x — 4.x requires vite >= 6 and this is vite 5. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit was merged in pull request #44.
This commit is contained in:
co-authored by
Claude Opus 5
parent
db44650a17
commit
031c80a40b
@@ -52,3 +52,29 @@ jobs:
|
||||
|
||||
- name: test
|
||||
run: cargo test --all
|
||||
|
||||
web:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install Node.js + pnpm
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get install -y --no-install-recommends curl ca-certificates
|
||||
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
|
||||
apt-get install -y --no-install-recommends nodejs
|
||||
corepack enable
|
||||
corepack prepare pnpm@9.15.4 --activate
|
||||
|
||||
- name: Install deps
|
||||
run: pnpm -C web install --frozen-lockfile
|
||||
|
||||
- name: typecheck
|
||||
run: pnpm -C web typecheck
|
||||
|
||||
- name: test
|
||||
run: pnpm -C web test
|
||||
|
||||
- name: build
|
||||
run: pnpm -C web build
|
||||
|
||||
Reference in New Issue
Block a user