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

test("Backspace restores literal list shortcut markers", WEB, async ({ t3, app, screen, browser }) => {
  await t3.project("Composer shortcuts");
  await t3.open();
  const composer = screen.getByRole("textbox");
  const restored: string[] = [];
  for (const [marker, label] of [["+ ", "plus"], ["* ", "asterisk"], ["1. ", "ordered"]]) {
    await composer.tap();
    await browser.keyboard.press("ControlOrMeta+A");
    await browser.keyboard.press("Backspace");
    await browser.keyboard.type(marker);
    await browser.locator('[contenteditable="true"] li').waitFor();
    await app.screenshot(`${label}-shortcut`);
    await browser.keyboard.press("Backspace");
    await app.screenshot(`${label}-after-backspace`);
    restored.push((await composer.textContent()).trim());
  }
  expect(restored).toEqual(["+", "*", "1."]);
});
