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

test("GitHub README view state resolves to the repository", WEB, async ({ t3, app, screen }) => {
  await t3.project("demo");
  const openRepository = async (repo: string) => {
    await t3.open(`/new?prompt=Explain%20this%20repository&repo=${encodeURIComponent(repo)}`);
    await screen.getByText(/You don't have octocat\/Hello-World|Could not open the link/).waitFor({ timeout: 30_000 });
  };
  await openRepository("https://github.com/octocat/Hello-World");
  await app.screenshot("plain-repository-control");
  await openRepository("https://github.com/octocat/Hello-World?tab=readme-ov-file#readme");
  await app.screenshot("readme-repository-link");
  await expect(screen.getByRole("button", "Clone octocat/Hello-World", { exact: true })).toBeVisible();
});
