Skip to content

Commit 7bc96ec

Browse files
committed
Fix tests
1 parent dd5224f commit 7bc96ec

File tree

4 files changed

+41
-34
lines changed

4 files changed

+41
-34
lines changed

webview-ui/src/components/chat/IndexingStatusBadge.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ export const IndexingStatusBadge: React.FC<IndexingStatusBadgeProps> = ({ classN
8989
<Button
9090
variant="ghost"
9191
size="sm"
92+
aria-label={tooltipText}
9293
className={cn(
9394
"relative h-7 w-7 p-0",
9495
"text-vscode-foreground opacity-85",

webview-ui/src/components/chat/__tests__/ApiConfigSelector.spec.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ describe("ApiConfigSelector", () => {
7676
render(<ApiConfigSelector {...defaultProps} />)
7777

7878
const trigger = screen.getByTestId("dropdown-trigger")
79-
// Check for the icon by looking for the codicon span element
80-
const icon = trigger.querySelector(".codicon-chevron-up")
79+
// Check for the icon by looking for the svg element (ChevronUp from lucide-react renders as svg)
80+
const icon = trigger.querySelector("svg")
8181
expect(icon).toBeInTheDocument()
8282
})
8383

webview-ui/src/components/chat/__tests__/ChatView.keyboard-fix.spec.tsx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,19 @@ vi.mock("react-i18next", () => ({
7373
}))
7474

7575
vi.mock("../ChatTextArea", () => {
76+
const ChatTextAreaComponent = React.forwardRef(function MockChatTextArea(
77+
_props: any,
78+
ref: React.ForwardedRef<{ focus: () => void }>,
79+
) {
80+
React.useImperativeHandle(ref, () => ({
81+
focus: vi.fn(),
82+
}))
83+
return <div data-testid="chat-textarea" />
84+
})
85+
7686
return {
77-
default: React.forwardRef(function MockChatTextArea(
78-
_props: any,
79-
ref: React.ForwardedRef<{ focus: () => void }>,
80-
) {
81-
React.useImperativeHandle(ref, () => ({
82-
focus: vi.fn(),
83-
}))
84-
return <div data-testid="chat-textarea" />
85-
}),
87+
default: ChatTextAreaComponent,
88+
ChatTextArea: ChatTextAreaComponent, // Export as named export too
8689
}
8790
})
8891

webview-ui/src/components/chat/__tests__/ChatView.spec.tsx

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -181,30 +181,33 @@ vi.mock("../ChatTextArea", () => {
181181
// eslint-disable-next-line @typescript-eslint/no-require-imports
182182
const mockReact = require("react")
183183

184+
const ChatTextAreaComponent = mockReact.forwardRef(function MockChatTextArea(
185+
props: ChatTextAreaProps,
186+
ref: React.ForwardedRef<{ focus: () => void }>,
187+
) {
188+
// Use useImperativeHandle to expose the mock focus method
189+
mockReact.useImperativeHandle(ref, () => ({
190+
focus: mockFocus,
191+
}))
192+
193+
return (
194+
<div data-testid="chat-textarea">
195+
<input
196+
ref={mockInputRef}
197+
type="text"
198+
onChange={(e) => {
199+
// With message queueing, onSend is always called (it handles queueing internally)
200+
props.onSend(e.target.value)
201+
}}
202+
data-sending-disabled={props.sendingDisabled}
203+
/>
204+
</div>
205+
)
206+
})
207+
184208
return {
185-
default: mockReact.forwardRef(function MockChatTextArea(
186-
props: ChatTextAreaProps,
187-
ref: React.ForwardedRef<{ focus: () => void }>,
188-
) {
189-
// Use useImperativeHandle to expose the mock focus method
190-
React.useImperativeHandle(ref, () => ({
191-
focus: mockFocus,
192-
}))
193-
194-
return (
195-
<div data-testid="chat-textarea">
196-
<input
197-
ref={mockInputRef}
198-
type="text"
199-
onChange={(e) => {
200-
// With message queueing, onSend is always called (it handles queueing internally)
201-
props.onSend(e.target.value)
202-
}}
203-
data-sending-disabled={props.sendingDisabled}
204-
/>
205-
</div>
206-
)
207-
}),
209+
default: ChatTextAreaComponent,
210+
ChatTextArea: ChatTextAreaComponent, // Export as named export too
208211
}
209212
})
210213

0 commit comments

Comments
 (0)