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

test("Rate-limited review threads show the activity error and retry", WEB, async ({ t3, app, screen, browser }) => {
  await browser.emulateMedia({ colorScheme: "dark" });
  await t3.project("Review thread proof", { ".git/config": '[remote "origin"]\n  url = https://github.com/pingdotgg/t3code.git\n  fetch = +refs/heads/*:refs/remotes/origin/*\n' });
  await t3.open("/pull-requests?selectedUrl=https%3A%2F%2Fgithub.com%2Fpingdotgg%2Ft3code%2Fpull%2F36988&state=all&repository=pingdotgg%2Ft3code&number=36988&host=github.com");
  await screen.getByRole("button", "Maximize panel", { exact: true }).tap();
  await screen.getByRole("button", "Timeline", { exact: true }).tap();
  try {
    await expect(screen.getByText("Could not load pull request activity", { exact: true, visible: true })).toBeVisible({ timeout: 20000 });
  } finally {
    await app.screenshot("review-thread-rate-limit");
  }
  await expect(screen.getByRole("button", "Retry", { exact: true, visible: true })).toBeVisible();
});
