test: close every remaining coderabbit finding on PR #473
Five new vitest cases plus two refactors that close out the last
batch of CodeRabbit comments on the uninstall PR.
New file: test/codex-manager-uninstall-dispatch.test.ts (F1)
- "forwards a working clearAccounts handler when --clear-accounts
is set" exercises the dispatcher branch in lib/codex-manager.ts
by calling runCodexMultiAuthCli(["uninstall","--clear-accounts"])
with vi.mock-injected runUninstallCommand and storage.clearAccounts;
asserts the storage handler is actually invoked. The flag-only
wiring previously regressed once in this PR's history.
- "forwards a clearAccounts handler regardless of whether the flag
is set" pins the dispatcher contract: deps.clearAccounts is
always present and runUninstallCommand owns the gating.
New file: test/uninstall-ebusy-retry.test.ts (F14)
- vi.mock("node:fs/promises") with a one-shot EBUSY injector
forces a single readFile or rm call to throw EBUSY exactly once.
- Two cases drive runUninstallCommand through its withFileOperationRetry
loop: one for the Codex.json read path, one for the cache
rm path. Both assert exit 0 and no "skipped" warnings, proving
the retry transparently absorbed the transient failure.
test/codex-manager-cli.test.ts (F3)
- "treats a quota cache save failure as a partial-success warning,
not a hard failure" rejects saveQuotaCache once with EBUSY after
account fixes were already persisted, asserts runFix returns 0
and the JSON payload includes quotaCacheSaveError so callers can
surface the cache failure without losing the primary fix.
test/preuninstall.test.ts
- "concurrent invocations leave Codex.json valid and free of
codex-multi-auth" (F11): runs two runPreuninstallCleanup calls
in parallel against the same temp home and asserts the resulting
Codex.json is valid JSON without codex-multi-auth.
- resolveTempPaths refactor (F10): the local helper that duplicated
the platform-specific configBase/cacheBase logic is replaced with
a call to the production resolveInstallPaths so the test cannot
silently drift from real install/uninstall paths.
test/stream-failover.test.ts (F4)
- "does not emit an unhandled rejection if releasing the upstream
reader throws" pins the safety net at lib/request/stream-failover.ts:230.
Wraps an upstream reader so its releaseLock throws, drives the
response through withStreamingFailover, asserts the consumer's
body errors (no hang) and that no unhandled rejection escaped.
Local verification:
- npx tsc --noEmit → clean
- npx vitest run on 8 affected suites → 63/63 (the new files plus
every previously-touched test file).
- npx vitest run test/codex-manager-cli.test.ts -t "quota cache save
failure" → 1/1.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> N
Neil committed
3fa70114bca59d954bda4c20a361e632029b9536
Parent: 86c461b