mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-08-04 19:45:34 +08:00
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:
@@ -32,17 +32,17 @@ describe("ImportExportSection Component", () => {
|
||||
it("should disable import button and show placeholder when no file selected", () => {
|
||||
render(<ImportExportSection {...baseProps} />);
|
||||
|
||||
expect(screen.getByText("settings.noFileSelected")).toBeInTheDocument();
|
||||
// When no file selected, button shows "selectConfigFile" and clicking it opens file dialog
|
||||
expect(
|
||||
screen.getByRole("button", { name: "settings.import" }),
|
||||
).toBeDisabled();
|
||||
screen.getByRole("button", { name: /settings\.selectConfigFile/ }),
|
||||
).toBeInTheDocument();
|
||||
fireEvent.click(
|
||||
screen.getByRole("button", { name: "settings.exportConfig" }),
|
||||
);
|
||||
expect(baseProps.onExport).toHaveBeenCalledTimes(1);
|
||||
|
||||
fireEvent.click(
|
||||
screen.getByRole("button", { name: "settings.selectConfigFile" }),
|
||||
screen.getByRole("button", { name: /settings\.selectConfigFile/ }),
|
||||
);
|
||||
expect(baseProps.onSelectFile).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
@@ -55,15 +55,15 @@ describe("ImportExportSection Component", () => {
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(screen.getByText("config.json")).toBeInTheDocument();
|
||||
expect(screen.getByText(/config\.json/)).toBeInTheDocument();
|
||||
const importButton = screen.getByRole("button", {
|
||||
name: "settings.import",
|
||||
name: /settings\.import/,
|
||||
});
|
||||
expect(importButton).toBeEnabled();
|
||||
fireEvent.click(importButton);
|
||||
expect(baseProps.onImport).toHaveBeenCalledTimes(1);
|
||||
|
||||
fireEvent.click(screen.getByRole("button", { name: "common.clear" }));
|
||||
fireEvent.click(screen.getByRole("button", { name: "Clear selection" }));
|
||||
expect(baseProps.onClear).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user