Skip to content

Commit bc7e1ee

Browse files
committed
test: measure runtime reflow at a fixed zoom above the LOD threshold
Fit-to-view on this workflow lands at ~0.52 zoom, below the LOD threshold (~0.57 at DPR 1) where nodes render as canvas boxes and no Vue components mount, so the fixture's visibility assertion had nothing to find. Center the node under test at a deterministic 0.8 zoom instead.
1 parent 175b782 commit bc7e1ee

1 file changed

Lines changed: 39 additions & 2 deletions

File tree

browser_tests/fixtures/utils/runtimeReflow.ts

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,51 @@ interface ReflowNodeUnderTest {
2323
}
2424

2525
/**
26-
* Adds a reflow node, fits it into view, and captures its starting height so a
27-
* test can assert on the height delta after triggering runtime growth.
26+
* Zoom at which the node under test is measured. Must sit above the LOD
27+
* threshold (~0.57 at DPR 1): below it nodes render as canvas boxes with no
28+
* Vue components mounted, and this test's subject is DOM reflow.
29+
*/
30+
const MEASUREMENT_ZOOM = 0.8
31+
32+
/** Centers the viewport on a node at a fixed, LOD-safe zoom. */
33+
async function centerOnNode(comfyPage: ComfyPage, nodeId: string) {
34+
await comfyPage.page.evaluate(
35+
([id, zoom]) => {
36+
const canvas = window.app!.canvas
37+
const graph = window.graph as unknown as TestGraphAccess
38+
const node = graph._nodes_by_id[id]
39+
if (!node) return
40+
41+
const element = canvas.canvas
42+
canvas.ds.scale = Number(zoom)
43+
canvas.ds.offset[0] =
44+
-(node.pos[0] + node.size[0] / 2) +
45+
element.clientWidth / 2 / Number(zoom)
46+
canvas.ds.offset[1] =
47+
-(node.pos[1] + node.size[1] / 2) +
48+
element.clientHeight / 2 / Number(zoom)
49+
canvas.setDirty(true, true)
50+
},
51+
[nodeId, MEASUREMENT_ZOOM] as const
52+
)
53+
await comfyPage.nextFrame()
54+
}
55+
56+
/**
57+
* Adds a reflow node, centers it at a deterministic zoom, and captures its
58+
* starting height so a test can assert on the height delta after triggering
59+
* runtime growth.
60+
*
61+
* Fit-to-view alone can land below the LOD threshold on this workflow, where
62+
* no Vue node elements exist at all, so the node is centered at a fixed zoom
63+
* instead of measured wherever fit happens to leave it.
2864
*/
2965
export async function addReflowNodeAndMeasure(
3066
comfyPage: ComfyPage
3167
): Promise<ReflowNodeUnderTest> {
3268
const nodeId = await addRuntimeReflowNode(comfyPage)
3369
await fitToViewInstant(comfyPage)
70+
await centerOnNode(comfyPage, nodeId)
3471

3572
const node = comfyPage.vueNodes.getNodeLocator(nodeId)
3673
await expect(node).toBeVisible()

0 commit comments

Comments
 (0)