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

test("Selecting GitHub preserves GitLab in the tracker menu", WEB, async ({ t3, app, screen, browser }) => {
  await t3.project("GitHub project", { ".git/config": '[remote "origin"]\nurl = https://github.com/pingdotgg/t3code.git\nfetch = +refs/heads/*:refs/remotes/origin/*\n' });
  await t3.project("GitLab project", { ".git/config": '[remote "origin"]\nurl = https://gitlab.com/gitlab-org/gitlab-runner.git\nfetch = +refs/heads/*:refs/remotes/origin/*\n' });
  await t3.open("/issues");
  await screen.getByRole("button", "Filter by tracker: All").tap();
  await screen.getByRole("menuitemradio", "GitLab (gitlab.com)").waitFor({ state: "visible" });
  await app.screenshot("all-trackers");
  await screen.getByRole("menuitemradio", "GitHub (github.com)").tap();
  await browser.keyboard.press("Escape");
  await screen.getByRole("menuitemradio", "All", { exact: true }).waitFor({ state: "hidden" });
  await browser.waitForURL(/host=github.com/);
  await screen.getByRole("button", "Refresh issues", { disabled: false }).waitFor();
  await screen.getByRole("button", "Filter by tracker: GitHub (github.com)").tap();
  await screen.getByRole("menuitemradio", "All", { exact: true }).waitFor();
  await app.screenshot("tracker-menu-after-selecting-github");
  await expect(screen.getByRole("menuitemradio", "GitLab (gitlab.com)")).toBeVisible();
});
