feat(web): add tools approvals models and images
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { ModelSettings } from "../src/components/settings/ModelSettings.js";
|
||||
|
||||
describe("ModelSettings", () => {
|
||||
it("saves through the server, clears the local key, and never uses browser storage", async () => {
|
||||
const user = userEvent.setup();
|
||||
const localSpy = vi.spyOn(Storage.prototype, "setItem");
|
||||
const save = vi.fn().mockResolvedValue({ configured: true, source: "session", keyHint: "••••cret" });
|
||||
render(<ModelSettings open onClose={vi.fn()} busy={false} onSave={save} onTest={vi.fn()} onClear={vi.fn()} />);
|
||||
|
||||
await user.type(screen.getByLabelText("API Key"), "sk-browser-secret");
|
||||
await user.type(screen.getByLabelText("模型 ID"), "gpt-test");
|
||||
await user.click(screen.getByRole("button", { name: "保存配置" }));
|
||||
|
||||
expect(save).toHaveBeenCalledWith(expect.objectContaining({ apiKey: "sk-browser-secret", modelId: "gpt-test" }));
|
||||
expect(screen.getByLabelText("API Key")).toHaveValue("");
|
||||
expect(screen.getByText("••••cret")).toBeVisible();
|
||||
expect(localSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user