test: cover login-menu data layer targeting, view model, and drift sync - #563
Conversation
Direct coverage for the three untested login-menu-data.ts exports (refreshQuotaCacheForMenu already has its own suite): - countMenuQuotaRefreshTargets: counts enabled accounts with usable tokens and stale/missing cache entries; skips disabled accounts, soon-to-expire tokens, fresh entries, and accounts whose probe result could not be stored behind a safe lookup key (duplicate accountIds without an email fallback) - toExistingAccountInfo: status mapping (active/disabled/cooldown/ quota-exhausted/rate-limited/ok), ready-first ordering with display reindexing and sourceIndex preservation, quick-switch numbering in both visible-row and storage-position modes, and source order when sorting is disabled - syncCodexCliActiveSelectionIfDrifted: no-ops on matching accountId, missing CLI state, sanitized-email match, read failures, and empty pools; rewrites the CLI selection with the active account's credentials on real drift https://claude.ai/code/session_01XNtnkLbBiXZxfQQYLMpucB
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Warning Review limit reached
More reviews will be available in 11 minutes and 42 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Add the loadRuntimeCurrentSelectionForStorage describe block (all three signals threaded into resolveRuntimeCurrentAccount, the non-running router dropped to null, and failing signal sources degraded to absent instead of throwing) plus the writer-false case so a skipped CLI write propagates as false from syncCodexCliActiveSelectionIfDrifted. https://claude.ai/code/session_01XNtnkLbBiXZxfQQYLMpucB
Summary
Fourth suite in the direct-coverage push for the login machinery (siblings: #559, #560, #561; all independent, based on
main).lib/codex-manager/login-menu-data.tshad direct tests only forrefreshQuotaCacheForMenu; its other three exports — the quota probe targeting, the dashboard view model, and the Codex CLI drift sync — were exercised only through the interactive menu. This addstest/login-menu-data.test.ts(15 tests).countMenuQuotaRefreshTargetsandtoExistingAccountInforun with no mocks at all (pure given storage/cache/settings fixtures); onlyloadCodexCliStateandsetCodexCliActiveSelectionare mocked for the drift-sync tests.What the tests pin
countMenuQuotaRefreshTargets(decides which accounts the menu probes):toExistingAccountInfo(the dashboard row view model):indexbecomes the display position whilesourceIndexstill points into storage;isDefaultAccountsurvives reordering.menuSortQuickSwitchVisibleRow: false).syncCodexCliActiveSelectionIfDrifted(repairsauth.jsondrift):{ forceRefresh: true }read.Validation
vitest run test/login-menu-data.test.ts— 15/15 passingnpm run typecheck— cleannpx eslint test/login-menu-data.test.ts --max-warnings=0— cleanhttps://claude.ai/code/session_01XNtnkLbBiXZxfQQYLMpucB
Generated by Claude Code
note: greptile review for oc-chatgpt-multi-auth. cite files like
lib/foo.ts:123. confirm regression tests + windows concurrency/token redaction coverage.Greptile Summary
adds
test/login-menu-data.test.ts, providing direct vitest coverage for four of the five exports inlib/codex-manager/login-menu-data.ts. the previous review feedback was addressed in this revision: both the writer-false propagation path and theloadRuntimeCurrentSelectionForStoragedescribe block are now included.countMenuQuotaRefreshTargets(5 tests): verifies disabled-account skipping, token-freshness window, stale-cache counting, and the duplicate-accountId / no-email-fallback safety gate that prevents unattributable probe snapshots.toExistingAccountInfo(4 tests): pins status mapping for all six states, ready-first sort + display/storage index renumbering, quick-switch numbering in both visible-row and storage-position modes, and sort-disabled source-order preservation.syncCodexCliActiveSelectionIfDrifted(7 tests): covers match-by-id no-op, null-state no-op, accountId drift rewrite, writer-false propagation (windowsEBUSYpath), sanitized-email match, read-throws no-op, and empty-pool early exit.loadRuntimeCurrentSelectionForStorage(3 tests): verifies all three runtime signals are threaded to the resolver, app-bind null-passthrough when router is not running, andPromise.allerror swallowing to null for both signal sources.Confidence Score: 5/5
test-only addition with no production code changes; safe to merge
the suite is a pure test addition with no changes to production code. all assertions were verified against the source: status ordering, index/sourceIndex renumbering, quick-switch numbering, drift-sync branching, and the Promise.all error-swallowing paths all match the implementation. both concerns from the previous review round are addressed — the writer-false propagation test and the loadRuntimeCurrentSelectionForStorage describe block are present.
no files require special attention
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[syncCodexCliActiveSelectionIfDrifted] --> B{activeIndex valid\nand accounts non-empty?} B -- no --> C[return false] B -- yes --> D[loadCodexCliState\nforceRefresh: true] D -- throws --> C D -- null --> C D -- state --> E{accountId present\non both sides?} E -- yes --> F{accountIds match?} F -- yes --> C F -- no --> I[setCodexCliActiveSelection\nwith active account creds] E -- no --> G{emails present\non both sides?} G -- yes --> H{sanitized emails match?} H -- yes --> C H -- no --> I G -- no --> I I --> J[return writer result\ntrue = written, false = skipped/EBUSY]Reviews (2): Last reviewed commit: "test: cover runtime selection loading an..." | Re-trigger Greptile