fix(test): update component tests to match current implementation

- Add JsonEditor mock to McpFormModal tests (component uses CodeMirror
  instead of Textarea)
- Fix assertion for missing command error message
- Update ImportExportSection tests for new button behavior and file
  display format
This commit is contained in:
Jason
2025-11-28 16:20:18 +08:00
parent 3878a16c4f
commit f4c284f86c
2 changed files with 19 additions and 8 deletions

View File

@@ -79,6 +79,17 @@ vi.mock("@/components/ui/textarea", () => ({
),
}));
vi.mock("@/components/JsonEditor", () => ({
default: ({ value, onChange, placeholder, ...rest }: any) => (
<textarea
value={value}
placeholder={placeholder}
onChange={(event) => onChange?.(event.target.value)}
{...rest}
/>
),
}));
vi.mock("@/components/ui/checkbox", () => ({
Checkbox: ({ id, checked, onCheckedChange, ...rest }: any) => (
<input
@@ -256,7 +267,7 @@ describe("McpFormModal", () => {
await waitFor(() => expect(toastErrorMock).toHaveBeenCalled());
expect(upsertMock).not.toHaveBeenCalled();
const [message] = toastErrorMock.mock.calls.at(-1) ?? [];
expect(message).toBe("mcp.error.jsonInvalid");
expect(message).toBe("mcp.error.commandRequired");
});
it("支持向导生成配置并自动填充 ID", async () => {