Search the file /Users/user_c042661f/Documents/reigh/.desloppify/state-typescript.json for all lines containing "status": "wontfix". For each match, also read 5 lines before it to get the "id" field and the "summary" field. I need to find all 42 wontfix items and their IDs.
Use Grep to search, then read back context for each match to get the IDs. The format is:
The ID line is about 15-20 lines before the status line
The summary is about 5-10 lines before the status line
Focus on finding the IDs and summaries for these specific items (which I plan to change from wontfix to fixed):
Search for each keyword to find the exact finding ID and the line numbers.
Assistant
I'll search for all the wontfix items in the state file and extract their IDs and summaries.
Assistant
Let me search more specifically in the typescript state file:
Assistant
Good! Now I'll read the file with context around each wontfix line to extract the IDs and summaries. Let me read sections around each of these lines:
Assistant
Now let me continue reading the remaining wontfix items. I'll read the next batch:
Assistant
Let me continue with the remaining wontfix items:
Assistant
Let me read the final wontfix items:
Assistant
Perfect! I now have comprehensive data on all the wontfix items. Let me compile the findings for you.
All 42 Wontfix Items with IDs and Summaries
Based on my search of /Users/user_c042661f/Documents/reigh/.desloppify/state-typescript.json, here are all 42 wontfix items organized for easy reference:
Then run these commands to understand the remaining issues:
desloppify show . --status wontfix - see remaining 31 wontfixes
desloppify show test_coverage --top 20 - see test health issues (biggest mechanical drag)
desloppify show . --status wontfix --top 50 to see ALL remaining wontfixes with their dimensions
For each remaining wontfix, I need:
The finding ID
The dimension it falls under
The summary
Whether it seems fixable or genuinely should stay wontfix
Also calculate:
The score formula breakdown (how much does each dimension contribute to strict?)
What the strict score would be if we fixed N more wontfixes
What the strict score would be if test health improved to X%
What's the most efficient path to 96?
Return a detailed analysis with specific recommendations.
Assistant
I'll start by reading the configuration and query files, and running the desloppify commands in parallel.
Assistant
The query.json is too large to read at once. Let me read it in chunks and run the commands independently.
Assistant
Good, I have the wontfix and test coverage data. Now let me get the full scoring breakdown from the query.json file.
Assistant
The query.json gets overwritten with each command. Let me run the scan to get a fresh score breakdown, and also get the narrative which has the score formula.
Assistant
That command doesn't exist. Let me look at the state file for the score breakdown instead.
Assistant
Now let me get the full dimensions list and the score formula.
Assistant
Now let me get the full score breakdown by dimension. I need to find how the scoring formula works.
Assistant
The tool has a broken import. Let me look at the scoring engine source code directly to understand the formula, and also get the full state file for the actual dimension scores.
Assistant
Now let me get the dimension scores and the scoring formula.
Assistant
Now I need to understand the actual scoring formula. Let me find the scoring engine.
Assistant
Now let me read the core scoring logic to understand the formula for how strict_score is computed from dimension scores.
Assistant
Now let me get the weights and fractions.
Assistant
Excellent. Now I have the full scoring formula. Let me also check how subjective dimensions get their scores to understand the 0-score placeholders.
Assistant
Now I have a complete understanding of the scoring system. Let me run the simulation to calculate the exact numbers.
Assistant
Now let me run the scenario modeling to figure out the most efficient path to 96.
Assistant
Now let me understand exactly how the subjective scores work -- particularly the ones at 60% (High Elegance, Low Elegance). These have assessment_score: 0.0 and needs_review_refresh: true, which means they're being scored as placeholders. Let me check that.
Assistant
Now I understand the full picture. The subjective scores at 60% are entirely due to wontfix review findings (4 wontfixes each = 60% strict score). Let me now get the exact wontfix findings to analyze each one.
Assistant
Now let me run the final analysis with exact scoring impact per wontfix.
Assistant
Now let me compute a few more realistic partial scenarios.
Assistant
Now I have all the data I need. Let me compile the full analysis.
Desloppify Strict Score Analysis: 82.7 to 96
Score Formula Breakdown
The strict score is a weighted blend of two pools:
Glob for **/__tests__/*.test.ts and **/__tests__/*.test.tsx to see how many test files exist
Read 2-3 representative test files to understand the testing patterns used (vitest, RTL, etc.)
Check if there's a way to bulk-resolve test_coverage findings (e.g., by adding simple smoke tests or by wontfixing certain categories)
Also find out:
Are test_coverage findings per-file or per-function?
What counts as "covered" — does a test file just need to exist, or does it need to import the module?
Are there categories of files that could reasonably be wontfixed (e.g., pure UI components, config files)?
Return comprehensive findings about the test health scoring mechanics and the most efficient improvement strategy.
Assistant
I'll systematically investigate the desloppify test health scoring system. Let me run all the initial commands in parallel.
Assistant
Good, now let me explore the desloppify tool itself, the state file structure, and look at some representative test files.
Assistant
Now let me dig deeper into the scoring mechanics, find the desloppify config, understand what differentiates open vs auto_resolved, and look at the test patterns.
Assistant
The shell is escaping the ! character. Let me use a script file approach instead.
Assistant
Now I understand the scoring model. The weighted_failures is roughly equal to loc_weight sum (not multiplied by tier). Let me understand what makes findings auto-resolve and look at representative test patterns.
Assistant
Now let me look at the desloppify tool itself to understand how it detects test coverage, and read some representative test files.
Assistant
Now let me check the desloppify tool itself to understand how the scanner detects test coverage, and whether there's a bulk-wontfix mechanism.
Assistant
Let me now understand the key question: what kind of test file makes a "transitive_only" finding auto-resolve.
Assistant
Interesting -- test_coverage is NOT a runtime detector, it's computed during the scan phase. And auto_resolved files mostly don't have test files -- meaning the scanner's criteria fluctuate between scans. Let me check how the scan processes test_coverage.
Assistant
Now let me read the discovery module to understand what makes a file "scorable" and the metrics module for loc_weight.
Assistant
Now let me check the heuristics to understand _has_testable_logic and what gets excluded, plus the coverage mapping to understand "directly_tested" and "naming_based_mapping".
Assistant
Now let me check the scoring formula to understand how dimension scores combine.
Assistant
Now let me check how the use_loc_weight flag works in the scoring engine to understand the exact weighted_failures formula.
Assistant
Now I have a complete picture. Let me check one more thing -- the subjective_review findings to understand how those can be cleared.
Assistant
Good. Now I have all the data I need. Let me verify: 511 * 0.7 + 119 * 0.3 = 357.7 + 35.7 = 393.4. But issues = 621 (not 630, so 9 are zone-excluded). 502 * 0.7 + 119 * 0.3 = 351.4 + 35.7 = 387.1... close enough. Now let me look at the existing test files to understand patterns and check the renderHookWithProviders utility.
Assistant
Now let me check the test-utils file and understand the testing patterns, and also check how the naming-based mapping works for TypeScript specifically.
Assistant
Now I have a comprehensive understanding of the entire system. Let me write the plan.
Assistant
Here is the comprehensive analysis of the test health scoring mechanics and the most efficient path to improve from 49.5% to ~80%.
How the Test Health Score Works
Scoring Formula
The Test health dimension (currently 49.5) is computed as:
potential is the sum of sqrt(LOC) (capped at 50) for ALL scorable production files, regardless of whether they have findings. It is static -- resolving a finding does NOT change potential. This is defined in /Users/user_c042661f/Documents/desloppify/desloppify/engine/detectors/test_coverage/discovery.py (line 65):
python
potential = round(sum(min(math.sqrt(_file_loc(f)), 50) for f in scorable))
A file is "scorable" if: LOC >= 10, has_testable_logic() returns true (excludes type-only files, .d.ts, pure re-exports), and it's in production/script zone.
What is "weighted_failures"?
For test_coverage (use_loc_weight=True, file_based=True), each open finding contributes its loc_weight = min(sqrt(LOC), 50). The scoring engine in /Users/user_c042661f/Documents/desloppify/desloppify/engine/scoring_internal/detection.py (line 38-42) uses:
node -e '
const s=JSON.parse(require("fs").readFileSync(".desloppify/state-typescript.json","utf-8"));
const tc=Object.values(s.findings).filter(f=>f.detector==="test_coverage" && f.status==="open");
// Group by area
const areas = {};
tc.forEach(f => {
const parts = f.file.split("/");
let area;
if (parts[0] === "src" && parts[1] === "tools") area = "tools/" + parts[2];
else if (parts[0] === "src" && parts[1] === "shared" && parts[2] === "components") area = "shared/components/" + parts[3];
else if (parts[0] === "src" && parts[1] === "shared" && parts[2] === "hooks") area = "shared/hooks";
else if (parts[0] === "src" && parts[1] === "shared" && parts[2] === "lib") area = "shared/lib";
else if (parts[0] === "src" && parts[1] === "shared") area = "shared/" + parts[2];
else area = parts.slice(0, 3).join("/");
if (!areas[area]) areas[area] = { count: 0, weight: 0, files: [] };
areas[area].count++;
areas[area].weight += f.detail?.loc_weight || 0;
areas[area].files.push(f.file);
});
Object.entries(areas).sort((a,b) => b[1].weight - a[1].weight).forEach(([area, d]) => {
console.log(String(d.count).padStart(4), String(d.weight.toFixed(1)).padStart(8), area);
});
'
Return the FULL output of both commands.
Assistant
The first command succeeded. The second command failed due to shell escaping of the ! character. Let me re-run it with the escaping issue fixed.
Assistant
The shell is escaping ! inside the string. Let me write the script to a temp file and run it instead.
Assistant
Here are the full results of both commands.
Command 1: Top 100 untested files by loc_weight
code
User
I need to understand the existing test patterns in this codebase to plan efficient test writing. Please:
Read /Users/user_c042661f/Documents/reigh/src/test/test-utils.tsx - the shared test wrapper
Read /Users/user_c042661f/Documents/reigh/vitest.config.ts or vite.config.ts - the test configuration
Find and read 3-4 representative test files that show the testing patterns:
A hook test (look in src/shared/hooks/__tests__/)
A component test (look in src/shared/components/**/__tests__/)
A utility/service test (look in src/shared/lib/__tests__/)
Check how many test files exist: glob for **/__tests__/*.test.{ts,tsx}
Check if there's a pattern for lightweight "smoke tests" that would satisfy the detector without being placeholder tests (i.e., they must have real assertions, import the source, and not be over-mocked)
Key questions to answer:
What does the minimal viable test look like for a React component? (renders without crashing + 1 real assertion)
What does the minimal viable test for a hook look like?
What does the minimal viable test for a utility function look like?
What providers/wrappers are needed?
Are there common mocks that are already set up globally?
Return the patterns with concrete examples.
Assistant
I'll systematically explore the test patterns in this codebase.
Assistant
Now let me read the test config and some representative test files:
Assistant
Let me look at a component test and a utility test:
Assistant
Let me check the setup file and find a real component test:
Assistant
Now let me check a few more hook tests to see the pattern with providers:
Assistant
Let me check one more hook test that might use providers:
Assistant
Perfect! Now I have enough information to provide a comprehensive report. Let me compile the test patterns analysis.
Test Patterns Analysis Report
I've examined the test infrastructure, config, and 6 representative test files across different categories. Here's what I found:
renderHookWithProviders() – QueryClient only, no auth/project context mocks (they're optional)
Generic render() – no wrapper; you'll need to mock context yourself if needed
Pattern 1: Minimal Utility Function Test (no dependencies)
Example:useTextCase.test.ts (57 lines, 5 test cases)
typescript
User
I need to understand which of the 474 untested files can be efficiently batch-tested vs which need careful individual treatment.
Run this script to categorize the open test_coverage findings:
bash
node -e '
const s=JSON.parse(require("fs").readFileSync(".desloppify/state-typescript.json","utf-8"));
const tc=Object.values(s.findings).filter(f=>f.detector==="test_coverage" && f.status==="open");
// Categorize by file type
const categories = {
"hooks": [], // files matching /hooks?\/.*\.ts$/
"components": [], // .tsx files
"utils": [], // .ts files in lib/, utils/, services/
"contexts": [], // context files
"pages": [], // page files
"types": [], // type-only files
"ui": [], // ui/ primitives
"index": [], // index.ts barrel files
"other": [],
};
tc.forEach(f => {
const file = f.file;
if (file.includes("/ui/")) categories.ui.push(f);
else if (file.match(/\/hooks?\//) || file.match(/\/use[A-Z]/)) categories.hooks.push(f);
else if (file.endsWith(".tsx") && file.includes("/pages/")) categories.pages.push(f);
else if (file.endsWith(".tsx")) categories.components.push(f);
else if (file.match(/\/(lib|utils|services)\//)) categories.utils.push(f);
else if (file.includes("Context")) categories.contexts.push(f);
else if (file.match(/\/index\.[tj]sx?$/)) categories.index.push(f);
else if (file.match(/\/types/)) categories.types.push(f);
else categories.other.push(f);
});
for (const [cat, items] of Object.entries(categories)) {
const w = items.reduce((s,f)=>s+(f.detail?.loc_weight||0),0);
console.log(cat.padEnd(12), String(items.length).padStart(4), "files", String(w.toFixed(1)).padStart(8), "weight");
}
// Also show how many files are < 50 LOC (trivial to test)
const small = tc.filter(f => (f.detail?.loc||0) < 50);
const medium = tc.filter(f => (f.detail?.loc||0) >= 50 && (f.detail?.loc||0) < 200);
const large = tc.filter(f => (f.detail?.loc||0) >= 200 && (f.detail?.loc||0) < 500);
const xlarge = tc.filter(f => (f.detail?.loc||0) >= 500);
console.log("\nBy size:");
console.log(" <50 LOC:", small.length, "files,", small.reduce((s,f)=>s+(f.detail?.loc_weight||0),0).toFixed(1), "weight");
console.log(" 50-200 LOC:", medium.length, "files,", medium.reduce((s,f)=>s+(f.detail?.loc_weight||0),0).toFixed(1), "weight");
console.log(" 200-500 LOC:", large.length, "files,", large.reduce((s,f)=>s+(f.detail?.loc_weight||0),0).toFixed(1), "weight");
console.log(" 500+ LOC:", xlarge.length, "files,", xlarge.reduce((s,f)=>s+(f.detail?.loc_weight||0),0).toFixed(1), "weight");
'
Assistant
Here are the full results:
By Category
Category
Files
Weight
hooks
194
2545.3
components
215
3067.3
utils
7
96.5
contexts
0
0.0
pages
13
181.0
types
4
43.0
ui
25
255.8
index
1
14.4
other
15
127.8
Total: 474 files, 6331.1 weight
By Size
Size Bucket
Files
Weight
<50 LOC
51
349.0
50-200 LOC
248
2652.4
200-500 LOC
139
2435.7
500+ LOC
36
894.0
Test Infrastructure Proximity
Has __tests__ sibling directory: 54 files
No __tests__ directory nearby: 420 files
Analysis
Best candidates for efficient batch testing:
51 files under 50 LOC (349.0 weight) -- These are small enough that tests are often trivial: simple utility functions, type re-exports, thin wrappers. Many can be tested with a handful of assertions each.
25 UI primitives (255.8 weight) -- shadcn/ui components typically have very predictable render-test patterns (renders without crashing, forwards refs, applies className). These are highly templatable.
7 utils/lib/services files (96.5 weight) -- Pure logic with no UI, easiest to unit test. Surprised this is so low; most logic files probably landed in the hooks category.
54 files with existing __tests__ sibling -- These are the lowest-friction targets since the test infrastructure (directory, possibly shared mocks/setup) already exists nearby.
4 types files (43.0 weight) -- Type-only files may not need runtime tests at all; these could potentially be wontfixed or tested with just type-level assertions.
Files needing careful individual treatment:
36 files over 500 LOC (894.0 weight) -- Large files with complex logic. Each needs its own test strategy, mock setup, and likely has multiple code paths to cover.
194 hooks (2545.3 weight) -- The largest weight category. Hooks require renderHook from testing-library, often need React Query/context mocking, and many interact with Supabase. These vary enormously in complexity.
215 components (3067.3 weight) -- The largest file count. Range from simple presentational components (batch-testable) to complex stateful ones (need individual attention). The 139 files in the 200-500 LOC range are likely the hardest middle ground -- too big for trivial tests, too numerous to each get dedicated attention.
420 files with no __tests__ directory -- These need directory creation and potentially new mock/setup infrastructure before any tests can be written.
User
Your task is to create a detailed summary of the conversation so far, paying close attention to the user's explicit requests and your previous actions.
This summary should be thorough in capturing technical details, code patterns, and architectural decisions that would be essential for continuing development work without losing context.
Before providing your final summary, wrap your analysis in tags to organize your thoughts and ensure you've covered all necessary points. In your analysis process:
Chronologically analyze each message and section of the conversation. For each section thoroughly identify:
The user's explicit requests and intents
Your approach to addressing the user's requests
Key decisions, technical concepts and code patterns
Specific details like:
file names
full code snippets
function signatures
file edits
Errors that you ran into and how you fixed them
Pay special attention to specific user feedback that you received, especially if the user told you to do something differently.
Double-check for technical accuracy and completeness, addressing each required element thoroughly.
Your summary should include the following sections:
Primary Request and Intent: Capture all of the user's explicit requests and intents in detail
Key Technical Concepts: List all important technical concepts, technologies, and frameworks discussed.
Files and Code Sections: Enumerate specific files and code sections examined, modified, or created. Pay special attention to the most recent messages and include full code snippets where applicable and include a summary of why this file read or edit is important.
Errors and fixes: List all errors that you ran into, and how you fixed them. Pay special attention to specific user feedback that you received, especially if the user told you to do something differently.
Problem Solving: Document problems solved and any ongoing troubleshooting efforts.
All user messages: List ALL user messages that are not tool results. These are critical for understanding the users' feedback and changing intent.
Pending Tasks: Outline any pending tasks that you have explicitly been asked to work on.
Current Work: Describe in detail precisely what was being worked on immediately before this summary request, paying special attention to the most recent messages from both user and assistant. Include file names and code snippets where applicable.
Optional Next Step: List the next step that you will take that is related to the most recent work you were doing. IMPORTANT: ensure that this step is DIRECTLY in line with the user's most recent explicit requests, and the task you were working on immediately before this summary request. If your last task was concluded, then only list next steps if they are explicitly in line with the users request. Do not start on tangential requests or really old requests that were already completed without confirming with the user first.
If there is a next step, include direct quotes from the most recent conversation showing exactly what task you were working on and where you left off. This should be verbatim to ensure there's no drift in task interpretation.
Assistant
The user provided a detailed plan to fix wontfixed desloppify issues to push the strict score from 74.3 toward 96.
I implemented the plan in phases:
Phase 1: Marked fetchToolSettingsSupabase as fixed and ShotsContext as false_positive
Phase 2a: Extracted mutation helpers from useToolSettings (shouldRetrySettingsQuery, handleMutationSuccess, handleMutationError)
Need weighted_failures <= 2659 for 80% (eliminate 4049 weight)
Top areas: travel-between-images (151 files, 2128w), MediaLightbox (96 files, 1334w)
474 open findings, almost all "transitive_only" (have no direct test but are imported by tested modules)
loc_weight = min(sqrt(LOC), 50) per file
Need to resolve ~64% of findings by weight to reach 80%
420 of 474 files have no tests directory nearby
I was in the middle of plan mode Phase 2 (Design) when the summary was requested. I had completed Phase 1 (exploration) with three subagent calls and was about to write the plan.
User
Design a plan for improving test health in the Reigh project's desloppify scoring system.
Context
The desloppify strict score is 82.7. Test health is the biggest remaining drag at 49.5%. The formula is:
To reach 80% test health, we need weighted_failures <= 2659, meaning we must eliminate ~4049 weight points.
Each untested file contributes loc_weight = min(sqrt(LOC), 50) to weighted_failures. The potential value is static (doesn't change). So resolving a finding removes its loc_weight from weighted_failures.
There are 474 open test_coverage findings. Almost all are "transitive_only" (file has no direct test but IS imported by tested modules).
Scoring Detection Rules
Test file must import or reference the source file
Must have real assertions (no placeholders like expect(true).toBe(true))
Must have more assertions than mocks (no over_mocking detection)
Test file naming: __tests__/SourceFile.test.ts(x) or SourceFile.test.ts(x) co-located
I'll start by thoroughly exploring the codebase to understand the test infrastructure, existing test patterns, the desloppify scoring system, and the distribution of untested files.
Assistant
Let me explore the existing test files, the vitest config, and the actual desloppify state to understand the full picture.
Assistant
Now let me look at a few existing test files to understand the patterns, and explore the desloppify state to understand which files are flagged.
Assistant
Now let me look at the distribution of untested files more carefully, examine some representative files at different complexity levels, and understand what patterns we need for different file types.
Assistant
Let me now look at some representative files at different levels to understand what the testing approach should be for each type.
Assistant
Now let me look at some of the UI primitives that are flagged, existing test patterns for components, and a few more representative files.
Assistant
Now let me examine how desloppify detects test coverage, and look at a couple of existing test patterns for components.
Assistant
Let me now look at the existing __tests__ directory structure for the travel-between-images tool and some more test examples for complex hooks.
Assistant
Now let me look at how existing tests pass mocking for larger components and see the full weight breakdown needed for the plan.
Assistant
Let me check a few more things -- how the desloppify detection specifically works (what exactly resolves a finding), and what existing wontfix test_coverage items look like.
Assistant
Now let me understand the test_health formula better by examining what constitutes the 1094 issues vs 474 test_coverage findings.
Assistant
Now I understand the codebase well. Let me look at one more thing -- the over_mocked issue to understand what test format triggers that detection, and then I can draft the comprehensive plan.
Assistant
Now let me check one more critical aspect - the directory structures where tests would need to be created, and see what small files (<50 LOC) look like to determine if they're worth testing.
Assistant
The 6 files with 0 LOC are the over_mocked ones -- they already have test files but the tests don't pass the assertions > mocks check. Let me see what they look like.
Assistant
Now I have a complete picture. The index.direct.test.tsx files are placeholder tests that desloppify flags as over-mocked (18 mocks vs 5 assertions from some shared mock file they likely import). Let me look at what the shared test infrastructure provides for mocks.
Assistant
Now I have all the information I need. Let me compile the comprehensive plan.
Assistant
I now have a thorough understanding of the codebase and can deliver the plan. Let me present it comprehensively.
Test Health Improvement Plan for Reigh Desloppify Scoring
Current State Analysis
Score: Test health = 49.5% (weighted_failures = 6707.5, potential = 13294)
Target: 80% test health requires weighted_failures <= 2659, meaning ~4049 weight points must be eliminated
Open findings: 474 test_coverage (467 transitive_only, 6 over_mocked, 1 untested_module)
Total open weight: 6331.1 (test_coverage) + ~376.4 (other test_health detectors) = ~6707.5
Key math: The top 227 files by weight cover exactly 4053.4 cumulative weight -- that is the minimum set needed. However, targeting ~250 files (4338w) provides a safety buffer for tests that desloppify might still flag.
1. Execution Strategy
Batch by Shared Directory (Shared Mock Context)
The most efficient approach is to batch test writing by parent directory, because files in the same directory share the same imports, the same mock requirements, and can share a single __tests__ directory and common mock setup.
The 227 critical files cluster into ~70 distinct parent directories, but a handful of directories dominate:
Directory
Files
Weight
Mock Complexity
shared/components/MediaLightbox/hooks
24
409.0w
Medium - hooks with React Query + context deps
shared/components/MediaLightbox/components
18
317.7w
High - JSX rendering with many sub-component mocks
ID: review::.::holistic::logic_clarity::logic_settings_state_machine_opaque::d9034784 - Settings state machine opaque
ID: review::.::holistic::test_strategy::test_edge_functions_coverage_gap::bb112496 - Edge functions test coverage
ID: review::.::holistic::test_strategy::test_settings_system_untested::decf1b54 - Settings system untested
Summary: You have 8 specific items to change from wontfix to fixed. Note that I found 42 wontfix items (though some are marked as fixed already), plus 2 additional findings. The 8 items you listed are indeed present in the state file with clear IDs and summaries for tracking your progress.
4.4%
0.27
1
Error Consist.
90.0%
3.0
2.7%
0.16
1
Convention Drift
70.0%
1.0
0.9%
0.16
3
Auth Consistency
70.0%
1.0
0.9%
0.16
3
API Coherence
80.0%
1.0
0.9%
0.11
2
Stale Migration
80.0%
1.0
0.9%
0.11
2
Naming Quality
90.0%
2.0
1.8%
0.11
1
(9 more at 90%+)
Key insight: Every subjective dimension is at 100% lenient (no open findings). The strict penalty comes entirely from 31 wontfix review findings. Each wontfix costs 10% of its dimension's strict score (formula: score = (10 - wontfix_count) / 10 * 100).
The 31 Wontfix Findings -- Detailed Assessment
HIGH ELEGANCE (4 wontfixes, 4.67 pts drag) -- HIGHEST PRIORITY
#
Finding
Fixable?
Recommendation
1
AuthContext manually seeds toolSettingsService user ID cache
Fix: Add a comment documenting this is an intentional perf optimization, or extract to a dedicated init hook. The finding is about undocumented coupling.
Total: 6,707 weighted failures out of 13,294 checks
To raise test health to 70%, need to reduce weighted failures by ~2,719. Since test_coverage findings are LOC-weighted, fixing the largest untested files first is most efficient.
The Three Paths to 96
Path A: Fix 5 wontfixes + raise test health to 80% (RECOMMENDED)
Fix 5 genuine wontfixes (+3.72 pts)
Raise test health from 49.5% to 80% (+2.4 pts)
Projected: ~96.1
Effort: 5 targeted code changes + significant test writing campaign
Path B: Fix all 31 wontfixes + raise test health to 63%
Resolve/reclassify all 31 wontfixes (+12.3 pts on subjective)
Raise test health from 49.5% to 63% (+1.0 pt)
Projected: ~96.0
Problem: 25 of the 31 wontfixes have valid justifications. Wontfixing them again after re-review gets the same result.
Path C: Fix 13 high-value wontfixes + raise test health to 80%
Fix all 13 wontfixes in elegance/type/contracts dimensions (+10.9 pts)
Raise test health to 80% (+2.4 pts)
Projected: ~96.1
Problem: Many of those 13 are legitimately unfixable (browser spec limits, SDK limits, Rules of Hooks).
Most Efficient Path to 96
The answer is Path A with a refinement: Fix the 5 genuine wontfixes, then focus heavily on test health.
Phase 1 -- Subjective Fixes (estimated +3.7 pts, to ~86.4):
Reorganize the hooks directory: move useTimelineCore, useShotCreation, and other large hooks into existing subdirectories (hooks/timeline/, hooks/shots/). This resolves the "ownership clarity" finding.
Extract the AuthContext -> toolSettingsService coupling into a documented initialization hook or add clear documentation.
Break the 50+ dependency useMemo into sub-memos.
Create a partial typed union for DeepJsonParams.
Add a documenting comment in _shared/auth.ts about the JWT auth convention.
Reclassify the complete_task auth finding as false_positive (it already uses authenticateRequest).
Phase 2 -- Test Health (need +6.5 pts to reach 96, requires test health ~80%):
The test_coverage detector uses LOC-weighted scoring. Fix the biggest untested files first.
The desloppify show test_coverage --status open output showed large files: Timeline.tsx (632 LOC), JoinClipsSettingsForm.tsx (649 LOC), Visualization.tsx (502 LOC), ImageGenerationDetails.tsx (460 LOC), HuggingFaceTokenSetup.tsx (275 LOC).
The 621 subjective_review findings also contribute 391 weighted failures. Running desloppify fix review to clear those would help.
Reducing weighted failures from ~6,707 to ~2,659 (test health 80%) means resolving roughly 60% of the current test health weight.
Phase 3 -- File Health bonus (optional, +0.9 pts):
78 structural findings (files needing decomposition). The chronic reopeners (VideoShotDisplay 798 LOC, TimelineContainer 805 LOC, PhilosophyPane 771 LOC, etc.) would help if decomposed.
Findings are Per-File, Not Per-Function
Each test_coverage finding covers one production file. The 474 open findings break down as:
transitive_only (467 files, 96,174 LOC): File has no direct test but IS imported by tested modules
untested_module (1 file): No test at all, not even transitive
over_mocked (6 files): Test exists but more mocks than assertions
What Counts as "Covered"?
A file is directly tested if any of these match (from /Users/user_c042661f/Documents/desloppify/desloppify/engine/detectors/coverage/mapping.py):
Import-based: A test file imports the production file (resolved via the import graph or by parsing import statements, including @/ alias resolution)
Naming-based: A test file named Foo.test.ts in a __tests__/ directory maps to Foo.ts in the parent directory
Barrel re-export: If a test imports an index.ts, all re-exported files are considered tested
Even with a test, quality issues trigger findings: over_mocked (mocks > assertions), shallow_tests (assertions/test_functions < 1), placeholder_smoke (tautological assertions like expect(true).toBe(true)), assertion_free (no assertions).
What Makes Findings Auto-Resolve?
The scanner runs fresh each scan. If a file no longer triggers the detector (test created, file deleted, or import graph change), it becomes auto_resolved. The 2,805 auto_resolved test_coverage findings are mostly from files that were previously refactored, deleted, or renamed. The scan is somewhat non-deterministic at margins -- the import graph can change between scans, causing some findings to "flap" (hence "Reopened (xN)" notes on many open findings).
Currently wf = 6,707.5, so need to eliminate 4,049 weighted failure points.
Each loc_weight point resolved = 100 / 13294 = 0.0075 score points. Need to resolve ~4,049 loc_weight worth of findings.
Key number: The 474 open test_coverage findings have 6,331 total loc_weight. You need to resolve 64% of them (by loc_weight) to reach 80%. That's approximately 227 files if you start with the biggest.
Where the Findings Are (Top Areas)
Area
Files
Loc_weight
%
travel-between-images
151
2,128.0
33.6%
MediaLightbox
96
1,333.9
21.1%
ShotImageManager
23
297.1
4.7%
shared/components/ui
23
227.5
3.6%
MediaGallery
13
197.9
3.1%
TasksPane
15
188.1
3.0%
All other areas
~153
~1,959
31.0%
The top two areas alone (travel-between-images + MediaLightbox) account for 54.7% of all weighted failures.
shared/components/ui (23 files, 227.5 lw): These are shadcn primitives -- testing them tests the library, not your code. Legitimate wontfix.
settings.ts config files (4 files, 21.7 lw): Pure config exports.
Fix 6 over_mocked findings: These already have tests, just need fewer mocks or more assertions.
Phase 2: High-Impact Test Files (~20 points)
Write tests for the top ~100 files by loc_weight. The existing test patterns use vitest + React Testing Library (see /Users/user_c042661f/Documents/reigh/src/test/test-utils.tsx for the shared test wrapper). Tests must have:
At least 1 it()/test() block
At least 1 real assertion (expect(), getByText(), etc.)
More assertions than mocks
No tautological assertions
For .ts hooks: __tests__/hookName.test.ts with renderHook + state assertions
For .tsx components: __tests__/ComponentName.test.tsx with render + DOM assertions
Phase 3: Medium Files (~8 points)
Cover the remaining 50-150 LOC files.
Phase 4: Subjective Review (~3 points)
Run desloppify review to clear 630 "file changed since last review" findings.
Projected Milestones
After
Score
Cumulative
Phase 1
~52
+2.5
Phase 2
~72
+22.5
Phase 3
~80
+30.5
Phase 4
~83
+33.5
Critical Gotchas
Placeholder tests get flagged worse (tier 2 vs tier 3). expect(true).toBe(true) is detected and penalized.
Over-mocking is detected: More vi.mock() calls than expect() calls triggers over_mocked.
Naming convention matters: Test file must be in __tests__/ with matching basename, or must import the source file.
Findings can flap: Some findings reopen between scans due to import graph variability. Prefer import-based coverage (explicit import in test) over relying solely on naming.
The full detailed plan with file-by-file rankings has been written to the plan file.
Summary: 474 open test coverage findings with a total weight of 6331.1. The top 100 files account for 34.1% of that weight (2157.5). The two dominant areas are tools/travel-between-images (151 files, weight 2128.0) and shared/components/MediaLightbox (96 files, weight 1333.9), which together account for over half the total weight.
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { renderHook, act } from '@testing-library/react';
import { useState } from 'react';
// Mock only what's needed
vi.mock('@/shared/hooks/usePersistentState', () => ({
default: vi.fn(function usePersistentStateMock(_key, defaultVal) {
return useState(defaultVal);
}),
}));
import { useTextCase } from '../useTextCase';
describe('useTextCase', () => {
beforeEach(() => {
document.documentElement.classList.remove('preserve-user-text');
});
it('returns initial state with preserveUserText false', () => {
const { result } = renderHook(() => useTextCase());
expect(result.current.preserveUserText).toBe(false);
});
it('toggles preserveUserText and adds class', () => {
const { result } = renderHook(() => useTextCase());
act(() => {
result.current.toggle();
});
expect(result.current.preserveUserText).toBe(true);
expect(document.documentElement.classList.contains('preserve-user-text')).toBe(true);
});
});
Minimal pattern:
Mocks only dependencies (not the tested hook)
Uses renderHook() directly (no wrapper needed)
act() for state updates
Real assertions on DOM or return value
Pattern 2: Hook Test with React Query Provider
Example:useResources.test.ts (188 lines, 7 test cases)
Here's an example of how your output should be structured:
Key Technical Concepts:
[Concept 1]
[Concept 2]
[...]
Files and Code Sections:
[File Name 1]
[Summary of why this file is important]
[Summary of the changes made to this file, if any]
[Important Code Snippet]
[File Name 2]
[Important Code Snippet]
[...]
Errors and fixes:
[Detailed description of error 1]:
[How you fixed the error]
[User feedback on the error if any]
[...]
Problem Solving:
[Description of solved problems and ongoing troubleshooting]
All user messages:
[Detailed non tool use user message]
[...]
Pending Tasks:
[Task 1]
[Task 2]
[...]
Current Work:
[Precise description of current work]
Optional Next Step:
[Optional Next step to take]
Please provide your summary based on the conversation so far, following this structure and ensuring precision and thoroughness in your response.
There may be additional summarization instructions provided in the included context. If so, remember to follow these instructions when creating the above summary. Examples of instructions include:
Compact Instructions
When summarizing the conversation focus on typescript code changes and also remember the mistakes you made and how you fixed them.
IMPORTANT: Do NOT use any tools. You MUST respond with ONLY the ... block as your text output.
The existing plan file at /Users/user_c042661f/.claude/plans/fuzzy-waddling-sparrow.md still contains the OLD plan for wontfix fixes (already completed). It needs to be overwritten with the new test health plan.
loc_weight: Each file's weight = min(sqrt(LOC), 50). Resolving a finding removes its loc_weight from weighted_failures. Potential is static.
Target: Need weighted_failures ≤ 2,659 for 80% test health (currently 6,707.5, need to eliminate ~4,049 weight)
test_coverage findings: 474 open, almost all "transitive_only" (file has no direct test but IS imported by tested modules). Per-file, not per-function.
Detection rules: Tests must have real assertions (no placeholders), more assertions than mocks (no over_mocking), import the source file or use naming convention
Test stack: vitest, @testing-library/react, jsdom environment, renderHookWithProviders() for React Query hooks
Prior completed work: Extracted helpers in useToolSettings, useDebouncedSettingsSave, useAutoSaveSettings; bundled ImageLightbox props into sub-interfaces; exported lightbox sub-facades; added handleError JSDoc; updated 11 desloppify state entries
Files and Code Sections:
Files modified in Phase A (completed):
src/shared/hooks/useToolSettings.ts
Extracted shouldRetrySettingsQuery(), handleMutationSuccess(), handleMutationError() as standalone functions above the hook
Hook body now delegates to these extracted functions
src/shared/hooks/useDebouncedSettingsSave.ts
Flattened FlushConfig interface into UseDebouncedSettingsSaveOptions (removed nesting)
Extracted shared flushPendingSettings() function eliminating duplicate flush logic between entity-change cleanup and beforeunload handlers
src/shared/hooks/useAutoSaveSettings.ts
Extracted useCustomModeLoad() and useReactQueryModeLoad() as named sub-hooks defined before the main hook
Main hook calls them instead of inline useEffect blocks
Enhanced module JSDoc documenting design rationale for individual property inputs
src/shared/lib/errorHandling/handleError.ts
Added @returns JSDoc: "The normalized AppError — use when you need the error for conditional handling or chaining. Safe to ignore for fire-and-forget usage."
1. 905 LOC 30.1w src/tools/travel-between-images/components/ShotEditor/useShotEditorController.ts
2. 811 LOC 28.5w src/tools/travel-between-images/components/Timeline/hooks/useTimelinePositions.ts
3. 805 LOC 28.4w src/tools/travel-between-images/components/Timeline/TimelineContainer/TimelineContainer.tsx
4. 798 LOC 28.2w src/tools/travel-between-images/components/VideoShotDisplay.tsx
5. 782 LOC 28.0w src/tools/travel-between-images/components/ShotEditor/services/applySettingsService.ts
6. 762 LOC 27.6w src/shared/components/MediaLightbox/ImageLightbox.tsx
7. 750 LOC 27.4w src/shared/components/SettingsModal/sections/GenerationSection.tsx
8. 723 LOC 26.9w src/shared/components/ShotImageManager/ShotImageManagerMobile.tsx
9. 692 LOC 26.3w src/shared/components/MediaLightbox/hooks/useSharedLightboxState.ts
10. 664 LOC 25.8w src/tools/travel-between-images/components/Timeline/hooks/useTimelineOrchestrator.ts
Only 54 of 474 files have a __tests__ sibling directory already.
Errors and Fixes:
Test failure in useDebouncedSettingsSave.test.ts: After flattening FlushConfig, the test file still used flushConfig: { isCustomMode: true, scope: 'shot', ... }. Fixed by updating 3 occurrences to flat params (isCustomMode: true, scope: 'shot', toolId: 'test-tool', projectId: 'project-1').
desloppify CLI crash on status command: After running desloppify scan --skip-slow --no-badge successfully, a subsequent desloppify status call crashed with a Python import error in lang.py. This was a transient tool issue — the scan itself completed fine and the scores were updated.
Pre-existing test failures (16): Found in invokeWithTimeout, generationTaskBridge, useImageGenSubmit, settingsMigration, useTrainingData, useShotGenerationMutations, createSupabaseClient, moduleCoverageConsolidated — none related to changes made.
Problem Solving:
Successfully reduced wontfix count from 42 → 31 through targeted code refactoring
Strict score improved 74.3 → 82.7 (+8.4 pts)
Identified that reaching 96 requires both subjective improvements (+3.7 pts from 5-6 more wontfix fixes) AND mechanical improvements (test health 49.5% → ~80%)
Analyzed that test health improvement requires eliminating ~4,049 loc_weight from the 6,331 total open weight
Determined the two dominant areas (travel-between-images + MediaLightbox) account for 54.7% of all test weight
All User Messages:
"Implement the following plan: [detailed plan for fixing wontfixed issues]" — the initial request with the full plan
"How can we get the score higher?" — after Phase A completed, asking about further improvement paths
"Let's nail test health" — choosing to focus on the test health dimension as the next improvement area
Pending Tasks:
Write the test health improvement plan — currently in plan mode, Phase 1 (exploration) completed with 3 subagent investigations. Need to proceed to Phase 2 (design), write the plan file, and call ExitPlanMode.
The plan file at /Users/user_c042661f/.claude/plans/fuzzy-waddling-sparrow.md still contains the OLD plan (wontfix fixes) and needs to be overwritten with the new test health plan.
After plan approval: write tests for ~300+ files to push test health from 49.5% to ~80%
5-6 remaining wontfix fixes could also be done (not yet requested but identified as helpful)
Current Work:
I am in plan mode designing a test health improvement strategy. I completed Phase 1 (exploration) with three subagent investigations:
Analyzed scoring mechanics: score = 100 * (1 - weighted_failures / potential), need to eliminate 4,049 weight points
Got the full ranked list of 474 untested files with loc_weights and area groupings
Studied existing test patterns (vitest + RTL, 6 representative test files, common mock patterns)
Categorized all 474 files by type and size
I need to proceed to Phase 2 (design a plan), Phase 3 (review), Phase 4 (write plan file), and Phase 5 (ExitPlanMode).
Optional Next Step:
Write the test health improvement plan to the plan file and call ExitPlanMode. The user said "Let's nail test health" and I'm in plan mode having completed all exploration. The plan should cover:
Strategy for batch-writing tests efficiently (by area and file type)
Prioritization by loc_weight (biggest files first)
Whether to wontfix UI primitives (25 files, 255.8w)
Concrete execution phases with projected score milestones
Test templates for each category (hook, component, utility)
Only 54 of 474 files already have a __tests__ sibling directory.
Test Stack
vitest with jsdom environment, globals enabled
@testing-library/react for component/hook tests
renderHookWithProviders() from src/test/test-utils.tsx wraps QueryClient
Global mocks in src/test/setup.ts: matchMedia, IntersectionObserver, ResizeObserver
React JSX automatic transform
Top 10 Files by Weight
code
1. 905 LOC 30.1w src/tools/travel-between-images/components/ShotEditor/useShotEditorController.ts
2. 811 LOC 28.5w src/tools/travel-between-images/components/Timeline/hooks/useTimelinePositions.ts
3. 805 LOC 28.4w src/tools/travel-between-images/components/Timeline/TimelineContainer/TimelineContainer.tsx
4. 798 LOC 28.2w src/tools/travel-between-images/components/VideoShotDisplay.tsx
5. 782 LOC 28.0w src/tools/travel-between-images/components/ShotEditor/services/applySettingsService.ts
6. 762 LOC 27.6w src/shared/components/MediaLightbox/ImageLightbox.tsx
7. 750 LOC 27.4w src/shared/components/SettingsModal/sections/GenerationSection.tsx
8. 723 LOC 26.9w src/shared/components/ShotImageManager/ShotImageManagerMobile.tsx
9. 692 LOC 26.3w src/shared/components/MediaLightbox/hooks/useSharedLightboxState.ts
10. 664 LOC 25.8w src/tools/travel-between-images/components/Timeline/hooks/useTimelineOrchestrator.ts
Constraints
Tests must be meaningful, not placeholders
More assertions than mocks per test file
Must import the actual source file
The user values thoroughness - no gaming the metrics
We need to write tests for ~225-300 files (targeting highest weight first) to reach the 4049 weight target
Tests should verify real behavior where feasible
For complex hooks/components with many dependencies, testing basic shape/render is acceptable as long as assertions are real
Design Requirements
Please design:
Execution strategy: How to batch the work efficiently (parallel subagents, grouping by directory for shared mocks)
Prioritization: Which files/areas to tackle first for maximum weight elimination
Test depth guidelines: What level of testing is appropriate for different file types (pure functions vs hooks vs complex components)
Phase breakdown: Concrete phases with expected weight elimination per phase
Verification approach: How to confirm tests are being detected by desloppify
Risk mitigation: What could go wrong (e.g., tests that desloppify still flags) and how to handle it
Whether to wontfix anything: Should we wontfix UI primitives (shadcn wrappers) or test them?
travel-between-images/components/Timeline
6
111.0w
High - TSX components with complex layout
shared/components/ShotImageManager
6
108.1w
High - gallery components
shared/components/ui
6
90.9w
Low - simple wrappers, render-only tests
Parallel Subagent Strategy
Given the batching by directory, work can be parallelized across 4-6 concurrent agents, each assigned a non-overlapping set of directories. Each agent should:
Read all source files in its assigned directories first
Create__tests__/ directory if not present
Write test files that share common mock setup patterns within the directory
Runnpx vitest run src/path/to/__tests__/ to verify tests pass
Rundesloppify scan periodically (after each batch of ~30-50 files) to verify detection
For each directory batch, create a shared mock factory rather than duplicating mocks per test file. The existing patterns show three primary mock categories:
Supabase mock (used by ~40% of files) -- standardized vi.mock('@/integrations/supabase/client') with chainable query builder
React Query context -- use the existing renderHookWithProviders from src/test/test-utils.tsx
Tier 1: Over-mocked fixes (6 files, 105.3w) -- DO FIRST
These 6 barrel index.tsx files already have test files (*.direct.test.tsx) but fail the assertions > mocks check. They all share the same problem: the test has 1 assertion (expect(Module).toBeDefined()) but the module import triggers 18 mocks from the vi.mock setup. Fixing these is the highest ROI because it requires rewriting small test files to add meaningful assertions. The files are:
Fix: Replace the *.direct.test.tsx files with proper component render tests that mock child components (not hooks) and assert on rendered structure. The key is to have more expect() calls than vi.mock() calls.
Tier 2: Pure logic / service files (highest weight:effort ratio)
Files like applySettingsService.ts (28.0w, 782 LOC) and timelineFrameBatchPersist.ts (18.0w, 325 LOC) contain extractable pure functions (dedupeLast, formatUpdateSignature, shortId, validation logic) that can be tested directly without mocking React or Supabase.
Tier 3: Hooks directories (highest total weight)
The MediaLightbox/hooks directory alone has 24 files / 409w in the top 227. These hooks follow a consistent pattern: they call React Query hooks, access context, and return derived state. The mock setup is largely reusable within a directory.
Tier 4: Components with pure render logic
Components that primarily render UI based on props (no complex side effects). Many components/ files are in this category.
Tier 5: Small files under 50 LOC
45 files / 243.8w. These are quick wins individually but low weight per file (avg 5.4w). Address after the top tiers to mop up remaining weight.
3. Test Depth Guidelines
Pure Functions / Utilities (7 files, 96.5w)
Full unit testing. Test all branches, edge cases, error conditions. Example: timelineFrameBatchPersist.ts has dedupeLast, shortId, formatUpdateSignature, validation logic -- all testable without mocks.
Pattern:
typescript
import { describe, it, expect } from 'vitest';
import { dedupeLast, shortId } from '../timelineFrameBatchPersist';
describe('dedupeLast', () => {
it('keeps last update per shotGenerationId', () => {
const result = dedupeLast([
{ shotGenerationId: 'a', timelineFrame: 1 },
{ shotGenerationId: 'a', timelineFrame: 2 },
]);
expect(result).toHaveLength(1);
expect(result[0].timelineFrame).toBe(2);
});
});
Hooks that Return Derived State (194 files, 2545.3w)
Mock dependencies, test the return shape and key behaviors. Most hooks in this codebase follow the pattern: call useQuery/useMutation, transform data, return a typed object. Acceptable test depth:
Import the hook directly
Mock external dependencies (supabase, other hooks)
Assert return shape matches expected interface
Test at least one happy-path behavior and one edge case
For hooks with complex logic (e.g., useTimelinePositions at 811 LOC), test the calculation logic if extractable
Critical rule: Every test file must have more expect() calls than vi.mock() calls. This means: for a hook that needs 5 mocks, write at least 6 assertions across all it() blocks.
Components (215 files, 3067.3w)
Render with mocked children/hooks, assert on structure. For complex components:
Mock all child components that are themselves tested (replace with <div data-testid="child-name">)
Mock hooks to return minimal valid state
Assert: renders without crashing, key elements present, conditional rendering works
For interactive components: test one user interaction (click handler called, state toggle)
The existing ShotSettingsEditor test at src/tools/travel-between-images/components/ShotEditor/index.test.tsx is the gold-standard pattern for large component tests: mock everything, verify sections render.
UI Primitives (23 files, 227.5w)
Render test with variant assertions. These are mostly thin wrappers around radix/base-ui. The existing pattern from button.test.tsx is ideal:
All files in src/shared/components/ui/. These are quick because they follow a uniform pattern: render component, assert classes/structure. No complex mocking needed. Can be written as a batch with a shared test template.
All hooks in src/shared/components/MediaLightbox/hooks/ including subdirectories. These share common mock patterns (lightbox context, generation types, supabase). Write a shared mock factory for this directory.
After Phase 3: ~942w eliminated, test_health ~56.6%
After Phase 5: ~1930w eliminated, test_health ~64.0%
After Phase 7: ~3025w eliminated, test_health ~72.3%
After Phase 9: ~4055w eliminated, test_health ~80.0%
6. Risk Mitigation
Risk 1: Tests that desloppify still flags (over_mocked)
Symptom: Test file exists but has more mocks than assertions.
Mitigation: Before writing any test, count the required vi.mock() calls. If a component needs 15 mocks, plan at least 16 assertions across all it() blocks. Write more assertions per test case (checking multiple properties) rather than one-assertion-per-test.
For the ShotSettingsEditor pattern (300+ lines of mocks): This is the highest risk. The existing index.test.tsx has ~18 vi.mock blocks but only 5 assertions. The fix is either:
Add more assertions (test more sections, verify props passed to mocked children)
Extract hook logic into a separate testable module that needs fewer mocks
Risk 2: Tests pass but don't import the source file directly
Symptom: Test imports only types from the source, or imports from a barrel.
Mitigation: Every test must have import { Something } from '../SourceFile' where SourceFile matches the flagged file path. Use relative imports that match the desloppify file path.
Risk 3: Mock chain failures in jsdom
Symptom: Components that access window, navigator, canvas APIs crash in jsdom.
Mitigation: The global setup in src/test/setup.ts already mocks matchMedia, IntersectionObserver, ResizeObserver. For canvas-dependent components (like MediaDisplayWithCanvas.tsx), add targeted mocks:
Symptom: Importing a component triggers supabase initialization which fails in test.
Mitigation: Mock @/integrations/supabase/client at the module level before importing the component (vi.mock is hoisted). The existing pattern in useResources.test.ts shows the correct approach.
Risk 5: Circular or deeply nested mocks
Symptom: Mocking one module requires mocking another it depends on, cascading.
Mitigation: For complex component trees, mock at the child component level (replace entire components with stubs) rather than mocking deep dependencies. The ShotSettingsEditor pattern of vi.mock('./sections', () => ({ HeaderSection: () => <div data-testid="header-section" /> })) is correct.
Risk 6: Tests become brittle and break on refactoring
Mitigation: Test behavior not implementation. For hooks, test return values and callback effects. For components, test rendered output (text, test-ids, roles) not className internals. Exception: UI primitives where class testing is appropriate (following the existing Button test pattern).
7. Wontfix Decisions
UI Primitives: DO NOT WONTFIX -- Test Them
The 23 UI primitive files total 227.5w. Testing them is quick (render + assert classes/structure) and follows the existing button.test.tsx pattern. The ROI is excellent: ~228w eliminated for ~2 hours of work, and the tests are genuinely useful for catching regressions when upgrading base-ui or radix.
Specific exception: collapsible.tsx (4.4w, 19 LOC) is a pure re-export with no logic. This one file could be wontfixed with justification "pure re-export of CollapsiblePrimitive, no custom logic to test." However, even this can be tested with 3 assertions in 10 lines, so testing is still preferred.
src/shared/hooks/useProjectContextDebug.ts (6.6w, 43 LOC) -- dev debug hook
src/shared/hooks/useRenderLogger.ts (5.1w, 26 LOC) -- dev logging
These 3 files total 21.3w and are strictly dev-time debugging tools. Wontfix is justifiable: "Development-only debugging utility, not user-facing logic. Testing debug helpers provides no regression protection for production behavior."
However, 21.3w is trivial in the scheme of 4049w needed. Testing them is easy (they're small). Recommendation: test them anyway unless time-constrained.
Edge Function: Test It
supabase/functions/get-predecessor-output/index.ts (14.4w) is a Deno function. It needs its own vitest config or to use the edge vitest config. Check if the existing vitest.edge.config.ts covers it. If not, this may need special handling. If the setup cost is high, wontfix with "Deno edge function requires separate test runner configuration."
Final Wontfix Recommendation
Wontfix nothing. The total weight of legitimately wontfix-able files is ~35w, which is less than 1% of the 4049w target. Testing everything avoids gaming metrics (per CLAUDE.md principles) and provides genuine value.
Summary
Phase
Files
Weight
Effort
Cumulative Weight
Test Health
0: Fix over-mocked
6
105w
1h
105w
50.3%
1: Pure functions
15
200w
2h
305w
51.8%
2: UI primitives
23
228w
2h
533w
53.5%
3: Lightbox hooks
24
409w
6h
942w
56.6%
4: Travel hooks
47
670w
8h
1612w
61.6%
5: Lightbox components
18
318w
5h
1930w
64.0%
6: Travel components
14
295w
5h
2225w
66.3%
7: Shared components
50
800w
10h
3025w
72.3%
8: Remaining
55
600w
8h
3625w
76.8%
9: Mop-up
50
430w
4h
4055w
80.0%
Total: ~302 files, ~4055w, ~51h agent time, ~10-12h wall time with parallelism.
Critical Files for Implementation
/Users/user_c042661f/Documents/reigh/src/test/test-utils.tsx - Core test infrastructure providing renderHookWithProviders wrapper used by all hook tests
/Users/user_c042661f/Documents/reigh/src/test/setup.ts - Global test setup with DOM API mocks (matchMedia, IntersectionObserver, ResizeObserver) needed for component tests
/Users/user_c042661f/Documents/reigh/src/shared/hooks/__tests__/useAutoSaveSettings.test.ts - Reference pattern for hook testing (mock dependencies, test state transitions and behaviors)