fix: correction de régression UI wizard first-run
This commit is contained in:
@ -2,16 +2,20 @@ import { describe, expect, it } from "vitest";
|
||||
import { fireEvent, render, screen, waitFor, within } from "@testing-library/react";
|
||||
|
||||
import { DIProvider } from "@/app/di";
|
||||
import { MockProfileGateway } from "@/adapters/mock";
|
||||
import { MockModelServerGateway, MockProfileGateway } from "@/adapters/mock";
|
||||
import type { Gateways } from "@/ports";
|
||||
import type { ProfileModelCatalog } from "@/domain";
|
||||
import type { LocalModelServerConfig, ProfileModelCatalog } from "@/domain";
|
||||
import { ProfilesSettings } from "./ProfilesSettings";
|
||||
|
||||
function renderSettings(profile: MockProfileGateway = new MockProfileGateway()) {
|
||||
function renderSettings(
|
||||
profile: MockProfileGateway = new MockProfileGateway(),
|
||||
modelServer: MockModelServerGateway = new MockModelServerGateway(),
|
||||
) {
|
||||
return {
|
||||
profile,
|
||||
modelServer,
|
||||
...render(
|
||||
<DIProvider gateways={{ profile } as unknown as Gateways}>
|
||||
<DIProvider gateways={{ profile, modelServer } as unknown as Gateways}>
|
||||
<ProfilesSettings />
|
||||
</DIProvider>,
|
||||
),
|
||||
@ -159,4 +163,62 @@ describe("ProfilesSettings", () => {
|
||||
await screen.findByText(/Ce modèle semble plus récent que votre Codex CLI 0\.145\.0/),
|
||||
).toBeTruthy();
|
||||
});
|
||||
|
||||
it("restores OpenCode local servers, local binding, and cloud provider choice in settings", async () => {
|
||||
const modelServer = new MockModelServerGateway();
|
||||
const server: LocalModelServerConfig = {
|
||||
id: "550e8400-e29b-41d4-a716-446655440000",
|
||||
kind: "llamaCpp",
|
||||
name: "Local A",
|
||||
baseURL: "http://localhost:8080/v1",
|
||||
port: 8080,
|
||||
servedModelName: "qwen3-coder-30b",
|
||||
host: "127.0.0.1",
|
||||
jinja: false,
|
||||
args: [],
|
||||
autoStart: false,
|
||||
stopPolicy: "stopOnAppExit",
|
||||
};
|
||||
await modelServer.saveModelServer(server);
|
||||
|
||||
const { profile } = renderSettings(new MockProfileGateway(), modelServer);
|
||||
await waitReady();
|
||||
|
||||
fireEvent.click(screen.getByRole("tab", { name: "OpenCode-local" }));
|
||||
await waitReady();
|
||||
|
||||
expect(screen.getByRole("button", { name: "add model server" })).toBeTruthy();
|
||||
expect(screen.getByText("Local A")).toBeTruthy();
|
||||
|
||||
await createProfile();
|
||||
const select = await screen.findByLabelText(
|
||||
"OpenCode + llama.cpp copy local model server",
|
||||
);
|
||||
fireEvent.change(select, { target: { value: server.id } });
|
||||
|
||||
const profileRow = select.closest("li");
|
||||
expect(profileRow).not.toBeNull();
|
||||
fireEvent.click(
|
||||
within(profileRow as HTMLElement).getByRole("button", {
|
||||
name: "Enregistrer",
|
||||
}),
|
||||
);
|
||||
|
||||
await waitFor(async () => {
|
||||
const saved = await profile.listProfiles();
|
||||
const opencode = saved.find((p) => p.structuredAdapter === "openCode");
|
||||
expect(opencode?.opencode?.localModelServerId).toBe(server.id);
|
||||
});
|
||||
|
||||
fireEvent.click(
|
||||
within(profileRow as HTMLElement).getByRole("radio", {
|
||||
name: "Provider cloud",
|
||||
}),
|
||||
);
|
||||
expect(
|
||||
await within(profileRow as HTMLElement).findByLabelText(
|
||||
"OpenCode + llama.cpp copy provider",
|
||||
),
|
||||
).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user