Skip to content

test: cover the auth menu view-model formatting helpers#573

Merged
ndycode merged 2 commits into
mainfrom
claude/audit-54-auth-menu-builder-tests
Jun 11, 2026
Merged

test: cover the auth menu view-model formatting helpers#573
ndycode merged 2 commits into
mainfrom
claude/audit-54-auth-menu-builder-tests

Conversation

@ndycode

@ndycode ndycode commented Jun 10, 2026

Copy link
Copy Markdown
Owner

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 in lib/. This adds test/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 a v prefix only when missing.
  • formatRelativeTime: the never/today/yesterday/Nd ago/Nw ago buckets and the locale-date fallback beyond a month.
  • accountTitle (the injection guard): identity precedence email > label > id > generic, numbering by quickSwitchNumber over 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 unless highlightCurrentRow is 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 render unknown.
  • formatAccountHint: default field order (Last used | Limits), Status: appears only when the badge column is hidden, configured statuslineFields ordering 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 (sourceIndex over display index — focus survives re-sorting), static actions key on their type.

Validation

  • vitest run test/auth-menu-builder.test.ts — 35/35 passing
  • npm run typecheck — clean
  • npx eslint test/auth-menu-builder.test.ts --max-warnings=0 — clean

https://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 in lib/ui/auth-menu-builder.ts, the last substantive untested module in lib/. all assertions strip ansi before comparing, so they hold across both the v2 and legacy v1 palettes.

  • security coverage: accountTitle injection guard now tests all three identity fields (email, accountLabel, accountId) with hostile CSI sequences, closing the gap noted in the previous review round.
  • v1 palette path: a legacy (v1) palette rendering suite wraps setUiRuntimeOptions({ v2Enabled: false }) in a try/finally to guarantee state restoration, covering statusBadge and formatAccountHint branches that were dead code under the default v2 mode.
  • remaining gap: the accountTitle precedence test exercises each identity field in isolation; it does not verify that email wins when email, accountLabel, and accountId are 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

Filename Overview
test/auth-menu-builder.test.ts new 35-test suite for auth-menu-builder.ts: covers title/version, relative time, identity sanitization on all three fields, search text, row color, status badges, account hints (field order, badge visibility, rate-limit/quota flags, empty output), legacy v1 palette path, and focus key routing — formatDate and currentMarkerLabel gaps from prior review threads are now closed

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]
Loading

Fix All in Codex

Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
test/auth-menu-builder.test.ts:87-95
**identity priority not tested under conflict**

the test name says "prefers email, then label, then id" but every assertion uses only one field at a time. if the `||` chain in `accountTitle` were accidentally reordered (e.g. `accountLabel` before `email`), all four assertions would still pass. adding a case where `email`, `accountLabel`, and `accountId` are all non-empty would actually exercise the declared priority — and would also benefit `accountSearchText` implicitly.

Reviews (2): Last reviewed commit: "test: extend the injection guard and cov..." | Re-trigger Greptile

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
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@ndycode, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: fff014df-9642-4828-8dc2-92e4ca0f35c0

📥 Commits

Reviewing files that changed from the base of the PR and between b566656 and a9c60c0.

📒 Files selected for processing (1)
  • test/auth-menu-builder.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/audit-54-auth-menu-builder-tests
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch claude/audit-54-auth-menu-builder-tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Comment thread test/auth-menu-builder.test.ts
Comment thread test/auth-menu-builder.test.ts
Comment thread test/auth-menu-builder.test.ts Outdated
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
@ndycode ndycode merged commit 71a8df4 into main Jun 11, 2026
2 checks passed
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.

2 participants