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

test("Side-chat drafts show Send while Replay is working in steer and queue modes", WEB, async ({ t3, app, screen, browser }) => {
  const project = await t3.project("Side chat demo", { "src/math.ts": "export const sum = 1 + 1;\n" });
  const thread = await t3.thread({ project, title: "Side chat send icon", messages: ["Initial tour"], model: "showcase" });
  const labels: string[] = [];
  for (const behavior of ["steer", "queue"]) {
    await t3.open("/settings/chat");
    await screen.getByRole("combobox", "Follow-up behavior").tap();
    await screen.getByRole("option", behavior === "queue" ? "Queue" : "Steer", { exact: true }).tap();
    await t3.open(thread);
    const composer = screen.getByRole("textbox");
    await composer.fill("Give me another short tour");
    await composer.press("Enter");
    await screen.getByRole("button", "Stop generation", { exact: true }).getAttribute("aria-label");
    for (const command of ["btw", "side"]) {
      await composer.fill(`/${command} what is this?`);
      await app.screenshot(`${behavior}-${command}-while-working`);
      labels.push(await screen.getByRole("button", /^(Submit|Queue|Steer) message$/).getAttribute("aria-label") ?? "missing");
    }
    await composer.fill("");
    await screen.getByRole("button", "Stop generation", { exact: true }).tap();
  }
  expect(labels).toEqual(["Submit message", "Submit message", "Submit message", "Submit message"]);
});
