Cover the personality settings write paths - #979
Merged
Conversation
PersonalitySettings had no coverage at all — no test sibling, no e2e reference, and its only caller (settings-pane.tsx) is untested — while owning four write paths against /api/v1/personalities. The new suite mocks only the HTTP seam; every row, form, radio toggle and error banner is the real component. It pins create (trimmed name, read-after-write refresh), in-place edit and PATCH-by-id, the optimistic active toggle with its revert-on-failure, delete behind window.confirm, the two pre-write validation guards, the submit lock that stops a double-post, and the error banner's lifecycle across all of them. Active state is asserted through aria-pressed/aria-label rather than Tailwind classes, so a restyle cannot break it and a broken affordance cannot pass. The framer-motion mock caches its component per tag: an uncached proxy hands React a fresh type on every render, remounting the list and silently detaching held elements. 50 mutants run against personality-settings.tsx; the only survivor is the `personalities.length === 0` half of the loading guard, which is unobservable because loading is never set back to true after the first refresh. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Uh oh!
There was an error while loading. Please reload this page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
PersonalitySettings(399 lines) had zero coverage — no test sibling, no e2e reference, and its only callersettings-pane.tsxis untested — while owning four write paths against/api/v1/personalities. It was the top-ranked gap carried in the test-enforcer brain state.What
One new file,
apps/web/src/components/app/personality-settings.test.tsx(18 tests). Only the HTTP seam (@/lib/api) and framer-motion are mocked; every row, form, radio toggle and error banner is the real component. The api mock dispatches on${METHOD} ${path}against a mutable list payload, so refreshes are modelled rather than stubbed away.Pinned behavior:
{ id: null }when the active row is toggled off, revert-to-previous on failurewindow.confirmgate in both directions, DELETE then refreshActive state is asserted through
aria-pressed/aria-labelrather than Tailwind classes, so a restyle cannot break the test and a broken affordance cannot pass it.Notes
The framer-motion mock caches its component per tag. An uncached proxy hands React a fresh component type on every render, which remounts the whole list and silently detaches any element a test is holding — that cost two confusing failures during authoring and is called out in a comment.
50 mutants were run against
personality-settings.tsx. The only survivor is thepersonalities.length === 0half of the loading guard:setLoading(true)happens solely in theuseStateinitializer andrefresh()only ever sets it false, so React never commits a frame withloading === trueand a non-empty list. No test can kill it; it is recorded in the brain rather than worked around.A review agent on the diff found four gaps — a non-discriminating banner assertion, an untested "edits survive a failed save" claim, and two undocumented survivors — all fixed here, with all seven demonstrated mutants re-verified as killed.
Local: check ✓ · format ✓ · lint 0 errors · unit 163/2797 server, 68/1000 web, 60 ext, 4 scripts · e2e 181 passed/12 skipped · live tmux lane 11 passed, no leaked sessions.
🤖 Generated with Claude Code