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

test("Send submits a draft containing only a thread context", WEB, async ({ t3, app, screen }) => {
  const project = await t3.project("Demo");
  await t3.thread({ project, title: "Source thread", messages: ["Source context"] });
  await t3.open();
  const composer = screen.getByRole("textbox");
  await composer.pressSequentially("@Source");
  await screen.getByRole("option", "Source thread", { exact: false }).tap();
  const send = screen.getByRole("button", "Submit message", { exact: true });
  await app.screenshot("thread-context-only");
  await expect(send).toBeEnabled();
  await send.tap();
  await expect(composer).toHaveText("");
  await expect(screen.getByText("Source thread", { exact: true }).last()).toBeVisible();
  await app.screenshot("submitted-thread-context");
});
