Skip to content

Commit 8cd8501

Browse files
committed
test: adjust test with new checkbox fields
1 parent b28d0b7 commit 8cd8501

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

webview-ui/src/components/mcp/__tests__/McpToolRow.spec.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ describe("McpToolRow", () => {
9898

9999
render(<McpToolRow tool={alwaysAllowedTool} serverName="test-server" alwaysAllowMcp={true} />)
100100

101-
const checkbox = screen.getByRole("checkbox") as HTMLInputElement
102-
expect(checkbox.checked).toBe(true)
101+
const checkbox = screen.getByRole("checkbox")
102+
expect(checkbox).toHaveAttribute("aria-checked", "true")
103103
})
104104

105105
it("prevents event propagation when clicking the checkbox", () => {

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ describe("ContextManagementSettings", () => {
119119
render(<ContextManagementSettings {...defaultProps} includeDiagnosticMessages={true} />)
120120

121121
const checkbox = screen.getByTestId("include-diagnostic-messages-checkbox")
122-
expect(checkbox.querySelector("input")).toBeChecked()
122+
expect(checkbox).toHaveAttribute("data-state", "checked")
123123

124124
const slider = screen.getByTestId("max-diagnostic-messages-slider")
125125
expect(slider).toBeInTheDocument()
@@ -130,7 +130,7 @@ describe("ContextManagementSettings", () => {
130130
render(<ContextManagementSettings {...defaultProps} includeDiagnosticMessages={false} />)
131131

132132
const checkbox = screen.getByTestId("include-diagnostic-messages-checkbox")
133-
expect(checkbox.querySelector("input")).not.toBeChecked()
133+
expect(checkbox).toHaveAttribute("data-state", "unchecked")
134134

135135
// Slider should still be rendered when diagnostics are disabled
136136
expect(screen.getByTestId("max-diagnostic-messages-slider")).toBeInTheDocument()
@@ -141,7 +141,7 @@ describe("ContextManagementSettings", () => {
141141
const setCachedStateField = vi.fn()
142142
render(<ContextManagementSettings {...defaultProps} setCachedStateField={setCachedStateField} />)
143143

144-
const checkbox = screen.getByTestId("include-diagnostic-messages-checkbox").querySelector("input")!
144+
const checkbox = screen.getByTestId("include-diagnostic-messages-checkbox")
145145
fireEvent.click(checkbox)
146146

147147
await waitFor(() => {
@@ -332,7 +332,7 @@ describe("ContextManagementSettings", () => {
332332
// Always full read checkbox
333333
const alwaysFullReadCheckbox = screen.getByTestId("max-read-file-always-full-checkbox")
334334
expect(alwaysFullReadCheckbox).toBeInTheDocument()
335-
expect(alwaysFullReadCheckbox).not.toBeChecked()
335+
expect(alwaysFullReadCheckbox).toHaveAttribute("data-state", "unchecked")
336336
})
337337

338338
it("updates max read file line setting", () => {
@@ -399,8 +399,7 @@ describe("ContextManagementSettings", () => {
399399
render(<ContextManagementSettings {...props} />)
400400

401401
const checkbox = screen.getByTestId("auto-condense-context-checkbox")
402-
const input = checkbox.querySelector('input[type="checkbox"]')
403-
expect(input).toBeChecked()
402+
expect(checkbox).toHaveAttribute("data-state", "checked")
404403

405404
// Toggle off
406405
fireEvent.click(checkbox)
@@ -445,8 +444,7 @@ describe("ContextManagementSettings", () => {
445444
render(<ContextManagementSettings {...propsWithMaxReadFileLine} />)
446445

447446
const checkbox = screen.getByTestId("max-read-file-always-full-checkbox")
448-
const input = checkbox.querySelector('input[type="checkbox"]')
449-
expect(input).toBeChecked()
447+
expect(checkbox).toHaveAttribute("data-state", "checked")
450448
})
451449

452450
it("handles boundary values for sliders", () => {
@@ -507,7 +505,7 @@ describe("ContextManagementSettings", () => {
507505
expect(input).toHaveValue(-1)
508506
expect(input).not.toBeDisabled() // Input is not disabled when maxReadFileLine is undefined (only when explicitly set to -1)
509507
expect(checkbox).toBeInTheDocument()
510-
expect(checkbox).not.toBeChecked() // Checkbox is not checked when maxReadFileLine is undefined (only when explicitly set to -1)
508+
expect(checkbox).toHaveAttribute("data-state", "unchecked") // Checkbox is not checked when maxReadFileLine is undefined (only when explicitly set to -1)
511509
})
512510
})
513511

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ describe("UISettings", () => {
1616

1717
it("displays the correct initial state", () => {
1818
const { getByTestId } = render(<UISettings {...defaultProps} reasoningBlockCollapsed={true} />)
19-
const checkbox = getByTestId("collapse-thinking-checkbox") as HTMLInputElement
20-
expect(checkbox.checked).toBe(true)
19+
const checkbox = getByTestId("collapse-thinking-checkbox")
20+
expect(checkbox).toHaveAttribute("data-state", "checked")
2121
})
2222

2323
it("calls setCachedStateField when checkbox is toggled", async () => {
@@ -34,10 +34,10 @@ describe("UISettings", () => {
3434

3535
it("updates checkbox state when prop changes", () => {
3636
const { getByTestId, rerender } = render(<UISettings {...defaultProps} reasoningBlockCollapsed={false} />)
37-
const checkbox = getByTestId("collapse-thinking-checkbox") as HTMLInputElement
38-
expect(checkbox.checked).toBe(false)
37+
const checkbox = getByTestId("collapse-thinking-checkbox")
38+
expect(checkbox).toHaveAttribute("data-state", "unchecked")
3939

4040
rerender(<UISettings {...defaultProps} reasoningBlockCollapsed={true} />)
41-
expect(checkbox.checked).toBe(true)
41+
expect(checkbox).toHaveAttribute("data-state", "checked")
4242
})
4343
})

0 commit comments

Comments
 (0)