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

test("Welcome imports both root and linked worktree conversations", WEB, async ({t3, app, screen, browser}) => {
  await t3.open("/welcome");
  await screen.getByRole("button", "Review all 1").tap();
  await screen.getByRole("checkbox", "sample-project", {exact: false}).tap();
  await app.screenshot("offered-sessions");
  await screen.getByRole("button", "Import 1 project and start", {exact: true}).tap();
  await screen.getByTestId("sidebar-settled-shelf-toggle").tap();
  await screen.getByRole("button", "Root conversation", {exact: false}).tap();
  await screen.getByRole("heading", "Root conversation", {exact: true}).tap();
  await browser.keyboard.press("Escape");
  await screen.getByText("Synthetic conversation ready for import.", {exact: true}).tap();
  await app.screenshot("imported-sessions");
  await expect(screen.getByRole("button", "Worktree conversation", {exact: false})).toBeVisible();
  await screen.getByRole("button", "Worktree conversation", {exact: false}).tap();
  await screen.getByRole("heading", "Worktree conversation", {exact: true}).tap();
  await browser.keyboard.press("Escape");
  await screen.getByText("Synthetic conversation ready for import.", {exact: true}).tap();
  await app.screenshot("worktree-context");
});
