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

test("Completing a list marker converts existing composer text", WEB, async ({ t3, app, screen, browser }) => {
  await t3.project("List marker demo");
  await t3.open();
  await browser.locator("[contenteditable=true]").tap();
  await app.open("/settings/chat");
  const richText = screen.getByRole("switch", "Rich text composer");
  if (!(await richText.isChecked())) await richText.tap();
  await app.open("/");
  const composer = screen.getByRole("textbox");
  await composer.tap();
  await browser.keyboard.type("-get md");
  await browser.keyboard.press("Shift+Enter");
  await browser.keyboard.type("second line");
  await browser.keyboard.press("Control+Home");
  await browser.keyboard.press("ArrowRight");
  await browser.keyboard.type(" ");
  await screen.getByText("second line", { exact: false }).last().tap();
  await app.screenshot("completed-list-marker");
  await expect(browser.locator('[data-composer-rich-text="true"] li')).toBeVisible();
  await expect(composer).toContainText("second line");
});
