import { test, expect } from "@playwright/test"; const cases = [ { path: "/", input: '', output: /Name', output: /className="name" htmlFor="name"/ }, { path: "/typescript-to-javascript", input: "const answer: number = 42;", output: /const answer = 42/ }, { path: "/css-to-tailwind", input: ".example { display: flex; }", output: /@apply flex/ } ]; for (const fixture of cases) { test(`converts ${fixture.path}`, async ({ page }) => { await page.goto(fixture.path); const input = page.getByRole("textbox", { name: /Editor content/ }).first(); await expect(input).toBeVisible(); await page.evaluate( value => (window as any).monaco.editor.getModels()[0].setValue(value), fixture.input ); // Monaco virtualizes rendered lines; its model is the full user-visible editor value. await expect .poll(() => page.evaluate(() => { const editor = (window as any).monaco?.editor; return ( editor ?.getModels() .filter((model: any) => model.uri.scheme === "inmemory") .at(-1) ?.getValue() || "" ); }) ) .toMatch(fixture.output); }); } test("navigation preserves input across converter pages", async ({ page }) => { await page.goto("/json-to-yaml"); const input = page.getByRole("textbox", { name: /Editor content/ }).first(); await expect(input).toBeVisible(); await page.evaluate(() => (window as any).monaco.editor .getModels()[0] .setValue('{"migration":"preserved"}') ); await page.locator('a[href="/json-to-toml"]').click(); await expect(page).toHaveURL(/\/json-to-toml$/); await expect .poll(() => page.evaluate(() => (window as any).monaco?.editor.getModels()[0]?.getValue() ) ) .toBe('{"migration":"preserved"}'); await page.reload(); await expect .poll(() => page.evaluate(() => (window as any).monaco?.editor.getModels()[0]?.getValue() ) ) .toBe('{"migration":"preserved"}'); });