Repository navigation
test: extract shared subgraph E2E test utilities - #10629
Conversation
📝 WalkthroughWalkthroughAdds comprehensive Subgraph testing helpers and a node deletion utility, removes a legacy test helper file, and updates many browser tests to use the new helper APIs instead of inline page.evaluate, DOM inspections, context-menu flows, and manual console listeners. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (3)
browser_tests/tests/appModeWidgetRename.spec.ts (1)
17-67: Consider extracting the remaining builder-setup flow into the shared utils.
setupSubgraphBuilderstill contains a sizable inline sequence (seed selection + output node selection). Moving that block intosubgraphTestUtilswould keep this spec focused on rename behavior and improve reuse across subgraph specs.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@browser_tests/tests/appModeWidgetRename.spec.ts` around lines 17 - 67, setupSubgraphBuilder contains a long inline sequence (seed selection + output node selection) that should be moved to shared utilities; extract the flow starting from the seed widget selection (the block using subgraphNode.getWidget, getPosition, page.evaluate to read NODE_TITLE_HEIGHT, and page.mouse.click) through the output node selection (the appMode.goToOutputs call, page.evaluate that finds SaveImage/PreviewImage, comfyPage.nodeOps.getNodeRefById and saveImageRef.centerOnNode plus the canvas click) into a new helper in subgraphTestUtils (e.g., selectPromotedSeedAndCenterOutput), then replace that inline block in setupSubgraphBuilder with a call to the new helper and keep existing calls to fitToViewInstant, appMode.enterBuilder, appMode.goToInputs, comfyPage.canvasOps.setScale and subgraphNode.centerOnNode intact so behavior is unchanged.browser_tests/helpers/subgraphTestUtils.ts (1)
107-123:collectConsoleWarningsshould expose a detach path for the console listener.Right now every call adds a permanent
page.on('console')handler for that page, which can duplicate captures in longer tests.♻️ Suggested update with disposer
-export function collectConsoleWarnings( +export function collectConsoleWarnings( page: Page, patterns: string[] = [ 'No link found', 'Failed to resolve legacy -1', 'No inner link found' ] -): string[] { +): { warnings: string[]; dispose: () => void } { const warnings: string[] = [] - page.on('console', (msg) => { + const handler = (msg: { text: () => string }) => { const text = msg.text() if (patterns.some((p) => text.includes(p))) { warnings.push(text) } - }) - return warnings + } + page.on('console', handler) + return { + warnings, + dispose: () => page.off('console', handler) + } }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@browser_tests/helpers/subgraphTestUtils.ts` around lines 107 - 123, collectConsoleWarnings currently attaches a permanent page.on('console') handler (in function collectConsoleWarnings) which can accumulate duplicates; change it to register the listener as a named callback, push matched messages into the warnings array, and return a disposer (e.g., return { warnings, stop } or [warnings, stop]) that calls page.off('console', listener) (or page.removeListener) to detach the handler when the test is done; keep the patterns parameter and behavior but ensure you reference the same listener instance when removing it.browser_tests/tests/subgraph.spec.ts (1)
112-113: Prefer explicit null guards for slot labels before rename actions.At Line 112 (and the other listed reads),
getSlotLabel()can returnnull, but downstream usage relies on non-null assertions. An explicit guard gives deterministic failure messages when fixtures evolve.♻️ Suggested pattern
const initialInputLabel = await comfyPage.subgraph.getSlotLabel('inputs') +if (initialInputLabel === null) { + throw new Error('Expected subgraph to have at least one input slot label') +} -await comfyPage.subgraph.rightClickInputSlot(initialInputLabel!) +await comfyPage.subgraph.rightClickInputSlot(initialInputLabel)Also applies to: 140-141, 166-167, 196-197, 228-229
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@browser_tests/tests/subgraph.spec.ts` around lines 112 - 113, The tests call comfyPage.subgraph.getSlotLabel(...) which can return null but the code proceeds assuming non-null; add explicit null guards where getSlotLabel('inputs') (and the other calls at the listed locations) are used before any rename action: check the returned value and throw or assert with a clear message like "expected slot label for 'inputs' to be present" (or use expect(...).not.toBeNull()) so the subsequent rename/usage (the code referencing the label) only runs when the label is non-null; update each occurrence that reads getSlotLabel to perform this explicit check (reference comfyPage.subgraph.getSlotLabel) before proceeding.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@browser_tests/helpers/subgraphTestUtils.ts`:
- Around line 107-123: collectConsoleWarnings currently attaches a permanent
page.on('console') handler (in function collectConsoleWarnings) which can
accumulate duplicates; change it to register the listener as a named callback,
push matched messages into the warnings array, and return a disposer (e.g.,
return { warnings, stop } or [warnings, stop]) that calls page.off('console',
listener) (or page.removeListener) to detach the handler when the test is done;
keep the patterns parameter and behavior but ensure you reference the same
listener instance when removing it.
In `@browser_tests/tests/appModeWidgetRename.spec.ts`:
- Around line 17-67: setupSubgraphBuilder contains a long inline sequence (seed
selection + output node selection) that should be moved to shared utilities;
extract the flow starting from the seed widget selection (the block using
subgraphNode.getWidget, getPosition, page.evaluate to read NODE_TITLE_HEIGHT,
and page.mouse.click) through the output node selection (the appMode.goToOutputs
call, page.evaluate that finds SaveImage/PreviewImage,
comfyPage.nodeOps.getNodeRefById and saveImageRef.centerOnNode plus the canvas
click) into a new helper in subgraphTestUtils (e.g.,
selectPromotedSeedAndCenterOutput), then replace that inline block in
setupSubgraphBuilder with a call to the new helper and keep existing calls to
fitToViewInstant, appMode.enterBuilder, appMode.goToInputs,
comfyPage.canvasOps.setScale and subgraphNode.centerOnNode intact so behavior is
unchanged.
In `@browser_tests/tests/subgraph.spec.ts`:
- Around line 112-113: The tests call comfyPage.subgraph.getSlotLabel(...) which
can return null but the code proceeds assuming non-null; add explicit null
guards where getSlotLabel('inputs') (and the other calls at the listed
locations) are used before any rename action: check the returned value and throw
or assert with a clear message like "expected slot label for 'inputs' to be
present" (or use expect(...).not.toBeNull()) so the subsequent rename/usage (the
code referencing the label) only runs when the label is non-null; update each
occurrence that reads getSlotLabel to perform this explicit check (reference
comfyPage.subgraph.getSlotLabel) before proceeding.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 8d29cd1c-ac38-4d80-a022-b5645f1c3043
📒 Files selected for processing (15)
browser_tests/fixtures/helpers/SubgraphHelper.tsbrowser_tests/fixtures/utils/litegraphUtils.tsbrowser_tests/helpers/subgraphTestUtils.tsbrowser_tests/tests/appModeWidgetRename.spec.tsbrowser_tests/tests/subgraph-promoted-widget-dom.spec.tsbrowser_tests/tests/subgraph-rename-dialog.spec.tsbrowser_tests/tests/subgraph.spec.tsbrowser_tests/tests/subgraphInputSlotRename.spec.tsbrowser_tests/tests/subgraphLegacyPrefixedProxyWidgets.spec.tsbrowser_tests/tests/subgraphLifecycle.spec.tsbrowser_tests/tests/subgraphNestedConfigureOrder.spec.tsbrowser_tests/tests/subgraphNestedPackValues.spec.tsbrowser_tests/tests/subgraphProgressClear.spec.tsbrowser_tests/tests/subgraphPromotion.spec.tsbrowser_tests/tests/subgraphSearchAliases.spec.ts
There was a problem hiding this comment.
🧹 Nitpick comments (1)
browser_tests/tests/subgraphLegacyPrefixedProxyWidgets.spec.ts (1)
34-34: Consider callingdispose()for consistency with the helper's design.The
collectConsoleWarningshelper returns adisposefunction to remove the listener. While Playwright's fresh page contexts make this unlikely to cause issues, callingdispose()after the assertion maintains consistency with the helper's design and documents the intended cleanup pattern.♻️ Optional: Call dispose after assertion
- const { warnings } = collectConsoleWarnings(comfyPage.page) + const { warnings, dispose } = collectConsoleWarnings(comfyPage.page) await comfyPage.workflow.loadWorkflow(WORKFLOW) expect(warnings).toEqual([]) + dispose()🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@browser_tests/tests/subgraphLegacyPrefixedProxyWidgets.spec.ts` at line 34, The test uses collectConsoleWarnings(comfyPage.page) which returns a dispose function that removes the console listener; call that dispose() after you finish asserting on warnings to consistently clean up the listener — locate the collectConsoleWarnings call in subgraphLegacyPrefixedProxyWidgets.spec.ts and invoke the returned dispose() (e.g., const { warnings, dispose } = collectConsoleWarnings(...); ... expect(...); dispose();) immediately after the assertion to follow the helper's intended cleanup pattern.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@browser_tests/tests/subgraphLegacyPrefixedProxyWidgets.spec.ts`:
- Line 34: The test uses collectConsoleWarnings(comfyPage.page) which returns a
dispose function that removes the console listener; call that dispose() after
you finish asserting on warnings to consistently clean up the listener — locate
the collectConsoleWarnings call in subgraphLegacyPrefixedProxyWidgets.spec.ts
and invoke the returned dispose() (e.g., const { warnings, dispose } =
collectConsoleWarnings(...); ... expect(...); dispose();) immediately after the
assertion to follow the helper's intended cleanup pattern.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: f98b80de-80eb-42b6-9337-7d257e2b84ff
📒 Files selected for processing (7)
browser_tests/fixtures/helpers/SubgraphHelper.tsbrowser_tests/helpers/subgraphTestUtils.tsbrowser_tests/tests/subgraph-duplicate-ids.spec.tsbrowser_tests/tests/subgraph-rename-dialog.spec.tsbrowser_tests/tests/subgraph.spec.tsbrowser_tests/tests/subgraphLegacyPrefixedProxyWidgets.spec.tsbrowser_tests/tests/subgraphNestedConfigureOrder.spec.ts
✅ Files skipped from review due to trivial changes (1)
- browser_tests/tests/subgraph.spec.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- browser_tests/fixtures/helpers/SubgraphHelper.ts
Extract repeated patterns from 12 subgraph Playwright spec files into shared utilities, reducing duplication by ~142 lines. New SubgraphHelper methods: - getSlotCount(type) — subgraph I/O slot count - getSlotLabel(type, index?) — slot label/name - removeSlot(type, slotName?) — right-click + Remove Slot - findSubgraphNodeId() — find first subgraph node in graph New NodeReference method: - delete() — click title + Delete key + nextFrame New subgraphTestUtils helpers: - serializeAndReload() — graph serialize/loadGraphData round-trip - convertDefaultKSamplerToSubgraph() — common test setup - expectWidgetBelowHeader() — DOM position assertion - collectConsoleWarnings() — console warning interception - packAllInteriorNodes() — enter subgraph + select all + convert Amp-Thread-ID: https://ampcode.com/threads/T-019d30ce-1665-76d1-9164-a95b1d92ba34 Co-authored-by: Amp <amp@ampcode.com>
- Return disposer from collectConsoleWarnings to prevent listener leaks - Unify slot type params to singular 'input'|'output' across SubgraphHelper - Replace || with ?? in getSlotCount and getSlotLabel for correctness - Remove dead assertSubgraph export and unused imports - Migrate subgraph-duplicate-ids.spec.ts to shared isInSubgraph helper - Add trust-boundary comment on serializeAndReload cast - Use early-throw narrowing in expectWidgetBelowHeader Amp-Thread-ID: https://ampcode.com/threads/T-019d311b-133d-71a8-87bb-e628ea82f90c Co-authored-by: Amp <amp@ampcode.com>
e558868 to
a4ce1a8
Compare
🎨 Storybook: ✅ Built — View Storybook |
🎭 Playwright: ✅ 749 passed, 0 failed · 6 flaky📊 Browser Reports
|
📦 Bundle: 5.09 MB gzip 🔴 +303 BDetailsSummary
Category Glance App Entry Points — 22.3 kB (baseline 22.3 kB) • ⚪ 0 BMain entry bundles and manifests
Status: 1 added / 1 removed Graph Workspace — 1.14 MB (baseline 1.14 MB) • ⚪ 0 BGraph editor runtime, canvas, workflow orchestration
Status: 1 added / 1 removed Views & Navigation — 76.6 kB (baseline 76.6 kB) • ⚪ 0 BTop-level views, pages, and routed surfaces
Status: 9 added / 9 removed / 2 unchanged Panels & Settings — 484 kB (baseline 484 kB) • ⚪ 0 BConfiguration panels, inspectors, and settings screens
Status: 10 added / 10 removed / 12 unchanged User & Accounts — 17.1 kB (baseline 17.1 kB) • ⚪ 0 BAuthentication, profile, and account management bundles
Status: 5 added / 5 removed / 2 unchanged Editors & Dialogs — 109 kB (baseline 109 kB) • ⚪ 0 BModals, dialogs, drawers, and in-app editors
Status: 2 added / 2 removed UI Components — 60.3 kB (baseline 60.3 kB) • ⚪ 0 BReusable component library chunks
Status: 5 added / 5 removed / 8 unchanged Data & Services — 2.96 MB (baseline 2.96 MB) • ⚪ 0 BStores, services, APIs, and repositories
Status: 13 added / 13 removed / 4 unchanged Utilities & Hooks — 334 kB (baseline 334 kB) • ⚪ 0 BHelpers, composables, and utility bundles
Status: 13 added / 13 removed / 12 unchanged Vendor & Third-Party — 9.8 MB (baseline 9.8 MB) • ⚪ 0 BExternal libraries and shared vendor chunks Status: 16 unchanged Other — 8.43 MB (baseline 8.43 MB) • ⚪ 0 BBundles that do not match a named category
Status: 55 added / 55 removed / 79 unchanged ⚡ Performance
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
browser_tests/helpers/subgraphTestUtils.ts (1)
92-109: Make console warning collection self-disposing to prevent accidental listener retention.
collectConsoleWarningsis correct, but the current API is easy to misuse because callers can forgetdispose(). A scoped wrapper would make cleanup automatic and avoid lingering listeners.♻️ Suggested scoped wrapper
export function collectConsoleWarnings( page: Page, patterns: string[] = [ 'No link found', 'Failed to resolve legacy -1', 'No inner link found' ] ): { warnings: string[]; dispose: () => void } { const warnings: string[] = [] const handler = (msg: ConsoleMessage) => { const text = msg.text() if (patterns.some((p) => text.includes(p))) { warnings.push(text) } } page.on('console', handler) return { warnings, dispose: () => page.off('console', handler) } } + +export async function withConsoleWarnings<T>( + page: Page, + run: () => Promise<T>, + patterns?: string[] +): Promise<{ result: T; warnings: string[] }> { + const { warnings, dispose } = collectConsoleWarnings(page, patterns) + try { + const result = await run() + return { result, warnings } + } finally { + dispose() + } +}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@browser_tests/helpers/subgraphTestUtils.ts` around lines 92 - 109, The current collectConsoleWarnings attaches a listener and returns a dispose() that callers may forget to call; add a scoped wrapper (e.g., withConsoleWarnings) that takes the same parameters plus an async callback (fn: () => Promise<T>) and internally installs the same handler (use the existing handler logic from collectConsoleWarnings), runs await fn() inside a try/finally, and always calls page.off('console', handler) in the finally before returning { result: await fnReturn, warnings }. Alternatively overload collectConsoleWarnings to accept a callback and ensure removal in finally; reference the existing symbols collectConsoleWarnings, handler and dispose when making the change so the listener registration and cleanup logic is identical.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@browser_tests/helpers/subgraphTestUtils.ts`:
- Around line 92-109: The current collectConsoleWarnings attaches a listener and
returns a dispose() that callers may forget to call; add a scoped wrapper (e.g.,
withConsoleWarnings) that takes the same parameters plus an async callback (fn:
() => Promise<T>) and internally installs the same handler (use the existing
handler logic from collectConsoleWarnings), runs await fn() inside a
try/finally, and always calls page.off('console', handler) in the finally before
returning { result: await fnReturn, warnings }. Alternatively overload
collectConsoleWarnings to accept a callback and ensure removal in finally;
reference the existing symbols collectConsoleWarnings, handler and dispose when
making the change so the listener registration and cleanup logic is identical.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: c7c8be37-5944-483c-9c7e-2c141225744a
📒 Files selected for processing (15)
browser_tests/fixtures/helpers/SubgraphHelper.tsbrowser_tests/fixtures/utils/litegraphUtils.tsbrowser_tests/helpers/subgraphTestUtils.tsbrowser_tests/tests/subgraph-duplicate-ids.spec.tsbrowser_tests/tests/subgraph-promoted-widget-dom.spec.tsbrowser_tests/tests/subgraph-rename-dialog.spec.tsbrowser_tests/tests/subgraph.spec.tsbrowser_tests/tests/subgraphInputSlotRename.spec.tsbrowser_tests/tests/subgraphLegacyPrefixedProxyWidgets.spec.tsbrowser_tests/tests/subgraphLifecycle.spec.tsbrowser_tests/tests/subgraphNestedConfigureOrder.spec.tsbrowser_tests/tests/subgraphNestedPackValues.spec.tsbrowser_tests/tests/subgraphProgressClear.spec.tsbrowser_tests/tests/subgraphPromotion.spec.tsbrowser_tests/tests/subgraphSearchAliases.spec.ts
✅ Files skipped from review due to trivial changes (1)
- browser_tests/tests/subgraphProgressClear.spec.ts
🚧 Files skipped from review as they are similar to previous changes (3)
- browser_tests/fixtures/utils/litegraphUtils.ts
- browser_tests/fixtures/helpers/SubgraphHelper.ts
- browser_tests/tests/subgraph-duplicate-ids.spec.ts
Move all standalone functions from helpers/subgraphTestUtils.ts into SubgraphHelper as instance methods (serializeAndReload, convertDefaultKSamplerToSubgraph, packAllInteriorNodes) and static methods (getTextSlotPosition, expectWidgetBelowHeader, collectConsoleWarnings). Update 9 spec files and delete the old module. Amp-Thread-ID: https://ampcode.com/threads/T-019d3158-4e9c-76c8-84ae-dffccccbd0ca Co-authored-by: Amp <amp@ampcode.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
browser_tests/fixtures/helpers/SubgraphHelper.ts (2)
483-498: Don't letpackAllInteriorNodes()silently change Vue mode on return.This helper enters through
vueNodes.enterSubgraph()but returns withComfy.VueNodes.Enabledforced tofalse. That hidden state mutation makes the API easy to misuse from future specs. Restoring the original setting in afinallywould make the helper much safer to compose.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@browser_tests/fixtures/helpers/SubgraphHelper.ts` around lines 483 - 498, packAllInteriorNodes currently disables the Comfy.VueNodes.Enabled setting before performing actions and never restores it; update packAllInteriorNodes so it reads and stores the current value of the 'Comfy.VueNodes.Enabled' setting before changing it, perform the work (enterSubgraph, convertToSubgraph, exitViaBreadcrumb) and then restore the original setting in a finally block to guarantee the setting is returned to its prior state even on errors; reference the methods comfyPage.vueNodes.enterSubgraph, comfyPage.settings.setSetting and the setting key 'Comfy.VueNodes.Enabled' when making this change.
474-480: Avoid hardcoding the default workflow's node ID in this shared helper.Baking
'default'and node id'3'into a fixture API makes every caller depend on one exact workflow snapshot. If that workflow changes, all dependent specs break together. Prefer a generic helper that takes the workflow and node id as parameters, or resolves the KSampler by a stable characteristic inside the helper.♻️ Possible shape
- async convertDefaultKSamplerToSubgraph(): Promise<NodeReference> { - await this.comfyPage.workflow.loadWorkflow('default') - const ksampler = await this.comfyPage.nodeOps.getNodeRefById('3') - await ksampler.click('title') - const subgraphNode = await ksampler.convertToSubgraph() + async convertNodeToSubgraph( + workflow: string, + nodeId: string + ): Promise<NodeReference> { + await this.comfyPage.workflow.loadWorkflow(workflow) + const node = await this.comfyPage.nodeOps.getNodeRefById(nodeId) + await node.click('title') + const subgraphNode = await node.convertToSubgraph() await this.comfyPage.nextFrame() return subgraphNode }Based on learnings, the default workflow composition can change, making fixed assumptions brittle.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@browser_tests/fixtures/helpers/SubgraphHelper.ts` around lines 474 - 480, The helper convertDefaultKSamplerToSubgraph hardcodes the workflow name 'default' and node id '3', which is brittle; modify convertDefaultKSamplerToSubgraph to accept parameters (e.g., workflowName: string, nodeId?: string) or to resolve the target node by a stable characteristic (e.g., node type/name/title) using comfyPage.nodeOps APIs instead of getNodeRefById('3'), then call this.comfyPage.workflow.loadWorkflow(workflowName) and locate the KSampler node (by id if provided or by stable selector) before clicking title and calling convertToSubgraph to return subgraphNode.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@browser_tests/tests/subgraphNestedConfigureOrder.spec.ts`:
- Line 12: The call to SubgraphHelper.collectConsoleWarnings(comfyPage.page)
relies on a helper default that also matches "No inner link found", causing
extra warnings to be captured; update the call to pass the two specific expected
warning strings explicitly (e.g.
SubgraphHelper.collectConsoleWarnings(comfyPage.page, ["<expected warning A>",
"<expected warning B>")) so only the two intended patterns are extracted and the
test remains equivalent — make this change where the call occurs in
subgraphNestedConfigureOrder.spec.ts and ensure the strings match the original
assertion/test name.
---
Nitpick comments:
In `@browser_tests/fixtures/helpers/SubgraphHelper.ts`:
- Around line 483-498: packAllInteriorNodes currently disables the
Comfy.VueNodes.Enabled setting before performing actions and never restores it;
update packAllInteriorNodes so it reads and stores the current value of the
'Comfy.VueNodes.Enabled' setting before changing it, perform the work
(enterSubgraph, convertToSubgraph, exitViaBreadcrumb) and then restore the
original setting in a finally block to guarantee the setting is returned to its
prior state even on errors; reference the methods
comfyPage.vueNodes.enterSubgraph, comfyPage.settings.setSetting and the setting
key 'Comfy.VueNodes.Enabled' when making this change.
- Around line 474-480: The helper convertDefaultKSamplerToSubgraph hardcodes the
workflow name 'default' and node id '3', which is brittle; modify
convertDefaultKSamplerToSubgraph to accept parameters (e.g., workflowName:
string, nodeId?: string) or to resolve the target node by a stable
characteristic (e.g., node type/name/title) using comfyPage.nodeOps APIs instead
of getNodeRefById('3'), then call
this.comfyPage.workflow.loadWorkflow(workflowName) and locate the KSampler node
(by id if provided or by stable selector) before clicking title and calling
convertToSubgraph to return subgraphNode.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 193341f4-1af2-40d0-99eb-558bdbeabed9
📒 Files selected for processing (11)
browser_tests/fixtures/helpers/SubgraphHelper.tsbrowser_tests/helpers/subgraphTestUtils.tsbrowser_tests/tests/subgraph-promoted-slot-position.spec.tsbrowser_tests/tests/subgraph-promoted-widget-dom.spec.tsbrowser_tests/tests/subgraphInputSlotRename.spec.tsbrowser_tests/tests/subgraphLegacyPrefixedProxyWidgets.spec.tsbrowser_tests/tests/subgraphLifecycle.spec.tsbrowser_tests/tests/subgraphNestedConfigureOrder.spec.tsbrowser_tests/tests/subgraphNestedPackValues.spec.tsbrowser_tests/tests/subgraphPromotion.spec.tsbrowser_tests/tests/subgraphSearchAliases.spec.ts
💤 Files with no reviewable changes (1)
- browser_tests/helpers/subgraphTestUtils.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- browser_tests/tests/subgraphSearchAliases.spec.ts
- browser_tests/tests/subgraphLifecycle.spec.ts
Amp-Thread-ID: https://ampcode.com/threads/T-019d31ce-8eef-70ae-beae-b94970f4d959 Co-authored-by: Amp <amp@ampcode.com>
christian-byrne
left a comment
There was a problem hiding this comment.
A lot of nits. Obviously these comments are moreso about the existing functionality since this is just a refactoring, so they are not blocking.
Overall +244/-414 is nice to see and the PR LGTM!
| async getSlotCount(type: 'input' | 'output'): Promise<number> { | ||
| return this.page.evaluate((slotType: 'input' | 'output') => { | ||
| const graph = window.app!.canvas.graph | ||
| if (!graph || !('inputNode' in graph)) return 0 | ||
| return graph[`${slotType}s`]?.length ?? 0 | ||
| }, type) | ||
| } | ||
|
|
||
| async getSlotLabel( | ||
| type: 'input' | 'output', | ||
| index = 0 | ||
| ): Promise<string | null> { | ||
| return this.page.evaluate( | ||
| ([slotType, idx]) => { | ||
| const graph = window.app!.canvas.graph | ||
| if (!graph || !('inputNode' in graph)) return null | ||
| const slot = graph[`${slotType}s`]?.[idx] | ||
| return slot?.label ?? slot?.name ?? null | ||
| }, | ||
| [type, index] as const | ||
| ) | ||
| } |
There was a problem hiding this comment.
So the need for litegraph-based helpers like this is just unavoidable here I am assuming?
| await this.comfyPage.nextFrame() | ||
| } | ||
|
|
||
| async findSubgraphNodeId(): Promise<string> { |
There was a problem hiding this comment.
nit: it's more like findFirstNodeInCurrentGraphThatIsASubgraphNode (and throw error if none found unlike standard find functions) (and it won't be deterministic).
| async serializeAndReload(): Promise<void> { | ||
| const serialized = await this.page.evaluate(() => | ||
| window.app!.graph!.serialize() | ||
| ) | ||
| await this.page.evaluate( | ||
| (workflow: ComfyWorkflowJSON) => window.app!.loadGraphData(workflow), | ||
| serialized as ComfyWorkflowJSON | ||
| ) | ||
| await this.comfyPage.nextFrame() | ||
| } |
There was a problem hiding this comment.
nit: this fucntion seems like it wants to be somewhere higher up
| async convertDefaultKSamplerToSubgraph(): Promise<NodeReference> { | ||
| await this.comfyPage.workflow.loadWorkflow('default') |
There was a problem hiding this comment.
nit: I wouldn't expect that this function loads a workflow based on the name
|
|
||
| async convertDefaultKSamplerToSubgraph(): Promise<NodeReference> { | ||
| await this.comfyPage.workflow.loadWorkflow('default') | ||
| const ksampler = await this.comfyPage.nodeOps.getNodeRefById('3') |
There was a problem hiding this comment.
WDYT about maintaining some mapping in code between ids->nodename for the common workflows? Although that's basically what the jsons already are... just thinking that as this pattern becomes more common we lose a bit of expressiveness that might be aided by a constant object / enum (but not actually a ts enum but you get what I mean).
There was a problem hiding this comment.
I think that adding structure to the fixtures is going to be great for readability, especially if we can also get intellisense and type checking for names/ids.
| const subgraphNode = await ksampler.convertToSubgraph() | ||
| await this.comfyPage.nextFrame() |
There was a problem hiding this comment.
Is the ksampler.convertToSubgraph not calling nextFrame itself?
| await this.comfyPage.settings.setSetting('Comfy.VueNodes.Enabled', false) | ||
| await this.comfyPage.nextFrame() | ||
| await this.comfyPage.canvas.click() | ||
| await this.comfyPage.canvas.press('Control+a') | ||
| await this.comfyPage.nextFrame() | ||
| await this.page.evaluate(() => { | ||
| const canvas = window.app!.canvas | ||
| canvas.graph!.convertToSubgraph(canvas.selectedItems) | ||
| }) |
There was a problem hiding this comment.
Are you sure we cannot just:
- Control+a
- Click a node
- Find selection toolbox
- Convert to subgraph icon -> click
(while staying in vue mode)
What's currently making this difficult/flaky? Finding a node to click in the viewport?
There was a problem hiding this comment.
I have a child branch where I'm working on updating the Helper logic to do things like this.
| await this.comfyPage.nextFrame() | ||
| } | ||
|
|
||
| static getTextSlotPosition(page: Page, nodeId: string) { |
There was a problem hiding this comment.
nit: I know this is a pre-existing method in the subgraph helpers, but this feels like it wants to be in another helper or the node reference class.
| expect(widgetBox.y).toBeGreaterThan(headerBox.y + headerBox.height) | ||
| } | ||
|
|
||
| static collectConsoleWarnings( |
There was a problem hiding this comment.
Honest question: is this actually considered good practice? Genuinely don't know the arguments for/against using this pattern in e2e tests.
There was a problem hiding this comment.
Taking a step back, having information that's only in the console isn't great for users. If it's a real problem that they can fix, it should be presented to them. If it's not a real problem, why log it in the first place?
For cases like this, it can be very useful within test and dev contexts to have extra information about known past issues that you can confirm are behaving in the way you expect even when it is opaque to a user.
christian-byrne
left a comment
There was a problem hiding this comment.
Forgot to approve
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
browser_tests/tests/subgraphNestedConfigureOrder.spec.ts (1)
12-19:⚠️ Potential issue | 🟡 MinorDispose the console listener to avoid test pollution.
collectConsoleWarningsreturns adisposeteardown; not calling it leaves theconsolelistener attached longer than needed and can leak warnings into later steps/tests.♻️ Suggested fix
- const { warnings } = SubgraphHelper.collectConsoleWarnings(comfyPage.page, [ - 'No link found', - 'Failed to resolve legacy -1' - ]) - - await comfyPage.workflow.loadWorkflow(WORKFLOW) - - expect(warnings).toEqual([]) + const { warnings, dispose } = SubgraphHelper.collectConsoleWarnings( + comfyPage.page, + ['No link found', 'Failed to resolve legacy -1'] + ) + try { + await comfyPage.workflow.loadWorkflow(WORKFLOW) + expect(warnings).toEqual([]) + } finally { + dispose() + }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@browser_tests/tests/subgraphNestedConfigureOrder.spec.ts` around lines 12 - 19, collectConsoleWarnings attaches a console listener and returns a teardown function; you should capture and call that dispose to avoid leaking listeners. Update the test around SubgraphHelper.collectConsoleWarnings(comfyPage.page, [...]) to store the returned dispose (e.g., const { warnings, dispose } = SubgraphHelper.collectConsoleWarnings(...)) and invoke dispose() after the assertion (after expect(warnings).toEqual([])) so the listener is removed and does not pollute later tests.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@browser_tests/tests/subgraphNestedConfigureOrder.spec.ts`:
- Around line 12-19: collectConsoleWarnings attaches a console listener and
returns a teardown function; you should capture and call that dispose to avoid
leaking listeners. Update the test around
SubgraphHelper.collectConsoleWarnings(comfyPage.page, [...]) to store the
returned dispose (e.g., const { warnings, dispose } =
SubgraphHelper.collectConsoleWarnings(...)) and invoke dispose() after the
assertion (after expect(warnings).toEqual([])) so the listener is removed and
does not pollute later tests.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: f36d8822-7650-4571-b50e-b568efe39737
📒 Files selected for processing (2)
browser_tests/tests/subgraphNestedConfigureOrder.spec.tsbrowser_tests/tests/subgraphPromotion.spec.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- browser_tests/tests/subgraphPromotion.spec.ts
- Rename convertDefaultKSamplerToSubgraph to loadDefaultAndConvertKSamplerToSubgraph - Remove redundant nextFrame() after convertToSubgraph (already called internally) - Add dispose() calls after collectConsoleWarnings assertions - Add explicit null guards on getSlotLabel() before non-null assertions Amp-Thread-ID: https://ampcode.com/threads/T-019d3651-bd02-760c-9542-a2fbe03e051a Co-authored-by: Amp <amp@ampcode.com>
## Summary Extract repeated patterns from 12 subgraph Playwright spec files into shared test utilities, reducing duplication by ~142 lines. ## Changes - **What**: New shared helpers for common subgraph test operations: - `SubgraphHelper`: `getSlotCount()`, `getSlotLabel()`, `removeSlot()`, `findSubgraphNodeId()` - `NodeReference`: `delete()` - `subgraphTestUtils`: `serializeAndReload()`, `convertDefaultKSamplerToSubgraph()`, `expectWidgetBelowHeader()`, `collectConsoleWarnings()`, `packAllInteriorNodes()` - Replaced ~72 inline `page.evaluate` blocks and multi-line sequences with single helper calls across 12 spec files ## Review Focus - Behavioral equivalence: every replacement is a mechanical extraction with no test logic changes - API surface of new helpers: naming, parameter types, placement in existing utility classes - Whether any remaining inline patterns in the spec files would benefit from further extraction ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-10629-test-extract-shared-subgraph-E2E-test-utilities-3306d73d365081b0b6b5db52ed0a4552) by [Unito](https://www.unito.io) --------- Co-authored-by: Amp <amp@ampcode.com>
## Summary Extract repeated patterns from 12 subgraph Playwright spec files into shared test utilities, reducing duplication by ~142 lines. ## Changes - **What**: New shared helpers for common subgraph test operations: - `SubgraphHelper`: `getSlotCount()`, `getSlotLabel()`, `removeSlot()`, `findSubgraphNodeId()` - `NodeReference`: `delete()` - `subgraphTestUtils`: `serializeAndReload()`, `convertDefaultKSamplerToSubgraph()`, `expectWidgetBelowHeader()`, `collectConsoleWarnings()`, `packAllInteriorNodes()` - Replaced ~72 inline `page.evaluate` blocks and multi-line sequences with single helper calls across 12 spec files ## Review Focus - Behavioral equivalence: every replacement is a mechanical extraction with no test logic changes - API surface of new helpers: naming, parameter types, placement in existing utility classes - Whether any remaining inline patterns in the spec files would benefit from further extraction ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-10629-test-extract-shared-subgraph-E2E-test-utilities-3306d73d365081b0b6b5db52ed0a4552) by [Unito](https://www.unito.io) --------- Co-authored-by: Amp <amp@ampcode.com>
## Summary Extract repeated patterns from 12 subgraph Playwright spec files into shared test utilities, reducing duplication by ~142 lines. ## Changes - **What**: New shared helpers for common subgraph test operations: - `SubgraphHelper`: `getSlotCount()`, `getSlotLabel()`, `removeSlot()`, `findSubgraphNodeId()` - `NodeReference`: `delete()` - `subgraphTestUtils`: `serializeAndReload()`, `convertDefaultKSamplerToSubgraph()`, `expectWidgetBelowHeader()`, `collectConsoleWarnings()`, `packAllInteriorNodes()` - Replaced ~72 inline `page.evaluate` blocks and multi-line sequences with single helper calls across 12 spec files ## Review Focus - Behavioral equivalence: every replacement is a mechanical extraction with no test logic changes - API surface of new helpers: naming, parameter types, placement in existing utility classes - Whether any remaining inline patterns in the spec files would benefit from further extraction ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-10629-test-extract-shared-subgraph-E2E-test-utilities-3306d73d365081b0b6b5db52ed0a4552) by [Unito](https://www.unito.io) --------- Co-authored-by: Amp <amp@ampcode.com>
Summary
Extract repeated patterns from 12 subgraph Playwright spec files into shared test utilities, reducing duplication by ~142 lines.
Changes
SubgraphHelper:getSlotCount(),getSlotLabel(),removeSlot(),findSubgraphNodeId()NodeReference:delete()subgraphTestUtils:serializeAndReload(),convertDefaultKSamplerToSubgraph(),expectWidgetBelowHeader(),collectConsoleWarnings(),packAllInteriorNodes()page.evaluateblocks and multi-line sequences with single helper calls across 12 spec filesReview Focus
┆Issue is synchronized with this Notion page by Unito