Skip to content

test: cover dashboard settings clone defaults and equality semantics#569

Merged
ndycode merged 2 commits into
mainfrom
claude/audit-50-dashboard-settings-data-tests
Jun 11, 2026
Merged

test: cover dashboard settings clone defaults and equality semantics#569
ndycode merged 2 commits into
mainfrom
claude/audit-50-dashboard-settings-data-tests

Conversation

@ndycode

@ndycode ndycode commented Jun 10, 2026

Copy link
Copy Markdown
Owner

Summary

Ninth suite in the direct-coverage wave (siblings: #559#561, #563#567; all independent, based on main). lib/codex-manager/dashboard-settings-data.ts is the clone/equality contract the settings hub uses to decide whether a settings edit is dirty and what to persist — wrong defaults here silently rewrite user settings. It had no direct tests. This adds test/dashboard-settings-data.test.ts (7 tests).

The deps are the real resolveMenuLayoutMode plus a normalizer matching the dashboard-settings default semantics, so the layout-derivation behavior under test is the production one.

What the tests pin

cloneDashboardSettingsData:

  • A sparse legacy settings object (an old settings.json predating the optional fields) clones with every optional field at its documented default, while the required flags pass through unchanged.
  • The layout mode and menuShowDetailsForUnselectedRows are derived together, and an explicit menuLayoutMode wins over the legacy boolean.
  • The statusline fields are copied, not aliased — mutating the input array cannot leak into the clone.

dashboardSettingsDataEqual:

  • Absent optional fields compare equal to their defaults (a sparse object equals its own clone, and equals a fully-defaulted object when the required flags agree).
  • Any single-field difference (TTL, theme, a required flag) flips the result.
  • Layout is compared through the resolver: the legacy boolean spelling of expanded-rows equals the explicit mode spelling.
  • Statusline fields are compared through the normalizer: absent equals the default list, but a different field order is a real difference.

Validation

  • vitest run test/dashboard-settings-data.test.ts — 7/7 passing
  • npm run typecheck — clean
  • npx eslint test/dashboard-settings-data.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/dashboard-settings-data.test.ts — the first direct test suite for cloneDashboardSettingsData and dashboardSettingsDataEqual, covering sparse-input defaults, layout/unselected-rows co-derivation, statusline array copy semantics, and 18 single-field equality cases using the real resolveMenuLayoutMode dep.

  • clone defaults: pins all 21 optional fields via toMatchObject, verifies required flags pass through, and confirms the statusline array is copied (not aliased).
  • equality coverage: 18 it.each entries exercise most comparison branches; layout resolution is tested through the resolver; statusline normalizer injection is validated for both absent-equals-default and order-sensitive cases.
  • type issue: one entry uses uiThemePreset: "mono", which is outside DashboardThemePreset = "green" | "blue" and would fail tsc if test files are included in the typecheck config; "blue" is the correct in-union alternative.

Confidence Score: 5/5

test-only addition with no changes to production code; safe to merge.

the change is a new test file that exercises pure, side-effect-free functions against their real deps — no production logic, no i/o, no concurrency. the one out-of-union value ("mono") is a test-quality nit that does not affect production behavior or ci correctness on the current typecheck config.

test/dashboard-settings-data.test.ts — the out-of-union uiThemePreset: "mono" entry is worth fixing before any typecheck config change widens coverage to include test files.

Important Files Changed

Filename Overview
test/dashboard-settings-data.test.ts new 7-test suite for cloneDashboardSettingsData and dashboardSettingsDataEqual; uses real resolveMenuLayoutMode dep; one out-of-type value in the equality it.each ("mono" not in DashboardThemePreset = "green"

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[SPARSE / settings helper] --> B[cloneDashboardSettingsData]
    A --> C[dashboardSettingsDataEqual]

    B --> D{resolveMenuLayoutMode}
    D -->|expanded-rows| E[menuLayoutMode + menuShowDetailsForUnselectedRows=true]
    D -->|compact-details| F[menuLayoutMode + menuShowDetailsForUnselectedRows=false]
    B --> G[normalizeStatuslineFields → spread copy]
    B --> H[optional fields ?? documented defaults]

    C --> I{resolveMenuLayoutMode left == right?}
    I -->|yes| J[compare 22 other fields with ?? defaults]
    I -->|no| K[return false]
    C --> L{normalizeStatuslineFields JSON.stringify ==?}
    L -->|yes| M[fields equal]
    L -->|no| N[return false]

    subgraph Tests
        T1[fills every optional field with its default]
        T2[derives layout mode and unselected-rows flag together]
        T3[copies statusline array not alias]
        T4[absent fields equal their defaults]
        T5[18 x it.each single-field difference]
        T6[compares layout through resolver]
        T7[compares statusline through normalizer]
    end
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/dashboard-settings-data.test.ts:131
`"mono"` is not a member of `DashboardThemePreset = "green" | "blue"`, so this entry violates the `satisfies Partial<DashboardDisplaySettings>` constraint and would fail any `tsc` invocation that covers test files. Using `"blue"` is an in-union value that still detects a genuine difference from the default `"green"` and keeps the test type-safe.

```suggestion
		["uiThemePreset", { uiThemePreset: "blue" }],
```

Reviews (2): Last reviewed commit: "test: pin the badge defaults and sweep e..." | Re-trigger Greptile

Drives cloneDashboardSettingsData/dashboardSettingsDataEqual with the
real resolveMenuLayoutMode and a normalizer matching the
dashboard-settings default semantics:

- a sparse legacy settings object clones with every optional field at
  its documented default, statusline fields copied (not aliased), and
  the layout mode + unselected-rows flag derived together with an
  explicit menuLayoutMode winning over the legacy boolean
- equality treats absent optional fields as their defaults, flags any
  single-field difference, compares layout through the resolver (the
  legacy boolean spelling equals the explicit expanded-rows mode), and
  compares statusline fields through the normalizer with order being
  significant

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 21 minutes and 14 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: d8099547-b4fe-4c87-8ec8-7e7d79e126a0

📥 Commits

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

📒 Files selected for processing (1)
  • test/dashboard-settings-data.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/audit-50-dashboard-settings-data-tests
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch claude/audit-50-dashboard-settings-data-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/dashboard-settings-data.test.ts
Comment thread test/dashboard-settings-data.test.ts Outdated
Add the four badge fields to the clone-defaults contract and convert
the single-field equality check into an it.each sweep over the
independent comparisons (sort, badge, action, theme, and TTL fields).

https://claude.ai/code/session_01XNtnkLbBiXZxfQQYLMpucB
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