test: cover dashboard settings clone defaults and equality semantics#569
Conversation
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
|
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 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 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 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
Summary
Ninth suite in the direct-coverage wave (siblings: #559–#561, #563–#567; all independent, based on
main).lib/codex-manager/dashboard-settings-data.tsis 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 addstest/dashboard-settings-data.test.ts(7 tests).The deps are the real
resolveMenuLayoutModeplus a normalizer matching the dashboard-settings default semantics, so the layout-derivation behavior under test is the production one.What the tests pin
cloneDashboardSettingsData:settings.jsonpredating the optional fields) clones with every optional field at its documented default, while the required flags pass through unchanged.menuShowDetailsForUnselectedRowsare derived together, and an explicitmenuLayoutModewins over the legacy boolean.dashboardSettingsDataEqual:Validation
vitest run test/dashboard-settings-data.test.ts— 7/7 passingnpm run typecheck— cleannpx eslint test/dashboard-settings-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/dashboard-settings-data.test.ts— the first direct test suite forcloneDashboardSettingsDataanddashboardSettingsDataEqual, covering sparse-input defaults, layout/unselected-rows co-derivation, statusline array copy semantics, and 18 single-field equality cases using the realresolveMenuLayoutModedep.toMatchObject, verifies required flags pass through, and confirms the statusline array is copied (not aliased).it.eachentries 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.uiThemePreset: "mono", which is outsideDashboardThemePreset = "green" | "blue"and would failtscif 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
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] endPrompt To Fix All With AI
Reviews (2): Last reviewed commit: "test: pin the badge defaults and sweep e..." | Re-trigger Greptile