import { expect } from "e2e";

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

test("Backslash paths stay ordinary composer text", WEB, async ({ t3, app, screen }) => {
  const project = await t3.project("path-examples");
  await t3.thread({ project, title: "Path examples", messages: ["Ready for path examples."] });
  await t3.open();
  await screen.getByRole("button", "Path examples, Done, path-examples").tap();
  const composer = screen.getByRole("textbox");

  await composer.fill("/Windows\\System32");
  await composer.press("End");
  await app.screenshot("windows-system32");

  await composer.fill("");
  await composer.fill("cmd /foo\\bar");
  await composer.press("End");
  await app.screenshot("command-backslash-path");

  await composer.fill("");
  await composer.fill("/tmp/build.sh");
  await composer.press("End");
  await app.screenshot("forward-slash-control");

  await composer.fill("/Windows\\System32");
  await composer.press("End");
  await expect(screen.getByText("No matching command.", { exact: true })).toBeHidden();
  await composer.fill("cmd /foo\\bar");
  await composer.press("End");
  await expect(screen.getByText("No matching command.", { exact: true })).toBeHidden();
});
