-
Notifications
You must be signed in to change notification settings - Fork 672
test: cover boundary link preservation on subgraph creation #15064
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+102
−0
Merged
Changes from 2 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
eb59077
test: cover boundary link preservation on subgraph creation
4e821e2
test: dump graph state in the boundary link assertion diff
1d37541
Revert "test: dump graph state in the boundary link assertion diff"
0566c82
test: assert the exact post-conversion link topology
269a12a
test: select both nodes before converting to a subgraph
18aae29
test: read the declared id off the selected item
85f173e
Merge branch 'main' into cb/track-a-subgraph-creation-repro
christian-byrne acfdb9e
Merge branch 'main' into cb/track-a-subgraph-creation-repro
DrJKL 625912a
test: simplify subgraph boundary link coverage
DrJKL bf99d70
test: extract node title viewport wait
DrJKL 74a1030
test: validate subgraph output link types
DrJKL 5a2d47d
Merge branch 'main' into cb/track-a-subgraph-creation-repro
DrJKL 7a03b0c
test: use rendered node viewport assertion
ampagent File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
126 changes: 126 additions & 0 deletions
126
browser_tests/tests/subgraph/subgraphCreationBoundaryLinks.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| import { expect } from '@playwright/test' | ||
|
|
||
| import { comfyPageFixture as test } from '@e2e/fixtures/ComfyPage' | ||
|
|
||
| test.describe( | ||
| 'Subgraph creation boundary links', | ||
| { tag: ['@slow', '@subgraph'] }, | ||
| () => { | ||
| test.beforeEach(async ({ comfyPage }) => { | ||
| await comfyPage.settings.setSetting('Comfy.UseNewMenu', 'Disabled') | ||
| await comfyPage.workflow.loadWorkflow('default') | ||
| await comfyPage.nodeOps.selectNodes(['KSampler', 'VAE Decode']) | ||
| const ksampler = await comfyPage.nodeOps.getNodeRefById('3') | ||
| await ksampler.convertToSubgraph() | ||
| }) | ||
|
|
||
| test('rewires every boundary link onto the new subgraph node', async ({ | ||
| comfyPage | ||
| }) => { | ||
| await expect | ||
| .poll(() => | ||
| comfyPage.page.evaluate(() => { | ||
| const graph = window.app!.graph! | ||
| const host = graph.nodes.find((node) => node.isSubgraphNode()) | ||
| if (!host) return { error: 'no subgraph node' } | ||
|
|
||
| const links = [...graph.links.values()] | ||
| return { | ||
| rootLinkCount: links.length, | ||
| inputCount: host.inputs.length, | ||
| outputCount: host.outputs.length, | ||
| unconnectedInputs: host.inputs.filter( | ||
| (input) => input.link == null | ||
| ).length, | ||
| sources: links | ||
| .filter((link) => link.target_id === host.id) | ||
| .map((link) => `${link.origin_id}:${link.origin_slot}`) | ||
| .sort(), | ||
| saveImageFedByHost: | ||
| links.find((link) => String(link.target_id) === '9') | ||
| ?.origin_id === host.id, | ||
| // Diagnostics: printed as context in the assertion diff. | ||
| diagnosticHostId: String(host.id), | ||
| diagnosticNodes: graph.nodes | ||
| .map((node) => `${node.id}:${node.type}`) | ||
| .sort(), | ||
| diagnosticLinks: links | ||
| .map( | ||
| (link) => | ||
| `${link.origin_id}:${link.origin_slot}->${link.target_id}:${link.target_slot}(${link.type})` | ||
| ) | ||
| .sort(), | ||
| diagnosticHostSlots: host.inputs | ||
| .map( | ||
| (input, index) => | ||
| `${index} ${input.name}:${input.type}=${input.link ?? 'NULL'}` | ||
| ) | ||
| .concat( | ||
| host.outputs.map( | ||
| (output, index) => | ||
| `out${index} ${output.name}:${output.type}=[${(output.links ?? []).join('|')}]` | ||
| ) | ||
| ) | ||
| } | ||
| }) | ||
| ) | ||
| .toEqual({ | ||
| rootLinkCount: 6, | ||
| inputCount: 5, | ||
| outputCount: 1, | ||
| unconnectedInputs: 0, | ||
| sources: ['4:0', '4:2', '5:0', '6:0', '7:0'], | ||
| saveImageFedByHost: true, | ||
| diagnosticHostId: expect.anything(), | ||
| diagnosticNodes: expect.anything(), | ||
| diagnosticLinks: expect.anything(), | ||
| diagnosticHostSlots: expect.anything() | ||
| }) | ||
| }) | ||
|
|
||
| test('lands each boundary link on a type-compatible slot', async ({ | ||
| comfyPage | ||
| }) => { | ||
| await expect | ||
| .poll(() => | ||
| comfyPage.page.evaluate(() => { | ||
| const graph = window.app!.graph! | ||
| const host = graph.nodes.find((node) => node.isSubgraphNode()) | ||
| if (!host) return ['no subgraph node'] | ||
|
|
||
| return [...graph.links.values()] | ||
| .filter((link) => link.target_id === host.id) | ||
| .filter( | ||
| (link) => host.inputs[link.target_slot]?.type !== link.type | ||
| ) | ||
| .map( | ||
| (link) => | ||
| `${link.type} link landed on slot ${link.target_slot} typed ${host.inputs[link.target_slot]?.type}` | ||
| ) | ||
| }) | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
| ) | ||
| .toEqual([]) | ||
| }) | ||
|
|
||
| test('preserves the rewiring across a save and reload', async ({ | ||
| comfyPage | ||
| }) => { | ||
| const serialisedLinks = () => | ||
| comfyPage.page.evaluate(() => | ||
| [...window.app!.graph!.links.values()] | ||
| .map( | ||
| (link) => | ||
| `${link.origin_id}:${link.origin_slot}->${link.target_id}:${link.target_slot}` | ||
| ) | ||
| .sort() | ||
| ) | ||
|
|
||
| const beforeReload = await serialisedLinks() | ||
| await comfyPage.nodeOps.loadGraph( | ||
| await comfyPage.nodeOps.getSerializedGraph() | ||
| ) | ||
|
|
||
| await expect.poll(serialisedLinks).toEqual(beforeReload) | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
| }) | ||
| } | ||
| ) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.