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

test("Pull Requests honors the gh OWNER/REPO default", WEB, async ({ t3, app, screen, browser }) => {
  await t3.project("Remote identity demo", {
    ".git/config": `[core]
  repositoryformatversion = 0
  bare = false
[remote "fork"]
  url = https://github.com/juliusmarminge/t3code.git
  fetch = +refs/heads/*:refs/remotes/fork/*
  gh-resolved = pingdotgg/t3code
[remote "main"]
  url = https://github.com/pingdotgg/t3code.git
  fetch = +refs/heads/*:refs/remotes/main/*
[remote "upstream"]
  url = https://github.com/cli/cli.git
  fetch = +refs/heads/*:refs/remotes/upstream/*
`,
  });
  await t3.open("/pull-requests");
  await screen.getByRole("button", "Filters", { exact: false }).tap();
  await screen.getByRole("menuitem", "Project All projects", { exact: true }).tap();
  await screen.getByRole("menuitemradio", "Remote identity demo", { exact: false }).tap();
  await browser.keyboard.press("Escape");
  await browser.keyboard.press("Escape");
  await screen.getByText(/^(cli\/cli|pingdotgg\/t3code)$/).first().waitFor({ state: "visible", timeout: 120000 });
  await app.screenshot("project-pull-requests");
  await expect(screen.getByText("pingdotgg/t3code", { exact: true }).first()).toBeVisible();
});
