Skip to content

Commit 05b04bc

Browse files
committed
Revert "temp"
This reverts commit cbab5a7.
1 parent 2124a15 commit 05b04bc

File tree

2 files changed

+11
-41
lines changed

2 files changed

+11
-41
lines changed

webview-ui/src/__mocks__/vscrui.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from "react"
22

3-
export const VSCodeCheckbox = ({ children, onChange }: any) =>
3+
export const Checkbox = ({ children, onChange }: any) =>
44
React.createElement("div", { "data-testid": "mock-checkbox", onClick: onChange }, children)
55

66
export const Dropdown = ({ children, onChange }: any) =>

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

Lines changed: 10 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from "react"
21
// npx jest src/components/settings/__tests__/ApiOptions.test.ts
32

43
import { render, screen, fireEvent } from "@testing-library/react"
@@ -16,23 +15,13 @@ jest.mock("@vscode/webview-ui-toolkit/react", () => ({
1615
VSCodeTextField: ({ children, value, onBlur }: any) => (
1716
<div>
1817
{children}
19-
<input type="text" value={value} onChange={onBlur || (() => {})} />
18+
<input type="text" value={value} onChange={onBlur} />
2019
</div>
2120
),
2221
VSCodeLink: ({ children, href }: any) => <a href={href}>{children}</a>,
2322
VSCodeRadio: ({ value, checked }: any) => <input type="radio" value={value} checked={checked} />,
2423
VSCodeRadioGroup: ({ children }: any) => <div>{children}</div>,
2524
VSCodeButton: ({ children }: any) => <div>{children}</div>,
26-
VSCodeCheckbox: ({ children, checked, onChange, ...props }: any) => (
27-
<div {...props}>
28-
<input
29-
type="checkbox"
30-
checked={checked}
31-
onChange={(e) => onChange && onChange({ target: { checked: e.target.checked } })}
32-
/>
33-
{children}
34-
</div>
35-
),
3625
}))
3726

3827
// Mock other components
@@ -53,32 +42,15 @@ jest.mock("vscrui", () => ({
5342
// Mock @shadcn/ui components
5443
jest.mock("@/components/ui", () => ({
5544
Select: ({ children, value, onValueChange }: any) => (
56-
<div className="select-mock" data-testid="shadcn-select-root">
57-
{React.Children.map(children, (child) => {
58-
if (React.isValidElement(child)) {
59-
// Pass down onValueChange and value to direct children
60-
return React.cloneElement(child as React.ReactElement<any>, {
61-
__rootValue: value,
62-
__onRootValueChange: onValueChange,
63-
})
64-
}
65-
return child
66-
})}
45+
<div className="select-mock">
46+
<select value={value} onChange={(e) => onValueChange && onValueChange(e.target.value)}>
47+
{children}
48+
</select>
6749
</div>
6850
),
69-
SelectTrigger: ({ children }: any) => <button className="select-trigger-mock">{children}</button>,
70-
SelectValue: ({ children, placeholder, __rootValue }: any) => (
71-
<span className="select-value-mock">{__rootValue || placeholder || children}</span>
72-
),
73-
SelectContent: ({ children, __rootValue, __onRootValueChange }: any) => (
74-
<select
75-
className="select-content-mock"
76-
value={__rootValue}
77-
onChange={(e) => __onRootValueChange && __onRootValueChange(e.target.value)}
78-
data-testid="shadcn-select-content">
79-
{children}
80-
</select>
81-
),
51+
SelectTrigger: ({ children }: any) => <div className="select-trigger-mock">{children}</div>,
52+
SelectValue: ({ children }: any) => <div className="select-value-mock">{children}</div>,
53+
SelectContent: ({ children }: any) => <div className="select-content-mock">{children}</div>,
8254
SelectItem: ({ children, value }: any) => (
8355
<option value={value} className="select-item-mock">
8456
{children}
@@ -94,15 +66,14 @@ jest.mock("@/components/ui", () => ({
9466
Command: ({ children }: any) => <div className="command-mock">{children}</div>,
9567
CommandEmpty: ({ children }: any) => <div className="command-empty-mock">{children}</div>,
9668
CommandGroup: ({ children }: any) => <div className="command-group-mock">{children}</div>,
97-
CommandInput: React.forwardRef(({ value, onValueChange, placeholder, className }: any, ref: any) => (
69+
CommandInput: ({ value, onValueChange, placeholder, className, _ref }: any) => (
9870
<input
99-
ref={ref}
10071
value={value}
10172
onChange={(e) => onValueChange && onValueChange(e.target.value)}
10273
placeholder={placeholder}
10374
className={className}
10475
/>
105-
)),
76+
),
10677
CommandItem: ({ children, value, onSelect }: any) => (
10778
<div className="command-item-mock" onClick={() => onSelect && onSelect(value)}>
10879
{children}
@@ -196,7 +167,6 @@ jest.mock("../ReasoningEffort", () => ({
196167
ReasoningEffort: ({ apiConfiguration, setApiConfigurationField, value }: any) => (
197168
<div data-testid="reasoning-effort-select">
198169
<select
199-
role="combobox"
200170
value={value ?? apiConfiguration.openAiCustomModelInfo?.reasoningEffort}
201171
onChange={(e) => setApiConfigurationField("reasoningEffort", e.target.value)}>
202172
<option value="auto">Auto</option>

0 commit comments

Comments
 (0)