import { expect } from "e2e";
import { test, WEB } from "./t3.ts";

test("Project OpenCode model is listed in an existing thread", WEB, async ({ t3, app, screen }) => {
  const project = await t3.project("Project A", { "opencode.jsonc": JSON.stringify({ provider: { uni: { npm: "@ai-sdk/openai-compatible", name: "uni", options: { baseURL: "http://127.0.0.1:9/v1", apiKey: "synthetic" }, models: { "medium-gpt": { name: "medium-gpt", limit: { context: 32000, output: 4000 } } } } } }) });
  await t3.project("Project B");
  await t3.thread({ project, title: "Existing project thread", messages: ["Hello"], model: "showcase" });
  await t3.open();
  await screen.getByRole("button", "Existing project thread,", { exact: false }).tap();
  await screen.getByRole("button", "showcase", { exact: false }).tap();
  await screen.getByRole("button", "OpenCode", { exact: true }).tap();
  await screen.getByPlaceholder("Search models...").fill("medium-gpt");
  await app.screenshot("project-a-existing-thread");
  await expect(screen.getByRole("option", "medium-gpt", { exact: false })).toBeVisible();
  await app.screenshot("project-a-model-loaded");
});
