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

test("Antigravity download failure explains the network cause", WEB, async ({ t3, app, screen }) => {
  await t3.open();
  await screen.getByRole("button", "Start", { exact: true }).tap();
  await screen.getByRole("button", "Add project", { exact: true }).first().waitFor({ state: "visible" });
  await app.open("/settings/providers");
  await screen.getByRole("button", "Add provider").first().tap();
  await screen.getByRole("button", "Show more").tap();
  await screen.getByRole("radio", "Antigravity").tap();
  await screen.getByRole("button", "Next", { exact: true }).tap();
  await screen.getByRole("button", "Next", { exact: true }).tap();
  await screen.getByRole("button", "Add instance", { exact: true }).tap();
  await screen.getByRole("button", "Install Antigravity", { exact: true }).tap();
  await screen.getByRole("button", "Retry installation", { exact: true }).waitFor({ state: "visible" });
  await screen.getByText("Provider instance added", { exact: true }).waitFor({ state: "hidden" });
  await app.screenshot("download-error");
  await new Promise((resolve) => setTimeout(resolve, 500));
  await app.screenshot("download-error-stable");
  await expect(screen.getByText("Could not download Antigravity from Google. Check the network connection and any proxy settings, then try again.", { exact: true })).toBeVisible();
});
