Skip to content

test: stop two tests failing on timing and megapixels - #1526

Merged
thymikee merged 1 commit into
mainfrom
flaky/poll-count-and-png-fixture
Jul 31, 2026
Merged

test: stop two tests failing on timing and megapixels#1526
thymikee merged 1 commit into
mainfrom
flaky/poll-count-and-png-fixture

Conversation

@thymikee

Copy link
Copy Markdown
Member

Two tests blocked unrelated PRs today. Neither is auto-retryable: #1419's contention retry declines find.test.ts as outside its enumerated list, and slow-gate failures cannot be re-checked by a rerun. Every occurrence costs someone a manual re-run.

find.test.ts — an un-assertable poll count

wait captures fresh snapshots while polling asserted exactly 2 dispatches.

The wait loop polls at a 300 ms interval against a 350 ms budget, and its final sleep consumes whatever remains — so it lands on exactly remainingMs() === 0. A sleep that returns even a millisecond early makes hasTimeRemaining() true and admits a third poll. The count was never assertable; it just usually came out at 2.

The test's actual subject is that each poll re-captures rather than reusing the first tree. It now asserts that directly: at least two captures, and every one a snapshot.

The sibling exact-count assertion earlier in the file is deliberately left alone — it takes its count from mockResolvedValueOnce ordering (the match appears in the second tree), not from the clock, so it is deterministic.

apps.test.ts — 3.2 megapixels to prove a ratio

Two tests built 1206×2622 source PNGs (iPhone 16 Pro native) purely to verify rescale arithmetic. Both are now 126×273 — still divisible by 3, so the /3 and 2/3 rescales stay exact — with expectations updated to match.

Measured locally:

test before after
keeps requested simulator pixel density 1021 ms 34 ms
retries simulator capture timeouts 1176 ms 233 ms
file test time 2.48 s 1.00 s

Verification

18/18 find.test.ts, 54/54 apps.test.ts. Typecheck, lint and oxfmt clean.

Neither change weakens what the tests cover: the polling test still proves fresh captures, and both rescale tests still assert exact output dimensions.


Generated by Claude Code

Both of these blocked unrelated PRs today and neither is auto-retryable:
#1419's contention retry declines find.test.ts as outside its enumerated
list, and slow-gate failures cannot be re-checked by a rerun. Each
occurrence costs a manual re-run.

find.test.ts 'wait captures fresh snapshots while polling' asserted exactly
2 dispatches. The wait loop polls at a 300ms interval against a 350ms
budget, and its last sleep consumes whatever remains, so it lands exactly on
remainingMs() === 0 — a sleep returning a millisecond early admits a third
poll. The count was never assertable. The test's actual subject is that each
poll re-captures instead of reusing the first tree, so it now asserts that:
at least two captures, every one a snapshot.

The sibling assertion at the top of the file is left alone: it takes its
count from mockResolvedValueOnce ordering, not from the clock.

apps.test.ts built 1206x2622 (iPhone 16 Pro, 3.2 megapixels) source PNGs to
prove two rescale ratios. Both sources are now 126x273 — still divisible by
3, so the /3 and 2/3 arithmetic stays exact — with expectations updated to
match. Measured on this machine: the density test 1021ms -> 34ms, the retry
test 1176ms -> 233ms, the file's test time 2.48s -> 1.00s.

Both suites pass: 18/18 find, 54/54 apps.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RXQLYV7etZx3gcXsUsrQJ8
@github-actions

Copy link
Copy Markdown

Size Report

Metric Base Current Diff
JS raw 1.91 MB 1.91 MB +72 B
JS gzip 613.3 kB 613.3 kB +88 B
npm tarball 731.3 kB 731.0 kB -328 B
npm unpacked 2.57 MB 2.56 MB -2.9 kB

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 27.4 ms 26.1 ms -1.3 ms
CLI --help 57.7 ms 56.4 ms -1.3 ms

Top changed chunks:

Chunk Raw diff Gzip diff
dist/src/ime-lifecycle.js +512 B +234 B
dist/src/session.js 0 B +2 B
dist/src/internal/daemon.js +2 B +1 B

@thymikee

Copy link
Copy Markdown
Member Author

Clean review at exact head efc7a746e388ba1d1a0f9725121b10c58620bbcc. The find timeout regression now asserts the actual contract—at least two polls and every poll dispatching a fresh snapshot—without pinning scheduler-dependent timing. The screenshot fixtures retain exact scale-3 arithmetic (42×91 and 84×182) plus retry/count coverage while avoiding multi-megapixel allocations. All exact-head checks and platform smokes are green; no live-device evidence is needed for this deterministic test-only change. Ready for human merge.

Residual risk: no separately authorized cross-vendor review was performed.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Jul 31, 2026
@thymikee
thymikee merged commit 4c1d62e into main Jul 31, 2026
30 checks passed
@thymikee
thymikee deleted the flaky/poll-count-and-png-fixture branch July 31, 2026 14:16
@github-actions

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-07-31 14:16 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants