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

test("Codex installed by the mise npm backend updates to latest", WEB, async ({ t3, app, screen, browser }) => {
  await t3.project("mise-update-demo");
  await t3.open("/settings/providers");
  await browser.evaluate(() => {
    const style = document.createElement("style");
    style.textContent = "*, *::before, *::after { animation: none !important; transition: none !important; }";
    document.head.appendChild(style);
  });
  await screen.getByRole("button", "Update available, view details").first().tap();
  await app.screenshot("before-update");
  await screen.getByRole("button", "Update now").tap();
  await expect(screen.getByText("Updating", { exact: true })).toBeHidden({ timeout: 120_000 });
  await app.screenshot("after-update");
  await expect(screen.getByText("v0.167.2", { exact: true }).first()).toBeVisible({ timeout: 30_000 });
});
