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

test("No project sends from New worktree with an unborn main branch", WEB, async ({ t3, app, screen, browser }) => {
  await t3.project("Demo");
  await t3.open();
  await screen.getByRole("button", "New thread", { exact: true }).tap();
  await screen.getByText("or start without a project", { exact: false }).tap();
  await screen.getByRole("combobox", "Branch: From main").tap();
  await screen.getByText("No refs found.").tap();
  await app.screenshot("empty-branch-picker");
  await browser.keyboard.press("Escape");
  await screen.getByRole("textbox").fill("hello");
  await screen.getByRole("textbox").press("Enter");
  try {
    await expect(screen.getByText("first fixture turn complete", { exact: false })).toBeVisible({ timeout: 30000 });
    await expect(screen.getByRole("button", "Stop generation")).toBeHidden();
  } finally {
    await app.screenshot("send-result");
  }
});
