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

test("Semicolon CSV preserves a decimal comma in its second column", WEB, async ({ t3, app, screen }) => {
  const project = await t3.project("CSV preview", { "sample.csv": "a;b\n1;2,5" });
  const thread = await t3.thread({ project, title: "CSV preview", messages: ["Start"] });
  await t3.open(thread);
  await screen.getByRole("button", "Toggle right panel").tap();
  await screen.getByRole("button", "Files F").tap();
  await screen.getByRole("treeitem", "sample.csv").tap();
  await screen.getByRole("button", "Hide file explorer", { exact: true }).tap();
  await screen.getByRole("button", "Show source", { exact: true }).tap();
  await screen.getByRole("button", "Show table", { exact: true }).tap();
  await screen.getByRole("status").filter({ hasText: "1 KB" }).waitFor();
  await app.screenshot("csv-table");
  await expect(screen.getByRole("cell", "2,5", { exact: true })).toBeVisible();
  await expect(screen.getByRole("columnheader", "a", { exact: true })).toBeVisible();
  await expect(screen.getByRole("columnheader", "b", { exact: true })).toBeVisible();
  await expect(screen.getByRole("cell", "1", { exact: true })).toBeVisible();
});
