Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ModelID cannot be saved and refactor ModelPicker #1122

Merged
merged 4 commits into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions webview-ui/src/__mocks__/lucide-react.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import React from "react"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should really figure out to get pure ESM modules to work with our jest configuration 🤔

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried it before, try again now

Copy link
Author

@System233 System233 Feb 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cte
After trying it, adding the following configuration to jest can pass the test. Although it is better than mock export, I am not sure whether hard coding the cjs path is a good idea:

	moduleNameMapper: {
		"\\.(css|less|scss|sass)$": "identity-obj-proxy",
		"^vscrui$": "<rootDir>/src/__mocks__/vscrui.ts",
+  		"^lucide-react$": "<rootDir>/node_modules/lucide-react/dist/cjs/lucide-react.js",
		"^@vscode/webview-ui-toolkit/react$": "<rootDir>/src/__mocks__/@vscode/webview-ui-toolkit/react.ts",
		"^@/(.*)$": "<rootDir>/src/$1",
	},


export const Check = () => React.createElement("div")
export const ChevronsUpDown = () => React.createElement("div")
export const Loader = () => React.createElement("div")
export const X = () => React.createElement("div")
3 changes: 3 additions & 0 deletions webview-ui/src/__mocks__/vscrui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ export const Dropdown = ({ children, value, onChange }: any) =>

export const Pane = ({ children }: any) => React.createElement("div", { "data-testid": "mock-pane" }, children)

export const Button = ({ children, ...props }: any) =>
React.createElement("div", { "data-testid": "mock-button", ...props }, children)

export type DropdownOption = {
label: string
value: string
Expand Down
16 changes: 16 additions & 0 deletions webview-ui/src/components/settings/ApiErrorMessage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from "react"

interface ApiErrorMessageProps {
errorMessage: string | undefined
children?: React.ReactNode
}
const ApiErrorMessage = ({ errorMessage, children }: ApiErrorMessageProps) => {
return (
<div className="text-vscode-errorForeground text-sm">
<span style={{ fontSize: "2em" }} className={`codicon codicon-close align-middle mr-1`} />
{errorMessage}
{children}
</div>
)
}
export default ApiErrorMessage
Loading