Skip to content

Test through the seams, and run the suite in 10s - #18

Merged
ericchernuka merged 5 commits into
masterfrom
ec/tests-through-seams
Nov 10, 2026
Merged

ericchernuka merged 5 commits into
masterfrom
ec/tests-through-seams

Conversation

@ericchernuka

Copy link
Copy Markdown
Owner

Summary

Tests now go through the parts a person or agent uses, so the code behind them can change without the tests breaking.

 src/picker/
 ├── agent/__tests__/
-│   ├── requests.test.ts       # called resolveChoice, squaresOf directly
 │   └── tools.test.tsx         # every case through agent.call(...)
 ├── color-card/__tests__/
 │   └── ColorCard.test.tsx     # reads the real clipboard
 └── hue-dial/__tests__/
-    ├── inertia.test.ts        # checked the sample buffer
     ├── motion.test.ts         # events in, commits + shown hue out
+    ├── script.ts              # event helpers for motion.test.ts
     ├── HueDial.test.tsx       # ring, keys, stepper
+    └── Wheel.test.tsx         # phone wheel coasts, run in parallel

What changed in how tests check things:

 motion.test.ts
-  expect(motion.kind).toBe('landing')
+  expect(commits).toEqual([commit]); expect(shown(motion)).toBe(commit.hue)
 HueDial.test.tsx
-  expect(views).toHaveLength(2)       // analytics as a stand-in for history
+  expect(history.length).toBe(2)
 ColorCard.test.tsx
-  expect(writeText).toHaveBeenCalledWith('#4998BF')
+  await expect.poll(() => navigator.clipboard.readText()).toBe('#4998BF')

The phone wheel tests used to sleep 2.6s each, one after another. A gentler flick now coasts for about 1.1s, and the tests that interrupt a coast wait 1.5s. A guard test fails if an uninterrupted coast takes longer than that, so a future change to friction can't make the waits too short without anyone noticing.

Evidence

  • Before: pnpm test took 16.0s for 135 tests. 13s of that was five coast tests run in series.
    After: pnpm test took 10.2s for 131 tests, the same on 3 runs. pnpm check passed 3 times in a row at 10.4s.

Before trusting the rewritten tests, I broke the code on purpose. Each break below failed its test:

inertia: no 80ms window           -> "slows for the last stretch" fails
inertia: no stale-release check   -> "pauses before lifting" fails
inertia: no minimum flick speed   -> "drags slowly" fails
inertia: less friction            -> "coasts forward about 200°" fails
motion: Back keeps a scroll       -> "given a scroll, when Back" fails
motion: Back keeps a coast        -> Wheel "Back holds" fails
motion: pick/step keep the coast  -> Wheel "only history entry" fails
motion: no catching a coast       -> "catches the wheel" fails
requests: tie-break on rounded    -> "same tenth" fails
Copy: writes lower-case hex       -> "value is on the clipboard" fails

Merge Danger

Door: two-way

Only tests changed. Nothing in src/ outside __tests__/ changed.

Blast Radius: tests

The wheel tests depend on timing. If CI machines drop animation frames, the guard test is the one that fails, and the fix is to raise COAST_REST_MS.

The reducer tests checked state names like 'landing' and built coasting
states by hand, so renaming a state broke them. They now send real events
and read only the commits, the shown hue and the free turn. The flick cases
from inertia.test.ts move here as finger events, and that file goes.
requests.test.ts called resolveChoice and squaresOf directly, and its
malformed-input case passed on any error text. Each case now goes through
agent.call, checks the notes or the reason, and checks that a refused call
adds no history entry. list_squares gets its first test through the tool.
The config already grants clipboard access, so Copy tests read what landed
there. The tick check looks inside the Copy button and is shown passing as
well as failing. Only the refusal case still stubs writeText, restored after
each test.
The link tests already open all 72 hues and reject the ones off the grid.
The ring tests counted analytics page views as a stand-in for history
entries. They now read history.length.

The coast tests each slept 2.6s, in series, and set the pace of the whole
suite. They move to Wheel.test.tsx, which runs beside the ring tests, and
use a gentler flick that coasts about 1.1s. A guard test fails if a coast
outlasts the 1.5s the others wait. The suite drops from about 16s to 10s.
@vercel

vercel Bot commented Nov 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
huebo Ready Ready Preview Nov 10, 2026 3:59am UTC

@ericchernuka
ericchernuka merged commit 61b8c2b into master Nov 10, 2026
3 checks passed
@ericchernuka
ericchernuka deleted the ec/tests-through-seams branch November 12, 2026 04:01

This branch was successfully deployed

1 active deployment
Preview — 9440f14b Deployed Nov 10, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant