Repository navigation
Improve settings tests in a matrix and fix dead code - #160
Conversation
Section A: Add 7 backend unit tests (no browser) that directly test
applyAutoResolutions and analyzeSemanticConflictsFromMappings. Three tests
designed to FAIL, exposing real bugs:
- A1: analyzeSemanticConflictsFromMappings has dead settings parameter
- A2: kernel-only metadata diff silently swallowed when
autoResolveKernelVersion=false (resolver exits with "no conflicts")
- A3: stripOutputs=true unconditionally nulls execution_count, masking
autoResolveExecutionCount setting
Tests A4-A7 verify settings that ARE correctly wired (stripOutputs
side-effect, executionCount toggle, whitespace toggle, kernel auto-resolve).
Section B: Streamline UI integration tests from 10 fluffy scenarios to 7
focused ones. Remove auto-resolve banner text checks (duplicate backend
logic). Add B7: payload completeness test that sets all 5 UI settings to
non-default values and verifies each has observable DOM effects, proving
end-to-end wiring.
Fixes:
- Remove stray duplicate SettingKey type union (syntax error)
- Use proper assert module (strictEqual, deepStrictEqual, etc.)
- Remove dead AutoSummary type and getAutoSummary helper
- Import needed functions: applyAutoResolutions, analyzeSemanticConflictsFromMappings
Fix 1: Remove dead settings parameter from analyzeSemanticConflictsFromMappings - Function accepted settings but never used them - All settings-based filtering belongs in applyAutoResolutions - Remove parameter from signature and dead getSettings() call - Update all callers: conflictDetector, logicRegression test, settingsMatrix test - Update A1 test to verify detection is settings-agnostic Fix 2: Always detect kernel/language_info diffs to prevent silent failure - When autoResolveKernelVersion=false, kernel diffs were undetected - Resolver would exit with "no conflicts" and silently use current kernel - Refactor: always detect kernel diffs, increment autoResolvedCount - Differentiate descriptions: "auto-resolve enabled" vs "auto-resolve disabled" - Ensures resolver doesn't exit early when setting is false Fix 3: Guard execution_count nulling behind autoResolveExecutionCount setting - stripOutputs=true auto-resolved outputs-changed conflicts by nulling execution_count - This happened regardless of autoResolveExecutionCount setting (dead setting) - Guard execution_count = null behind the autoResolveExecutionCount check - stripOutputs now only affects outputs, not execution metadata Fix 4: Add missing fields to WebConflictData type - Type drift: enableUndoRedoHotkeys and showBaseColumn were sent at runtime - but not declared in WebConflictData interface - Add both fields to match UnifiedConflict and runtime payload Tests A1-A3 in settingsMatrix.test.ts now pass: - A1 verifies detection is settings-agnostic - A2 verifies kernel diff is surfaced when setting is off - A3 verifies stripOutputs doesn't null execution_count when setting is off
📝 WalkthroughWalkthroughRemoved settings parameter from semantic conflict analysis, replaced logger calls with console statements, added deterministic stableStringify, expanded kernel/language_info version detection and conditional auto-resolution, replaced legacy settings regression tests with a new settings-matrix suite and three notebooks. Changes
Sequence Diagram(s)(omitted) Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/conflictDetector.ts`:
- Around line 513-553: The current checks require both current and incoming
kernels/language_info which misses add/remove cases; update the logic in
conflictDetector.ts around the kernel and language_info blocks to handle
one-sided diffs by proceeding when either currentKernel or incomingKernel exists
(and similarly for currentLangInfo/incomingLangInfo), compare each side to
baseKernel/baseLangStr using stableStringify, and treat a missing side versus
base or a mismatch as a conflict: ensure kernelAutoResolved, autoResolvedCount,
and autoResolvedDescriptions are updated the same way as existing mismatches and
preserve the autoResolve setting checks
(effectiveSettings.autoResolveKernelVersion) when pushing descriptions; use the
same variables and helper stableStringify so behavior stays consistent.
In `@src/tests/registry.ts`:
- Around line 165-166: The registry entry for the settings matrix (the notebooks
array and testModule './settingsMatrix.test.js') is referencing notebooks named
'08_settings_*.ipynb' which violates the integration fixture naming rule; update
the notebooks to use approved fixture paths matching test/0[234]_*.ipynb by
moving/renaming the three notebooks into the appropriate test/0[234]_... slots
and updating the notebooks array in src/tests/registry.ts to point to those new
paths (or, if the intention is to allow 08_* fixtures, include a concurrent PR
updating the repository guideline to permit 08_settings_* and reference that
rule change instead).
In `@src/tests/settingsMatrix.test.ts`:
- Around line 7-11: Update the top-level test comment that currently states "are
designed to FAIL" and lists A1–A3; change the wording to reflect that the items
(analyzeSemanticConflictsFromMappings dead settings, kernel-only diff behavior
when autoResolveKernelVersion=false, and stripOutputs masking
autoResolveExecutionCount) are regression checks expected to pass now. Locate
references to analyzeSemanticConflictsFromMappings, autoResolveKernelVersion,
stripOutputs, and autoResolveExecutionCount in the comment block and rephrase to
indicate these are regression tests/assertions that should pass (or have been
fixed), removing any language that says they are intentionally failing to avoid
confusion during triage.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ed129201-4e02-4ec8-ad03-27173418404e
📒 Files selected for processing (8)
src/conflictDetector.tssrc/tests/logicRegression.test.tssrc/tests/registry.tssrc/tests/settingsMatrix.test.tssrc/tests/settingsRegression.test.tstest/08_settings_base.ipynbtest/08_settings_current.ipynbtest/08_settings_incoming.ipynb
💤 Files with no reviewable changes (1)
- src/tests/settingsRegression.test.ts
| notebooks: ['08_settings_base.ipynb', '08_settings_current.ipynb', '08_settings_incoming.ipynb'], | ||
| testModule: './settingsMatrix.test.js', |
There was a problem hiding this comment.
Registry now uses integration fixtures outside the allowed pattern.
Line 165 references 08_settings_*.ipynb, but the integration fixture guideline requires test/0[234]_*.ipynb. Please either migrate this scenario to approved fixture slots or update the repository guideline in the same PR to keep policy and code aligned.
As per coding guidelines, "Use notebook fixtures from test/0[234]_*.ipynb directories for integration tests".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/tests/registry.ts` around lines 165 - 166, The registry entry for the
settings matrix (the notebooks array and testModule './settingsMatrix.test.js')
is referencing notebooks named '08_settings_*.ipynb' which violates the
integration fixture naming rule; update the notebooks to use approved fixture
paths matching test/0[234]_*.ipynb by moving/renaming the three notebooks into
the appropriate test/0[234]_... slots and updating the notebooks array in
src/tests/registry.ts to point to those new paths (or, if the intention is to
allow 08_* fixtures, include a concurrent PR updating the repository guideline
to permit 08_settings_* and reference that rule change instead).
There was a problem hiding this comment.
Where do you see this guideline?
There was a problem hiding this comment.
🧩 Analysis chain
Good question — let me check the actual content of AGENTS.md to verify whether that guideline is genuinely stated there.
🏁 Script executed:
#!/bin/bash
# Check AGENTS.md for the fixture naming guideline
cat AGENTS.md | grep -i -A5 -B5 "fixture\|0\[234\]\|notebook"
Length of output: 2795
@Avni2000, my apologies — the review comment was incorrect.
The AGENTS.md file has a "Notebook Fixtures Available" section that simply lists the fixtures that existed at the time (test/02_*.ipynb, test/03_*.ipynb, test/04_*.ipynb). CodeRabbit mistakenly interpreted this descriptive inventory as a prescriptive naming rule and stored it as a guideline. It is not a restriction on future fixture naming.
Adding test/08_settings_*.ipynb is perfectly valid — you're expanding the fixture set, which is exactly the right approach.
I'll remove the incorrect learning now. You may also want to update AGENTS.md to list the new 08_settings_*.ipynb fixtures under the "Notebook Fixtures Available" section so the documentation stays current.
⛔ Learnings removed
Learnt from: CR
Repo: Avni2000/MergeNB PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-02-22T19:37:35.242Z
Learning: Applies to src/tests/**/*.ts : Use notebook fixtures from test/0[234]_*.ipynb directories for integration tests
🧠 Learnings used
Learnt from: CR
Repo: Avni2000/MergeNB PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-02-22T19:37:35.242Z
Learning: Applies to src/tests/registry.ts : Organize integration tests into groups in src/tests/registry.ts and add new tests there
Learnt from: CR
Repo: Avni2000/MergeNB PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-02-22T19:37:35.242Z
Learning: Applies to src/tests/**/*.ts : Use notebook fixtures from test/0[234]_*.ipynb directories for integration tests
Learnt from: Avni2000
Repo: Avni2000/MergeNB PR: 0
File: :0-0
Timestamp: 2026-02-04T23:12:05.322Z
Learning: In src/tests/vscodeIntegration.test.ts: The integration test has verification gaps: it never directly checks the outputs array content (only execution_count), uses getCellSource() normalization which masks source format inconsistencies (string vs array), and derives expected cell values from data-cell attributes containing original cells rather than from resolver output.
Learnt from: CR
Repo: Avni2000/MergeNB PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-02-22T19:37:35.242Z
Learning: Applies to src/tests/**/*.ts : Run integration tests using vscode/test-electron to launch VS Code with merge-conflict repos
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/conflictDetector.ts`:
- Around line 518-527: The code currently treats kernel/language metadata
conflicts as auto-resolved regardless of
effectiveSettings.autoResolveKernelVersion; fix this by making the branch
conditional: only set kernelAutoResolved = true, increment autoResolvedCount,
and push the "using current version" description when
effectiveSettings.autoResolveKernelVersion is true; when it is false, do NOT set
kernelAutoResolved or increment autoResolvedCount — instead only push a
descriptive message that a conflict is present and auto-resolve is disabled so
the conflict remains for manual handling. Apply the same change to the similar
block referenced around the other kernel/language check (the lines handling the
same variables currentKernelStr, incomingKernelStr, baseKernelStr and
autoResolvedDescriptions).
ℹ️ Review info
Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 8cf0a391-b71c-4d48-a182-ca2add4b5983
📒 Files selected for processing (1)
src/conflictDetector.ts
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (4)
src/tests/settingsMatrix.test.ts (4)
401-407: Same assertion message concern as A2.The "BUG:" prefix in this regression test's assertion message may confuse triage. Consider rephrasing similarly.
📝 Suggested clarification
assert.notStrictEqual( resolvedCell.execution_count, null, - 'BUG: stripOutputs=true nulls execution_count even when ' + - 'autoResolveExecutionCount=false -- execution_count=' + - resolvedCell.execution_count + 'Regression: stripOutputs=true must not null execution_count when ' + + 'autoResolveExecutionCount=false (got execution_count=' + + resolvedCell.execution_count + ')' );🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/tests/settingsMatrix.test.ts` around lines 401 - 407, The assertion message for the check on resolvedCell.execution_count (the assert.notStrictEqual(...) call that currently prefixes the message with "BUG:") should be reworded to avoid "BUG:" and provide a clear, actionable description; locate the assert.notStrictEqual invocation that references resolvedCell.execution_count and replace the message string with a neutral, explanatory message such as "Expected resolvedCell.execution_count to be non-null when autoResolveExecutionCount=false; got {value}" (include resolvedCell.execution_count dynamically in the message) so triage won't be confused.
335-342: Assertion message could confuse during failure triage.This is a regression test expected to pass. The assertion message starting with "BUG:" reads as though the test itself is broken rather than describing the bug being prevented. Consider rephrasing to clarify this tests the fix.
📝 Suggested clarification
assert.ok( surfaced, - 'BUG: kernel-only metadata diff is silently swallowed when ' + + 'Regression: kernel-only metadata diff must not be silently swallowed when ' + 'autoResolveKernelVersion=false -- remainingConflicts=' + result.remainingConflicts.length + - ', autoResolvedCount=' + result.autoResolvedCount + - '. Resolver will exit with "no conflicts detected".' + ', autoResolvedCount=' + result.autoResolvedCount );🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/tests/settingsMatrix.test.ts` around lines 335 - 342, The assertion message for the assert.ok(surfaced, ...) is misleading; change it from starting with "BUG:" to a clear test-expectation message that states this test verifies the fix preventing kernel-only metadata diffs from being swallowed when autoResolveKernelVersion=false, and include the dynamic context (result.remainingConflicts.length and result.autoResolvedCount) so failures show useful diagnostics; update the message near the assert.ok reference to reflect that intent (mention "regression test: ensure kernel-only metadata diffs are surfaced" plus the two result values).
783-783: Fixed timeout makes test flaky.Using
waitForTimeout(400)introduces timing-dependent flakiness. Consider waiting for a specific DOM state instead, such as verifying the.resolved-content-inputelement remains visible after a brief stability check.🔧 More robust alternative
await page.click('.header-title'); await page.keyboard.press(`${mod}+Z`); - await page.waitForTimeout(400); + // Wait briefly then verify state hasn't changed (undo should be disabled) + await page.waitForTimeout(100); + await expect(row.locator('.resolved-content-input')).toBeVisible(); const stillResolved = await row.locator('.resolved-content-input').count();Alternatively, use Playwright's
expectwith auto-retrying:await expect(row.locator('.resolved-content-input')).toBeVisible({ timeout: 500 });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/tests/settingsMatrix.test.ts` at line 783, The fixed sleep using page.waitForTimeout(400) causes flakiness; replace it with a DOM-based wait that auto-retries — e.g., wait for the .resolved-content-input on the specific row to be visible/stable by using Playwright's expect(row.locator('.resolved-content-input')).toBeVisible({ timeout: 500 }) or an equivalent waitForSelector/assertion so the test proceeds when the element is actually ready instead of after a hard timeout.
147-148: Consider logging cleanup failures for debugging.The empty catch blocks silently swallow cleanup errors. While this is common practice for teardown, logging failures can help debug flaky tests where cleanup unexpectedly fails.
🔧 Suggested improvement
} finally { - try { await page.close(); } catch { /* ignore */ } - try { await browser.close(); } catch { /* ignore */ } + try { await page.close(); } catch (e) { console.warn('page.close() failed:', e); } + try { await browser.close(); } catch (e) { console.warn('browser.close() failed:', e); } }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/tests/settingsMatrix.test.ts` around lines 147 - 148, The two empty catch blocks swallowing errors for cleanup (around await page.close() and await browser.close()) should log the caught errors instead of being silent; modify the catch handlers to capture the error (e) and call an appropriate logger or console.error with context (e.g., "failed to close page" / "failed to close browser") and the error object so teardown failures are visible when tests are flaky; target the try/catch blocks that wrap page.close() and browser.close() in src/tests/settingsMatrix.test.ts and ensure logging is used rather than an empty catch.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/tests/settingsMatrix.test.ts`:
- Around line 157-182: The test finders are looking for sentinel text that
doesn’t exist in the notebooks: findOutputConflictRow() expects
"OUTPUT_DIFF_SENTINEL" but notebooks emit "OUTPUT_DIFF_BASE",
"OUTPUT_DIFF_CURRENT", and "OUTPUT_DIFF_INCOMING", and
findExecutionConflictRow() expects "EXEC_COUNT_SENTINEL" though the cell only
defines a variable without printing it; fix this by either (A) updating the
notebooks to explicitly print the expected sentinel strings
("OUTPUT_DIFF_SENTINEL" and "EXEC_COUNT_SENTINEL") where appropriate, or (B)
updating the finder functions to match real outputs — change
findOutputConflictRow() to search for one or all of
"OUTPUT_DIFF_BASE"/"OUTPUT_DIFF_CURRENT"/"OUTPUT_DIFF_INCOMING", and change
findExecutionConflictRow() to filter for the actual execution-count text printed
by the notebook (or modify the notebook to print the execution count) so the
waitFor() locators will reliably find the rows.
---
Nitpick comments:
In `@src/tests/settingsMatrix.test.ts`:
- Around line 401-407: The assertion message for the check on
resolvedCell.execution_count (the assert.notStrictEqual(...) call that currently
prefixes the message with "BUG:") should be reworded to avoid "BUG:" and provide
a clear, actionable description; locate the assert.notStrictEqual invocation
that references resolvedCell.execution_count and replace the message string with
a neutral, explanatory message such as "Expected resolvedCell.execution_count to
be non-null when autoResolveExecutionCount=false; got {value}" (include
resolvedCell.execution_count dynamically in the message) so triage won't be
confused.
- Around line 335-342: The assertion message for the assert.ok(surfaced, ...) is
misleading; change it from starting with "BUG:" to a clear test-expectation
message that states this test verifies the fix preventing kernel-only metadata
diffs from being swallowed when autoResolveKernelVersion=false, and include the
dynamic context (result.remainingConflicts.length and result.autoResolvedCount)
so failures show useful diagnostics; update the message near the assert.ok
reference to reflect that intent (mention "regression test: ensure kernel-only
metadata diffs are surfaced" plus the two result values).
- Line 783: The fixed sleep using page.waitForTimeout(400) causes flakiness;
replace it with a DOM-based wait that auto-retries — e.g., wait for the
.resolved-content-input on the specific row to be visible/stable by using
Playwright's expect(row.locator('.resolved-content-input')).toBeVisible({
timeout: 500 }) or an equivalent waitForSelector/assertion so the test proceeds
when the element is actually ready instead of after a hard timeout.
- Around line 147-148: The two empty catch blocks swallowing errors for cleanup
(around await page.close() and await browser.close()) should log the caught
errors instead of being silent; modify the catch handlers to capture the error
(e) and call an appropriate logger or console.error with context (e.g., "failed
to close page" / "failed to close browser") and the error object so teardown
failures are visible when tests are flaky; target the try/catch blocks that wrap
page.close() and browser.close() in src/tests/settingsMatrix.test.ts and ensure
logging is used rather than an empty catch.
ℹ️ Review info
Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 52879086-870a-4385-8849-62a02110c989
📒 Files selected for processing (1)
src/tests/settingsMatrix.test.ts
Matrix regression tests for settings
Fix dead code and ensure proper handling of settings in conflict resolution logic.
Summary by CodeRabbit
New Features
Refactor
Tests