test: cover the auth menu view-model formatting helpers#573
Conversation
Direct coverage for lib/ui/auth-menu-builder.ts (the last substantive untested module in lib/), asserting text content with ANSI stripped so the contract holds in both UI palettes: - main-menu title version suffix with the v prefix added only when missing, env save/restored - relative-time buckets (never/today/yesterday/Nd/Nw/locale date) - account titles prefer email > label > id > generic, number by quickSwitchNumber, and strip ANSI escapes and control characters from identity fields so a hostile label cannot repaint the row - search text joins lowercased identity fields plus the row number - row colors highlight the current row unless disabled, then map by status; status badges carry their status label, unknown fallback - hint lines: default field order, Status only when the badge column is hidden, configured statusline field ordering, rate-limited and quota-exhausted flags, empty when every field is hidden - focus keys use the storage position for account actions and the action type for static rows 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 26 minutes and 5 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 |
From review: the ANSI/control-character strip is now asserted on email and accountId too (not just accountLabel), formatDate gets its unknown and locale-date cases, and a legacy-palette block renders badges and hints with v2 disabled (setUiRuntimeOptions, restored in finally) so the v1 branches are no longer dead from the suite's perspective. https://claude.ai/code/session_01XNtnkLbBiXZxfQQYLMpucB
Summary
Thirteenth suite in the direct-coverage wave (siblings: #559–#561, #563–#567, #569–#572; all independent, based on
main).lib/ui/auth-menu-builder.ts(445 lines) builds the auth dashboard's row titles, badges, colors, hints, and focus keys — it was the last substantive untested module inlib/. This addstest/auth-menu-builder.test.ts(35 tests).The suite asserts text content with ANSI stripped, so the contracts hold in both the legacy and v2 UI palettes, and the version env var is saved/restored.
What the tests pin
mainMenuTitleWithVersion: bare title without the env var; the version suffix gets avprefix only when missing.formatRelativeTime: the never/today/yesterday/Nd ago/Nw agobuckets and the locale-date fallback beyond a month.accountTitle(the injection guard): identity precedence email > label > id > generic, numbering byquickSwitchNumberover the display index, and — the security-relevant bit — ANSI escapes and control characters are stripped from identity fields so a hostile account label cannot repaint the menu row.accountSearchText: lowercased identity fields joined with the row number.accountRowColor: the current row highlights green unlesshighlightCurrentRowis disabled (then the status color wins); the ok/limited/flagged tone mapping with the unknown fallback.statusBadge: every status renders its own label; missing statuses renderunknown.formatAccountHint: default field order (Last used | Limits),Status:appears only when the badge column is hidden, configuredstatuslineFieldsordering is respected, rate-limited/quota-exhausted flags surface in the limits segment (with the quota bar and reset countdown), and hiding every field yields an empty string.authMenuFocusKey: account actions key on the storage position (sourceIndexover display index — focus survives re-sorting), static actions key on their type.Validation
vitest run test/auth-menu-builder.test.ts— 35/35 passingnpm run typecheck— cleannpx eslint test/auth-menu-builder.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/auth-menu-builder.test.ts— 35 tests that pin the text-content contracts for every exported formatting helper inlib/ui/auth-menu-builder.ts, the last substantive untested module inlib/. all assertions strip ansi before comparing, so they hold across both the v2 and legacy v1 palettes.accountTitleinjection guard now tests all three identity fields (email,accountLabel,accountId) with hostile CSI sequences, closing the gap noted in the previous review round.legacy (v1) palette renderingsuite wrapssetUiRuntimeOptions({ v2Enabled: false })in atry/finallyto guarantee state restoration, coveringstatusBadgeandformatAccountHintbranches that were dead code under the default v2 mode.accountTitleprecedence test exercises each identity field in isolation; it does not verify thatemailwins whenemail,accountLabel, andaccountIdare all simultaneously non-empty — a multi-field assertion would make the declared priority enforceable by the test.Confidence Score: 5/5
test-only addition with no production code changes; all 35 tests pass, typecheck is clean, and the suite correctly isolates shared state (env var and ui runtime options) via beforeEach/afterEach and try/finally.
the change is a pure test file. it touches no auth logic, no storage paths, no token handling, and no windows filesystem code. state isolation is handled correctly: the env var is saved/restored at the top level and the v1 runtime option override is wrapped in try/finally. the only notable gap is the identity-priority test not exercising multi-field conflict, which does not affect production correctness.
no files require special attention
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[auth-menu-builder.test.ts] --> B[mainMenuTitleWithVersion] A --> C[formatRelativeTime] A --> D[accountTitle] A --> E[accountSearchText] A --> F[accountRowColor] A --> G[statusBadge] A --> H[formatDate] A --> I[currentMarkerLabel] A --> J[formatAccountHint] A --> K[legacy v1 palette] A --> L[authMenuFocusKey] B --> B1[bare title / v prefix] C --> C1[never/today/yesterday/Nd/Nw/locale] D --> D1[email > label > id > generic] D --> D2[quickSwitchNumber numbering] D --> D3[ANSI injection guard all 3 fields] E --> E1[lowercased join + row number] F --> F1[isCurrentAccount + highlightCurrentRow] F --> F2[status tone mapping] G --> G1[all 8 statuses + unknown] J --> J1[default field order] J --> J2[badge visibility toggle] J --> J3[statuslineFields ordering] J --> J4[rate-limited / quota-exhausted flags] J --> J5[empty string when all hidden] K --> K1[statusBadge v1 labels] K --> K2[formatAccountHint v1 text] L --> L1[account actions keyed by sourceIndex] L --> L2[static actions keyed by type]Prompt To Fix All With AI
Reviews (2): Last reviewed commit: "test: extend the injection guard and cov..." | Re-trigger Greptile