import { expect } from "e2e";
import { copyFileSync } from "node:fs";
import { join } from "node:path";
import { APP_DIR } from "../e2e.config.ts";
import { test, WEB } from "./t3.ts";

test("Git Bash image paths load on a Windows host", WEB, async ({ t3, app, screen, browser }) => {
  copyFileSync("C:/proof38088/transcript.ndjson", join(APP_DIR, "apps/server/scripts/dev-replay/command_output_transcript.ndjson"));
  const project = await t3.project("Windows-path-proof");
  const thread = await t3.thread({project, title: "Windows path comparison", messages: ["Show the Git Bash and drive-path image and file links."], model: "command-output"});
  await t3.open(thread);
  await screen.getByText("drive link").waitFor({ state: "visible" });
  await browser.locator('img[alt="drive"]').waitFor({ state: "visible" });
  await app.screenshot("images");
  await expect.poll(() => browser.evaluate(() =>
    (document.querySelector('img[alt="gitbash"]') as HTMLImageElement | null)?.naturalWidth ?? 0,
  )).toBe(200);
});
