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

test("A rate-limited workflow approval read reports the rate limit with Retry", WEB, async ({ t3, app, screen }) => {
  const project = await t3.project("Approval read proof", { ".git/config": "[remote \"origin\"]\nurl = https://github.com/pingdotgg/t3code.git\nfetch = +refs/heads/*:refs/remotes/origin/*\n" });
  await t3.open('/pull-requests');
  await screen.getByRole('searchbox', 'Search pull requests').fill('32990');
  await screen.getByText('fix(github): a rate-limited workflow approval read no longer shows a check awaiting action', { exact: true }).tap();
  await screen.getByText(/1 check awaiting action|GitHub API rate limit/).first().waitFor({ state: "visible", timeout: 60000 });
  await app.screenshot("workflow-approval-rate-limit");
  await expect(screen.getByRole("button", "Retry", { exact: true })).toBeVisible();
  await expect(screen.getByText(/GitHub API rate limit/).first()).toBeVisible();
});
