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

test("Browser starts with sh on PATH while /bin/sh is absent", WEB, async ({ t3, app, screen, browser }) => {
  const project = await t3.project("browser-proof");
  const thread = await t3.thread({ project, title: "Browser shell proof", model: "default", messages: ["Start"] });
  await t3.open(thread);
  await screen.getByRole("button", "Toggle right panel", { exact: true }).waitFor();
  await browser.keyboard.press("Control+Shift+J");
  const address = screen.getByRole("textbox", "Search or enter URL", { exact: true });
  await address.waitFor();
  try {
    await expect(address).toBeEnabled({ timeout: 45_000 });
    await address.fill("https://example.com");
    await address.press("Enter");
    await expect(address).toHaveValue("https://example.com/", { timeout: 45_000 });
    await expect(screen.getByRole("button", "Refresh", { exact: true })).toBeEnabled({ timeout: 45_000 });
  } finally {
    await app.screenshot("browser-without-bin-sh");
  }
});
