Skip to content

Commit 09886d5

Browse files
committed
test(docs): exercise canvas interactions and container expansion
1 parent a5fba63 commit 09886d5

2 files changed

Lines changed: 76 additions & 11 deletions

File tree

‎apps/docs/scripts/benchmark-readiness.ts‎

Lines changed: 56 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ async function interactions(browser: Browser, profile: Profile, repetition: numb
949949
}
950950
})
951951
await apiControls(run, profile, repetition)
952-
await measure(profile, '/workflows', repetition, 'workflow-inspector-control', async () => {
952+
await measure(profile, '/workflows', repetition, 'workflow-canvas-control', async () => {
953953
await run.page.goto(new URL('/workflows', base).href, { waitUntil: 'domcontentloaded' })
954954
await meaningful(run.page, new URL('/workflows', base).pathname)
955955
const trigger = run.page
@@ -963,20 +963,65 @@ async function interactions(browser: Browser, profile: Profile, repetition: numb
963963
await dialog.waitFor()
964964
await painted(run.page)
965965
const feedbackMs = performance.now() - start
966-
const block = dialog
967-
.getByRole('group', { name: 'Inspect a block' })
968-
.getByRole('button')
969-
.first()
970-
if (await block.count()) {
971-
await block.click()
972-
await painted(run.page)
973-
}
966+
const canvas = dialog.locator('.react-flow__pane')
967+
const viewport = dialog.locator('.react-flow__viewport')
968+
const node = dialog.locator('.react-flow__node').first()
969+
await expect(node).toBeVisible()
970+
await painted(run.page)
971+
const bounds = await canvas.boundingBox()
972+
if (!bounds) throw new Error('Workflow canvas has no visible bounds')
973+
const transform = (element: Locator) =>
974+
element.evaluate((element) => {
975+
const matrix = new DOMMatrixReadOnly(getComputedStyle(element).transform)
976+
return { x: matrix.e, y: matrix.f, scale: matrix.a }
977+
})
978+
const beforePan = await transform(viewport)
979+
const x = bounds.x + bounds.width / 2
980+
const y = bounds.y + bounds.height - 24
981+
await run.page.mouse.move(x, y)
982+
await run.page.mouse.down()
983+
await run.page.mouse.move(x + 24, y - 24, { steps: 5 })
984+
await run.page.mouse.up()
985+
await expect.poll(async () => (await transform(viewport)).x).not.toBe(beforePan.x)
986+
const afterPan = await transform(viewport)
987+
expect(afterPan.scale).toBe(beforePan.scale)
988+
const beforeZoom = afterPan.scale
989+
await run.page.mouse.wheel(0, -80)
990+
await expect
991+
.poll(() =>
992+
viewport.evaluate(
993+
(element) => new DOMMatrixReadOnly(getComputedStyle(element).transform).a
994+
)
995+
)
996+
.toBeGreaterThan(beforeZoom)
997+
await node.click({ trial: true, position: { x: 8, y: 8 } })
998+
const afterZoom = await transform(viewport)
999+
const nodeBefore = await transform(node)
1000+
const nodeBounds = await node.boundingBox()
1001+
if (!nodeBounds) throw new Error('Workflow node has no visible bounds')
1002+
await run.page.mouse.move(nodeBounds.x + nodeBounds.width / 2, nodeBounds.y + 8)
1003+
await run.page.mouse.down()
1004+
await run.page.mouse.move(nodeBounds.x + nodeBounds.width / 2 + 20, nodeBounds.y + 28, {
1005+
steps: 5,
1006+
})
1007+
await run.page.mouse.up()
1008+
await expect
1009+
.poll(async () => {
1010+
const position = await transform(node)
1011+
return Math.hypot(position.x - nodeBefore.x, position.y - nodeBefore.y)
1012+
})
1013+
.toBeGreaterThan(1)
1014+
expect(await transform(viewport)).toEqual(afterZoom)
9741015
const data = {
975-
selectedBlock: (await block.count()) ? await block.textContent() : undefined,
976-
dialogTextLength: (await dialog.textContent())?.length,
1016+
beforePan,
1017+
afterPan,
1018+
afterZoom,
1019+
nodeBefore,
1020+
nodeAfter: await transform(node),
9771021
}
9781022
await run.page.keyboard.press('Escape')
9791023
await dialog.waitFor({ state: 'hidden' })
1024+
await expect(trigger).toBeFocused()
9801025
return { status: 'completed', feedbackMs, data }
9811026
})
9821027
for (const route of [

‎apps/docs/scripts/test-navigation-e2e.ts‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,26 @@ try {
608608
}
609609
})
610610
}
611+
for (const kind of ['loop', 'parallel']) {
612+
await check(`Inline ${kind} body opens lightbox at ${width}px`, async () => {
613+
const page = await context.newPage()
614+
try {
615+
await open(page, `/workflows/blocks/${kind}`)
616+
const container = page.locator('.react-flow__node-previewContainer').first()
617+
await expect(container).toBeVisible()
618+
const bounds = await container.boundingBox()
619+
if (!bounds) throw new Error('Container has no visible bounds')
620+
await container.click({ position: { x: bounds.width / 2, y: bounds.height - 8 } })
621+
const viewer = page.getByRole('dialog')
622+
await expect(viewer).toBeVisible()
623+
await page.screenshot({ path: join(directory, `${kind}-body-${width}.png`) })
624+
await page.keyboard.press('Escape')
625+
await expect(viewer).toHaveCount(0)
626+
} finally {
627+
await page.close()
628+
}
629+
})
630+
}
611631
await check(`Workflow lightbox at ${width}px`, async () => {
612632
const page = await context.newPage()
613633
try {

0 commit comments

Comments
 (0)