openpencil/tests/helpers/demo.ts
Danila Poyarkov 21ecce1f38 feat: assemble an editable demo document
Compose announcement, typography, and paint workbenches with native linked components and editable effects. Preserve the original examples on a reference page.

Wait for the canvas and existing fonts before layout, fit demo pages on first visits, and preserve user viewports thereafter.
2026-09-14 00:36:53 +03:00

25 lines
824 B
TypeScript

import type { Page } from '@playwright/test'
export async function waitForDemo(page: Page) {
await page.waitForFunction(() => {
const store = window.openPencil?.getStore?.()
return (
store?.graph.getNode(store.state.currentPageId)?.name === '01 · Components & variables' &&
store.state.preparation === null
)
})
}
export async function selectDemoReferencePage(page: Page) {
await waitForDemo(page)
await page.evaluate(async () => {
const store = window.openPencil?.getStore?.()
if (!store) throw new Error('OpenPencil store not initialized')
const reference = store.graph
.getPages()
.find((page) => page.name === 'Reference · original examples')
if (!reference) throw new Error('Demo reference page not found')
await store.switchPage(reference.id)
})
}