Skip to content

Commit bf99d70

Browse files
DrJKLampagent
andcommitted
test: extract node title viewport wait
Amp-Thread-ID: https://ampcode.com/threads/T-01a0165c-6e78-7117-9a54-4514124737d7 Co-authored-by: Amp <amp@ampcode.com>
1 parent 625912a commit bf99d70

2 files changed

Lines changed: 31 additions & 26 deletions

File tree

browser_tests/fixtures/utils/litegraphUtils.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,20 @@ export class NodeReference {
356356
const nodeSize = await this.getSize()
357357
return { x: nodePos.x + nodeSize.width / 2, y: nodePos.y - 15 }
358358
}
359+
async waitForTitleInView(): Promise<void> {
360+
const canvas = await this.comfyPage.canvas.boundingBox()
361+
if (!canvas) throw new Error('Canvas bounding box not available')
362+
363+
let previousX = Number.NaN
364+
await expect
365+
.poll(async () => {
366+
const { x } = await this.getTitlePosition()
367+
const settledInView = x === previousX && x < canvas.width
368+
previousX = x
369+
return settledInView
370+
})
371+
.toBe(true)
372+
}
359373
async dragBy(
360374
delta: Position,
361375
options?: {

browser_tests/tests/subgraph/subgraphCreationBoundaryLinks.spec.ts

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@ import { expect } from '@playwright/test'
22

33
import { comfyPageFixture as test } from '@e2e/fixtures/ComfyPage'
44

5+
const SUBGRAPH_LINKS_EXPECTED = {
6+
rootLinks: [
7+
'4:0->HOST:0',
8+
'4:1->6:0',
9+
'4:1->7:0',
10+
'4:2->HOST:4',
11+
'5:0->HOST:3',
12+
'6:0->HOST:1',
13+
'7:0->HOST:2',
14+
'HOST:0->9:0'
15+
],
16+
incompatibleHostInputLinks: []
17+
} as const
18+
519
test(
620
'Subgraph creation rewires boundary links to compatible slots across reload',
721
{ tag: ['@slow', '@subgraph', '@vue-nodes'] },
822
async ({ comfyPage }) => {
9-
const expectedSnapshot = {
10-
rootLinks: [
11-
'4:0->HOST:0',
12-
'4:1->6:0',
13-
'4:1->7:0',
14-
'4:2->HOST:4',
15-
'5:0->HOST:3',
16-
'6:0->HOST:1',
17-
'7:0->HOST:2',
18-
'HOST:0->9:0'
19-
],
20-
incompatibleHostInputLinks: []
21-
}
22-
2323
await test.step('Select both nodes in the default workflow', async () => {
2424
await comfyPage.settings.setSetting('Comfy.UseNewMenu', 'Disabled')
2525
await comfyPage.workflow.loadWorkflow('default')
@@ -29,16 +29,7 @@ test(
2929
// holding KSampler alone.
3030
await comfyPage.command.executeCommand('Comfy.Canvas.FitView')
3131
const vaeDecode = await comfyPage.nodeOps.getNodeRefById('8')
32-
const canvasWidth = (await comfyPage.canvas.boundingBox())!.width
33-
let previousX = Number.NaN
34-
await expect
35-
.poll(async () => {
36-
const { x } = await vaeDecode.getTitlePosition()
37-
const settledInView = x === previousX && x < canvasWidth
38-
previousX = x
39-
return settledInView
40-
})
41-
.toBe(true)
32+
await vaeDecode.waitForTitleInView()
4233

4334
await comfyPage.nodeOps.selectNodes(['KSampler', 'VAE Decode'])
4435
expect(
@@ -53,15 +44,15 @@ test(
5344

5445
await expect
5546
.poll(() => comfyPage.subgraph.getBoundaryLinkSnapshot())
56-
.toEqual(expectedSnapshot)
47+
.toEqual(SUBGRAPH_LINKS_EXPECTED)
5748
})
5849

5950
await test.step('Reload and verify the boundary links', async () => {
6051
await comfyPage.subgraph.serializeAndReload()
6152

6253
await expect
6354
.poll(() => comfyPage.subgraph.getBoundaryLinkSnapshot())
64-
.toEqual(expectedSnapshot)
55+
.toEqual(SUBGRAPH_LINKS_EXPECTED)
6556
})
6657
}
6758
)

0 commit comments

Comments
 (0)