Skip to content

Commit 324ddf7

Browse files
committed
test(settings): cover settings fallback defaults
1 parent fdfff90 commit 324ddf7

1 file changed

Lines changed: 27 additions & 3 deletions

File tree

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

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
// pnpm --filter @roo-code/vscode-webview test src/components/settings/__tests__/SettingsView.spec.tsx
22

3-
import { render, screen, fireEvent, within } from "@/utils/test-utils"
3+
import { render, screen, fireEvent, within, waitFor } from "@/utils/test-utils"
44
import { QueryClient, QueryClientProvider } from "@tanstack/react-query"
55

66
import { vscode } from "@/utils/vscode"
77
import { ExtensionStateContextProvider } from "@/context/ExtensionStateContext"
8+
import { DEFAULT_CHECKPOINT_TIMEOUT_SECONDS } from "@roo-code/types"
89

910
import SettingsView from "../SettingsView"
1011

@@ -287,7 +288,7 @@ const mockPostMessage = (state: any) => {
287288
)
288289
}
289290

290-
const renderSettingsView = () => {
291+
const renderSettingsView = (initialState: any = {}) => {
291292
const onDone = vi.fn()
292293
const queryClient = new QueryClient()
293294

@@ -300,7 +301,7 @@ const renderSettingsView = () => {
300301
)
301302

302303
// Hydrate initial state.
303-
mockPostMessage({})
304+
mockPostMessage(initialState)
304305

305306
// Helper function to activate a tab and ensure its content is visible
306307
const activateTab = (tabId: string) => {
@@ -443,6 +444,29 @@ describe("SettingsView - Sound Settings", () => {
443444
)
444445
})
445446

447+
it("saves fallback defaults for checkpoint and terminal settings", async () => {
448+
renderSettingsView({
449+
enableCheckpoints: undefined,
450+
checkpointTimeout: undefined,
451+
terminalShellIntegrationTimeout: undefined,
452+
settingsImportedAt: new Date().toISOString(),
453+
})
454+
455+
await waitFor(() => expect(screen.getByTestId("save-button")).toBeInTheDocument())
456+
fireEvent.click(screen.getByTestId("save-button"))
457+
458+
expect(vscode.postMessage).toHaveBeenCalledWith(
459+
expect.objectContaining({
460+
type: "updateSettings",
461+
updatedSettings: expect.objectContaining({
462+
enableCheckpoints: false,
463+
checkpointTimeout: DEFAULT_CHECKPOINT_TIMEOUT_SECONDS,
464+
terminalShellIntegrationTimeout: 30_000,
465+
}),
466+
}),
467+
)
468+
})
469+
446470
it("shows tts slider when sound is enabled", () => {
447471
// Render once and get the activateTab helper
448472
const { activateTab, getSettingsContent } = renderSettingsView()

0 commit comments

Comments
 (0)