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"
44import { QueryClient , QueryClientProvider } from "@tanstack/react-query"
55
66import { vscode } from "@/utils/vscode"
77import { ExtensionStateContextProvider } from "@/context/ExtensionStateContext"
8+ import { DEFAULT_CHECKPOINT_TIMEOUT_SECONDS } from "@roo-code/types"
89
910import 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