import type { Page } from '@playwright/test'; export const scriptMarker = 'E2E prompter script'; /** long enough that the document scrolls well past a screen */ export const scriptText = `${scriptMarker}. `.repeat(40); /** * Puts a known script into whichever rundown happens to be loaded. * * Specs which read the rundown cannot rely on the uploaded fixture surviving: * the suite runs serially and earlier specs add, edit and delete entries, while * 214 creates a fresh rundown and leaves it loaded. Seeding is idempotent, so * the rundown gains one event no matter how many tests have run before. */ export async function seedScript(page: Page) { const rundown = await (await page.request.get('/data/rundowns/current')).json(); const alreadySeeded = rundown.flatOrder.some((id: string) => rundown.entries[id]?.note?.startsWith(scriptMarker)); if (alreadySeeded) return; await page.request.post(`/data/rundowns/${rundown.id}/entry`, { data: { type: 'event', title: 'Teleprompter e2e', note: scriptText }, }); }