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

test("Forgejo discovery accepts the second configured fj login", WEB, async ({ t3, app, screen, browser }) => {
  await t3.project("forgejo-login-demo");
  await t3.open("/settings/source-control");
  await screen.getByRole("button", "Rescan server environment").tap();
  await screen.getByRole("button", "Rescan server environment").waitFor({ state: "visible" });
  const offer = screen.getByRole("switch", "Offer Forgejo / Gitea when adding or publishing a project");
  await offer.scrollIntoView();
  await browser.locator('button[aria-label="Rescan server environment"]:not(:disabled)').waitFor();
  await app.screenshot("forgejo-login-status");
  await expect(browser.locator("div.px-3.py-3").filter({ hasText: "Forgejo / Gitea" }).getByText("Authenticated", { exact: true })).toBeVisible();
});
