Skip to content

Commit f9f4212

Browse files
committed
more tests
1 parent 34fc431 commit f9f4212

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

webview-ui/src/components/settings/__tests__/ContextManagementSettings.test.tsx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,43 @@ describe("ContextManagementSettings", () => {
207207
],
208208
}
209209

210+
it("toggles auto condense context setting", () => {
211+
const mockSetCachedStateField = jest.fn()
212+
const props = { ...autoCondenseProps, setCachedStateField: mockSetCachedStateField }
213+
render(<ContextManagementSettings {...props} />)
214+
215+
const checkbox = screen.getByTestId("auto-condense-context-checkbox")
216+
expect(checkbox).toBeChecked()
217+
218+
// Toggle off
219+
fireEvent.click(checkbox)
220+
expect(mockSetCachedStateField).toHaveBeenCalledWith("autoCondenseContext", false)
221+
222+
// Additional settings should not be visible when disabled
223+
expect(screen.queryByTestId("auto-condense-percent-slider")).not.toBeInTheDocument()
224+
expect(screen.queryByTestId("condensing-api-config-select")).not.toBeInTheDocument()
225+
expect(screen.queryByTestId("custom-condensing-prompt-textarea")).not.toBeInTheDocument()
226+
})
227+
228+
it("shows additional settings when auto condense is enabled", () => {
229+
render(<ContextManagementSettings {...autoCondenseProps} />)
230+
231+
// Additional settings should be visible
232+
expect(screen.getByTestId("auto-condense-percent-slider")).toBeInTheDocument()
233+
expect(screen.getByTestId("condensing-api-config-select")).toBeInTheDocument()
234+
expect(screen.getByTestId("custom-condensing-prompt-textarea")).toBeInTheDocument()
235+
})
236+
237+
it("hides additional settings when auto condense is disabled", () => {
238+
const props = { ...autoCondenseProps, autoCondenseContext: false }
239+
render(<ContextManagementSettings {...props} />)
240+
241+
// Additional settings should not be visible
242+
expect(screen.queryByTestId("auto-condense-percent-slider")).not.toBeInTheDocument()
243+
expect(screen.queryByTestId("condensing-api-config-select")).not.toBeInTheDocument()
244+
expect(screen.queryByTestId("custom-condensing-prompt-textarea")).not.toBeInTheDocument()
245+
})
246+
210247
it("updates auto condense context percent", () => {
211248
const mockSetCachedStateField = jest.fn()
212249
const props = { ...autoCondenseProps, setCachedStateField: mockSetCachedStateField }

0 commit comments

Comments
 (0)