import { execFileSync } from "node:child_process";
import { expect } from "e2e";
import { IOS, test } from "./t3-mobile.ts";

test("The Git menu shortens an emoji branch without broken characters", IOS, async ({ t3, app, screen }) => {
  const project = await t3.project("demo");
  execFileSync("git", ["checkout", "-b", "feature/abc😀-long-branch-name-😀-for-menus"], { cwd: project });
  await t3.thread({ project, title: "Branch work", messages: ["first"] });
  await t3.open();
  await screen.getByText("Branch work", { exact: false }).first().tap({ timeout: 120_000 });
  await screen.getByRole("button", "Git controls").tap();
  const branch = screen.getByLabel(/^feature\/abc/);
  await branch.waitFor();
  await app.screenshot("git-menu-branch");
  await expect(branch).toHaveAccessibleName("feature/abc…-for-menus, Clean");
});
