Skip to content

Commit e12e961

Browse files
test(settings): name perWriteCheckpoints in the checkpoint payload assertions
The checkpoint and terminal payload assertions used objectContaining, which cannot fail when a key is missing from the updateSettings payload at all: dropping perWriteCheckpoints from the payload leaves every existing case green. The fallback-defaults case now names the key, and a new case loads a stored true, un-checks the box, and saves, so the payload has to carry the false the user chose rather than the display default. Test-only: SettingsView.tsx is untouched. On the shipped payload line, removing the key fails both assertions, and replacing the value with the default constant fails only the new case. The LogicalOperator mutant the mutation CI drew at :418 (?? changed to &&) leaves the suite green, because the webview state default means the left operand is never undefined at submit, so that mutant is equivalent here. Answering the codeRabbit thread on webview-ui/src/components/settings/SettingsView.tsx:418 (#1406).
1 parent 6bc14e7 commit e12e961

1 file changed

Lines changed: 36 additions & 1 deletion

File tree

‎webview-ui/src/components/settings/__tests__/SettingsView.spec.tsx‎

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ import { renderWithExtensionState, screen, fireEvent, within, waitFor } from "@/
44
import { act } from "@testing-library/react"
55

66
import { vscode } from "@/utils/vscode"
7-
import { DEFAULT_CHECKPOINT_TIMEOUT_SECONDS, type ProviderSettings } from "@roo-code/types"
7+
import {
8+
DEFAULT_CHECKPOINT_TIMEOUT_SECONDS,
9+
DEFAULT_PER_WRITE_CHECKPOINTS,
10+
type ProviderSettings,
11+
} from "@roo-code/types"
812
import type { ApiOptionsProps } from "../ApiOptions"
913

1014
import SettingsView from "../SettingsView"
@@ -527,13 +531,44 @@ describe("SettingsView - Sound Settings", () => {
527531
soundEnabled: true,
528532
enableCheckpoints: false,
529533
checkpointTimeout: DEFAULT_CHECKPOINT_TIMEOUT_SECONDS,
534+
perWriteCheckpoints: DEFAULT_PER_WRITE_CHECKPOINTS,
530535
terminalShellIntegrationTimeout: 30_000,
531536
}),
532537
}),
533538
),
534539
)
535540
})
536541

542+
it("saves a disabled per-write checkpoints setting as false in the updateSettings payload", () => {
543+
// CheckpointSettings.spec.tsx covers the control's render and its setter; this
544+
// is the UI-to-payload link: a stored true that the user un-checks has to reach
545+
// the save payload as false, not as the display default. The neighbouring cases
546+
// assert with objectContaining, which ignores a key that is missing from the
547+
// payload entirely, so this key is named here. The per-write checkbox is the
548+
// first checkbox of the checkpoints section and the enable-checkpoints box is
549+
// seeded false, so the two boxes are told apart by their state, not by order.
550+
renderWithExtensionState(<SettingsView onDone={vi.fn()} targetSection="checkpoints" />, {
551+
state: { perWriteCheckpoints: true, enableCheckpoints: false },
552+
})
553+
554+
const content = screen.getByTestId("settings-content")
555+
const [perWriteCheckbox, enableCheckbox] = within(content).getAllByRole("checkbox")
556+
expect(perWriteCheckbox).toHaveProperty("checked", true)
557+
expect(enableCheckbox).toHaveProperty("checked", false)
558+
559+
fireEvent.click(perWriteCheckbox)
560+
fireEvent.click(screen.getByTestId("save-button"))
561+
562+
expect(vscode.postMessage).toHaveBeenCalledWith(
563+
expect.objectContaining({
564+
type: "updateSettings",
565+
updatedSettings: expect.objectContaining({
566+
perWriteCheckpoints: false,
567+
}),
568+
}),
569+
)
570+
})
571+
537572
it("shows tts slider when sound is enabled", () => {
538573
// Render once and get the activateTab helper
539574
const { activateTab, getSettingsContent } = renderSettingsView()

0 commit comments

Comments
 (0)