From a01033067a367429028453853f37e1a0a31ad7e4 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Fri, 11 Sep 2026 20:17:00 -0700 Subject: [PATCH 01/28] test: cover subgraph UI lifecycle boundaries --- browser_tests/tests/nodeReplacement.spec.ts | 8 + .../subgraph/subgraphEcsScenarios.spec.ts | 231 ++++++++++++++++++ 2 files changed, 239 insertions(+) create mode 100644 browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts diff --git a/browser_tests/tests/nodeReplacement.spec.ts b/browser_tests/tests/nodeReplacement.spec.ts index b1401b4ea15..492c686ddf2 100644 --- a/browser_tests/tests/nodeReplacement.spec.ts +++ b/browser_tests/tests/nodeReplacement.spec.ts @@ -82,6 +82,12 @@ test.describe('Node replacement', { tag: ['@node', '@ui'] }, () => { test('Replace Node replaces a single group in-place', async ({ comfyPage }) => { + const before = await comfyPage.page.evaluate((nodeId) => { + const node = window.app!.graph!.getNodeById(nodeId) + if (!node) + throw new Error('Missing-node placeholder was not loaded') + return { pos: [...node.pos], size: [...node.size] } + }, toNodeId(1)) const swapGroup = getSwapNodesGroup(comfyPage.page) await swapGroup.getByRole('button', { name: /replace node/i }).click() await expect(swapGroup).toBeHidden() @@ -101,6 +107,8 @@ test.describe('Node replacement', { tag: ['@node', '@ui'] }, () => { ksampler?.id, 'Replaced node should keep the original id' ).toBe(1) + expect(ksampler?.pos).toEqual(before.pos) + expect(ksampler?.size).toEqual(before.size) const linkFromReplacedToDecode = workflow.links?.find( (l) => l[1] === 1 && l[3] === 2 diff --git a/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts b/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts new file mode 100644 index 00000000000..dca5ef28fbb --- /dev/null +++ b/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts @@ -0,0 +1,231 @@ +import { expect, mergeTests } from '@playwright/test' + +import { comfyPageFixture } from '@e2e/fixtures/ComfyPage' +import { subgraphBreadcrumbFixture } from '@e2e/fixtures/helpers/SubgraphBreadcrumbHelper' + +const test = mergeTests(comfyPageFixture, subgraphBreadcrumbFixture) + +const modes = [ + { label: 'LiteGraph', vueNodesEnabled: false }, + { label: 'Vue', vueNodesEnabled: true } +] as const + +test.describe( + 'Subgraph ECS user scenarios', + { tag: ['@subgraph', '@ui'] }, + () => { + for (const mode of modes) { + test.describe(`${mode.label} renderer`, () => { + test.beforeEach(async ({ comfyPage }) => { + await comfyPage.settings.setSetting( + 'Comfy.VueNodes.Enabled', + mode.vueNodesEnabled + ) + }) + + test('parent edits reach the exact interior widget and copied hosts remain independent', async ({ + comfyPage + }) => { + await comfyPage.workflow.loadWorkflow( + 'subgraphs/subgraph-with-promoted-text-widget' + ) + + const original = await comfyPage.nodeOps.getNodeRefById('11') + const parentWidget = comfyPage.page.getByRole('textbox', { + name: 'text', + exact: true + }) + await expect(parentWidget).toHaveCount(1) + await parentWidget.fill('original parent edit') + await expect(parentWidget).toHaveValue('original parent edit') + + await original.navigateIntoSubgraph() + const interiorWidget = comfyPage.page.getByRole('textbox', { + name: 'text', + exact: true + }) + await expect(interiorWidget).toHaveCount(1) + await expect(interiorWidget).toHaveValue('original parent edit') + await comfyPage.subgraph.exitViaBreadcrumb() + + await original.click('title') + await comfyPage.clipboard.copy() + await comfyPage.clipboard.paste() + await expect + .poll(() => + comfyPage.page.evaluate( + () => + window.app!.graph!.nodes.filter((node) => + node.isSubgraphNode() + ).length + ) + ) + .toBe(2) + + const copyId = await comfyPage.page.evaluate(() => { + const copy = window.app!.graph!.nodes.find( + (node) => node.isSubgraphNode() && String(node.id) !== '11' + ) + if (!copy) throw new Error('Pasted subgraph host was not created') + return String(copy.id) + }) + const copy = await comfyPage.nodeOps.getNodeRefById(copyId) + const hostWidgets = comfyPage.page.getByRole('textbox', { + name: 'text', + exact: true + }) + await expect(hostWidgets).toHaveCount(2) + const originalWidget = hostWidgets.first() + const copyWidget = hostWidgets.last() + await copyWidget.fill('copy-only edit') + + await expect(copyWidget).toHaveValue('copy-only edit') + await expect(originalWidget).toHaveValue('original parent edit') + + await copy.delete() + await expect.poll(() => copy.exists()).toBe(false) + await expect(parentWidget).toHaveValue('original parent edit') + await parentWidget.fill('original survives duplicate deletion') + await original.navigateIntoSubgraph() + await expect(interiorWidget).toHaveValue( + 'original survives duplicate deletion' + ) + }) + + for (const deleteOriginal of [true, false]) { + test(`surviving ${deleteOriginal ? 'copy' : 'original'} opens and edits after save/reload`, async ({ + comfyPage + }) => { + await comfyPage.workflow.setupWorkflowsDirectory({}) + await comfyPage.workflow.loadWorkflow( + 'subgraphs/subgraph-with-promoted-text-widget' + ) + const original = await comfyPage.nodeOps.getNodeRefById('11') + await original.click('title') + await comfyPage.clipboard.copy() + await comfyPage.clipboard.paste() + + await expect + .poll(() => + comfyPage.page.evaluate(() => + window.app!.graph!.nodes.some( + (node) => node.isSubgraphNode() && String(node.id) !== '11' + ) + ) + ) + .toBe(true) + const copyId = await comfyPage.page.evaluate(() => + String( + window.app!.graph!.nodes.find( + (node) => node.isSubgraphNode() && String(node.id) !== '11' + )!.id + ) + ) + + const removed = await comfyPage.nodeOps.getNodeRefById( + deleteOriginal ? '11' : copyId + ) + const survivorId = deleteOriginal ? copyId : '11' + await removed.delete() + await comfyPage.menu.topbar.saveWorkflow( + `${mode.label.toLowerCase()}-${deleteOriginal ? 'copy' : 'original'}-survivor` + ) + await comfyPage.workflow.reloadAndWaitForApp() + + const survivor = await comfyPage.nodeOps.getNodeRefById(survivorId) + await expect.poll(() => survivor.exists()).toBe(true) + const survivorWidget = comfyPage.page.getByRole('textbox', { + name: 'text', + exact: true + }) + await expect(survivorWidget).toHaveCount(1) + await survivorWidget.fill('editable after reload') + await survivor.navigateIntoSubgraph() + await expect( + comfyPage.page.getByRole('textbox', { + name: 'text', + exact: true + }) + ).toHaveValue('editable after reload') + }) + } + + test('nested controls and breadcrumbs preserve exact topology and root undo', async ({ + comfyPage, + subgraphBreadcrumb + }) => { + await comfyPage.workflow.loadWorkflow('subgraphs/nested-subgraph') + + const topology = () => + comfyPage.page.evaluate(() => ({ + nodes: window + .app!.canvas.graph!.nodes.map((node) => String(node.id)) + .sort(), + links: [...window.app!.canvas.graph!.links.values()] + .map((link) => [ + String(link.origin_id), + link.origin_slot, + String(link.target_id), + link.target_slot + ]) + .sort() + })) + + expect(await topology()).toEqual({ + nodes: ['10', '8', '9'], + links: [ + ['10', 0, '8', 0], + ['10', 1, '8', 1], + ['8', 0, '9', 0] + ] + }) + + const rootNode = await comfyPage.nodeOps.getNodeRefById('8') + const originalPosition = + await rootNode.getProperty<[number, number]>('pos') + await rootNode.dragBy({ x: 80, y: 40 }) + await comfyPage.keyboard.undo() + await expect + .poll(() => rootNode.getProperty<[number, number]>('pos')) + .toEqual(originalPosition) + + const outer = await comfyPage.nodeOps.getNodeRefById('10') + await outer.navigateIntoSubgraph() + expect(await topology()).toEqual({ + nodes: ['10', '3', '6'], + links: [ + ['10', 0, '3', 2], + ['10', 1, '3', 3], + ['10', 2, '3', 0], + ['10', 3, '6', 0], + ['10', 4, '-20', 1], + ['3', 0, '-20', 0], + ['6', 0, '3', 1] + ] + }) + + const inner = await comfyPage.nodeOps.getNodeRefById('10') + await inner.navigateIntoSubgraph() + expect(await topology()).toEqual({ + nodes: ['4', '5', '7'], + links: [ + ['4', 0, '-20', 2], + ['4', 1, '-20', 3], + ['4', 1, '7', 0], + ['4', 2, '-20', 4], + ['5', 0, '-20', 1], + ['7', 0, '-20', 0] + ] + }) + + await subgraphBreadcrumb.clickItem( + 'subgraph-8beb610f-ddd1-4489-ae0d-2f732a4042ae' + ) + expect((await topology()).nodes).toEqual(['10', '3', '6']) + await subgraphBreadcrumb.clickItem('root') + expect((await topology()).nodes).toEqual(['10', '8', '9']) + }) + }) + } + } +) From 7f551bbd8486775e62f4b06cedeb396512652138 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Sat, 12 Sep 2026 03:22:37 +0000 Subject: [PATCH 02/28] [automated] Apply ESLint and Oxfmt fixes --- browser_tests/tests/nodeReplacement.spec.ts | 2 +- browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/browser_tests/tests/nodeReplacement.spec.ts b/browser_tests/tests/nodeReplacement.spec.ts index 492c686ddf2..38fd042289b 100644 --- a/browser_tests/tests/nodeReplacement.spec.ts +++ b/browser_tests/tests/nodeReplacement.spec.ts @@ -83,7 +83,7 @@ test.describe('Node replacement', { tag: ['@node', '@ui'] }, () => { comfyPage }) => { const before = await comfyPage.page.evaluate((nodeId) => { - const node = window.app!.graph!.getNodeById(nodeId) + const node = window.app!.graph.getNodeById(nodeId) if (!node) throw new Error('Missing-node placeholder was not loaded') return { pos: [...node.pos], size: [...node.size] } diff --git a/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts b/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts index dca5ef28fbb..e1980721498 100644 --- a/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts +++ b/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts @@ -55,7 +55,7 @@ test.describe( .poll(() => comfyPage.page.evaluate( () => - window.app!.graph!.nodes.filter((node) => + window.app!.graph.nodes.filter((node) => node.isSubgraphNode() ).length ) @@ -63,7 +63,7 @@ test.describe( .toBe(2) const copyId = await comfyPage.page.evaluate(() => { - const copy = window.app!.graph!.nodes.find( + const copy = window.app!.graph.nodes.find( (node) => node.isSubgraphNode() && String(node.id) !== '11' ) if (!copy) throw new Error('Pasted subgraph host was not created') @@ -108,7 +108,7 @@ test.describe( await expect .poll(() => comfyPage.page.evaluate(() => - window.app!.graph!.nodes.some( + window.app!.graph.nodes.some( (node) => node.isSubgraphNode() && String(node.id) !== '11' ) ) @@ -116,7 +116,7 @@ test.describe( .toBe(true) const copyId = await comfyPage.page.evaluate(() => String( - window.app!.graph!.nodes.find( + window.app!.graph.nodes.find( (node) => node.isSubgraphNode() && String(node.id) !== '11' )!.id ) From bd706d6b55cf83cbbae2eb2dc0439fc317d8c33d Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Fri, 11 Sep 2026 20:47:53 -0700 Subject: [PATCH 03/28] test: address subgraph scenario review feedback --- .../subgraph/subgraphEcsScenarios.spec.ts | 396 ++++++++++-------- 1 file changed, 211 insertions(+), 185 deletions(-) diff --git a/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts b/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts index e1980721498..bfc16dbf214 100644 --- a/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts +++ b/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts @@ -15,217 +15,243 @@ test.describe( { tag: ['@subgraph', '@ui'] }, () => { for (const mode of modes) { - test.describe(`${mode.label} renderer`, () => { - test.beforeEach(async ({ comfyPage }) => { - await comfyPage.settings.setSetting( - 'Comfy.VueNodes.Enabled', - mode.vueNodesEnabled - ) - }) - - test('parent edits reach the exact interior widget and copied hosts remain independent', async ({ - comfyPage - }) => { - await comfyPage.workflow.loadWorkflow( - 'subgraphs/subgraph-with-promoted-text-widget' - ) - - const original = await comfyPage.nodeOps.getNodeRefById('11') - const parentWidget = comfyPage.page.getByRole('textbox', { - name: 'text', - exact: true + test.describe( + `${mode.label} renderer`, + { tag: mode.vueNodesEnabled ? '@vue-nodes' : undefined }, + () => { + test.use({ + initialSettings: { + 'Comfy.VueNodes.Enabled': mode.vueNodesEnabled + } }) - await expect(parentWidget).toHaveCount(1) - await parentWidget.fill('original parent edit') - await expect(parentWidget).toHaveValue('original parent edit') - - await original.navigateIntoSubgraph() - const interiorWidget = comfyPage.page.getByRole('textbox', { - name: 'text', - exact: true - }) - await expect(interiorWidget).toHaveCount(1) - await expect(interiorWidget).toHaveValue('original parent edit') - await comfyPage.subgraph.exitViaBreadcrumb() - - await original.click('title') - await comfyPage.clipboard.copy() - await comfyPage.clipboard.paste() - await expect - .poll(() => - comfyPage.page.evaluate( - () => - window.app!.graph.nodes.filter((node) => - node.isSubgraphNode() - ).length - ) - ) - .toBe(2) - const copyId = await comfyPage.page.evaluate(() => { - const copy = window.app!.graph.nodes.find( - (node) => node.isSubgraphNode() && String(node.id) !== '11' - ) - if (!copy) throw new Error('Pasted subgraph host was not created') - return String(copy.id) - }) - const copy = await comfyPage.nodeOps.getNodeRefById(copyId) - const hostWidgets = comfyPage.page.getByRole('textbox', { - name: 'text', - exact: true - }) - await expect(hostWidgets).toHaveCount(2) - const originalWidget = hostWidgets.first() - const copyWidget = hostWidgets.last() - await copyWidget.fill('copy-only edit') - - await expect(copyWidget).toHaveValue('copy-only edit') - await expect(originalWidget).toHaveValue('original parent edit') - - await copy.delete() - await expect.poll(() => copy.exists()).toBe(false) - await expect(parentWidget).toHaveValue('original parent edit') - await parentWidget.fill('original survives duplicate deletion') - await original.navigateIntoSubgraph() - await expect(interiorWidget).toHaveValue( - 'original survives duplicate deletion' - ) - }) - - for (const deleteOriginal of [true, false]) { - test(`surviving ${deleteOriginal ? 'copy' : 'original'} opens and edits after save/reload`, async ({ + test('parent edits reach the exact interior widget and copied hosts remain independent', async ({ comfyPage }) => { - await comfyPage.workflow.setupWorkflowsDirectory({}) await comfyPage.workflow.loadWorkflow( 'subgraphs/subgraph-with-promoted-text-widget' ) + const original = await comfyPage.nodeOps.getNodeRefById('11') + const parentWidget = comfyPage.page.getByRole('textbox', { + name: 'text', + exact: true + }) + await expect(parentWidget).toHaveCount(1) + await parentWidget.fill('original parent edit') + await expect(parentWidget).toHaveValue('original parent edit') + + await original.navigateIntoSubgraph() + const interiorWidget = comfyPage.page.getByRole('textbox', { + name: 'text', + exact: true + }) + await expect(interiorWidget).toHaveCount(1) + await expect(interiorWidget).toHaveValue('original parent edit') + await comfyPage.subgraph.exitViaBreadcrumb() + await original.click('title') await comfyPage.clipboard.copy() await comfyPage.clipboard.paste() - await expect .poll(() => - comfyPage.page.evaluate(() => - window.app!.graph.nodes.some( - (node) => node.isSubgraphNode() && String(node.id) !== '11' - ) + comfyPage.page.evaluate( + () => + window.app!.graph.nodes.filter((node) => + node.isSubgraphNode() + ).length ) ) - .toBe(true) - const copyId = await comfyPage.page.evaluate(() => - String( - window.app!.graph.nodes.find( - (node) => node.isSubgraphNode() && String(node.id) !== '11' - )!.id - ) - ) + .toBe(2) - const removed = await comfyPage.nodeOps.getNodeRefById( - deleteOriginal ? '11' : copyId - ) - const survivorId = deleteOriginal ? copyId : '11' - await removed.delete() - await comfyPage.menu.topbar.saveWorkflow( - `${mode.label.toLowerCase()}-${deleteOriginal ? 'copy' : 'original'}-survivor` - ) - await comfyPage.workflow.reloadAndWaitForApp() - - const survivor = await comfyPage.nodeOps.getNodeRefById(survivorId) - await expect.poll(() => survivor.exists()).toBe(true) - const survivorWidget = comfyPage.page.getByRole('textbox', { + const copyId = await comfyPage.page.evaluate(() => { + const copy = window.app!.graph.nodes.find( + (node) => node.isSubgraphNode() && String(node.id) !== '11' + ) + if (!copy) throw new Error('Pasted subgraph host was not created') + return String(copy.id) + }) + const copy = await comfyPage.nodeOps.getNodeRefById(copyId) + const hostWidgets = comfyPage.page.getByRole('textbox', { name: 'text', exact: true }) - await expect(survivorWidget).toHaveCount(1) - await survivorWidget.fill('editable after reload') - await survivor.navigateIntoSubgraph() - await expect( - comfyPage.page.getByRole('textbox', { + await expect(hostWidgets).toHaveCount(2) + const originalWidget = hostWidgets.first() + const copyWidget = hostWidgets.last() + await copyWidget.fill('copy-only edit') + + await expect(copyWidget).toHaveValue('copy-only edit') + await expect(originalWidget).toHaveValue('original parent edit') + + await copy.delete() + await expect.poll(() => copy.exists()).toBe(false) + await expect(parentWidget).toHaveValue('original parent edit') + await parentWidget.fill('original survives duplicate deletion') + await original.navigateIntoSubgraph() + await expect(interiorWidget).toHaveValue( + 'original survives duplicate deletion' + ) + }) + + for (const deleteOriginal of [true, false]) { + test(`surviving ${deleteOriginal ? 'copy' : 'original'} opens and edits after save/reload`, async ({ + comfyPage + }) => { + await comfyPage.workflow.setupWorkflowsDirectory({}) + await comfyPage.workflow.loadWorkflow( + 'subgraphs/subgraph-with-promoted-text-widget' + ) + const original = await comfyPage.nodeOps.getNodeRefById('11') + await original.click('title') + await comfyPage.clipboard.copy() + await comfyPage.clipboard.paste() + + await expect + .poll(() => + comfyPage.page.evaluate(() => + window.app!.graph.nodes.some( + (node) => + node.isSubgraphNode() && String(node.id) !== '11' + ) + ) + ) + .toBe(true) + const copyId = await comfyPage.page.evaluate(() => + String( + window.app!.graph.nodes.find( + (node) => node.isSubgraphNode() && String(node.id) !== '11' + )!.id + ) + ) + + const removed = await comfyPage.nodeOps.getNodeRefById( + deleteOriginal ? '11' : copyId + ) + const survivorId = deleteOriginal ? copyId : '11' + await removed.delete() + await comfyPage.menu.topbar.saveWorkflow( + `${mode.label.toLowerCase()}-${deleteOriginal ? 'copy' : 'original'}-survivor` + ) + await comfyPage.workflow.reloadAndWaitForApp() + + const survivor = + await comfyPage.nodeOps.getNodeRefById(survivorId) + await expect.poll(() => survivor.exists()).toBe(true) + const survivorWidget = comfyPage.page.getByRole('textbox', { name: 'text', exact: true }) - ).toHaveValue('editable after reload') - }) - } + await expect(survivorWidget).toHaveCount(1) + await survivorWidget.fill('editable after reload') + await survivor.navigateIntoSubgraph() + await expect( + comfyPage.page.getByRole('textbox', { + name: 'text', + exact: true + }) + ).toHaveValue('editable after reload') + }) + } - test('nested controls and breadcrumbs preserve exact topology and root undo', async ({ - comfyPage, - subgraphBreadcrumb - }) => { - await comfyPage.workflow.loadWorkflow('subgraphs/nested-subgraph') - - const topology = () => - comfyPage.page.evaluate(() => ({ - nodes: window - .app!.canvas.graph!.nodes.map((node) => String(node.id)) - .sort(), - links: [...window.app!.canvas.graph!.links.values()] - .map((link) => [ - String(link.origin_id), - link.origin_slot, - String(link.target_id), - link.target_slot - ]) - .sort() - })) - - expect(await topology()).toEqual({ - nodes: ['10', '8', '9'], - links: [ - ['10', 0, '8', 0], - ['10', 1, '8', 1], - ['8', 0, '9', 0] - ] - }) + test('nested controls and breadcrumbs preserve exact topology and root undo', async ({ + comfyPage, + subgraphBreadcrumb + }) => { + await comfyPage.workflow.loadWorkflow('subgraphs/nested-subgraph') - const rootNode = await comfyPage.nodeOps.getNodeRefById('8') - const originalPosition = - await rootNode.getProperty<[number, number]>('pos') - await rootNode.dragBy({ x: 80, y: 40 }) - await comfyPage.keyboard.undo() - await expect - .poll(() => rootNode.getProperty<[number, number]>('pos')) - .toEqual(originalPosition) - - const outer = await comfyPage.nodeOps.getNodeRefById('10') - await outer.navigateIntoSubgraph() - expect(await topology()).toEqual({ - nodes: ['10', '3', '6'], - links: [ - ['10', 0, '3', 2], - ['10', 1, '3', 3], - ['10', 2, '3', 0], - ['10', 3, '6', 0], - ['10', 4, '-20', 1], - ['3', 0, '-20', 0], - ['6', 0, '3', 1] - ] - }) + const topology = () => + comfyPage.page.evaluate(() => ({ + nodes: window + .app!.canvas.graph!.nodes.map((node) => String(node.id)) + .sort(), + links: [...window.app!.canvas.graph!.links.values()] + .map((link) => [ + String(link.origin_id), + link.origin_slot, + String(link.target_id), + link.target_slot + ]) + .sort() + })) - const inner = await comfyPage.nodeOps.getNodeRefById('10') - await inner.navigateIntoSubgraph() - expect(await topology()).toEqual({ - nodes: ['4', '5', '7'], - links: [ - ['4', 0, '-20', 2], - ['4', 1, '-20', 3], - ['4', 1, '7', 0], - ['4', 2, '-20', 4], - ['5', 0, '-20', 1], - ['7', 0, '-20', 0] - ] - }) + expect(await topology()).toEqual({ + nodes: ['10', '8', '9'], + links: [ + ['10', 0, '8', 0], + ['10', 1, '8', 1], + ['8', 0, '9', 0] + ] + }) + + const rootNode = await comfyPage.nodeOps.getNodeRefById('8') + const originalPosition = + await rootNode.getProperty<[number, number]>('pos') + await rootNode.dragBy({ x: 80, y: 40 }) + await expect + .poll(() => rootNode.getProperty<[number, number]>('pos')) + .not.toEqual(originalPosition) + await comfyPage.keyboard.undo() + await expect + .poll(() => rootNode.getProperty<[number, number]>('pos')) + .toEqual(originalPosition) + + const outer = await comfyPage.nodeOps.getNodeRefById('10') + await outer.navigateIntoSubgraph() + expect(await topology()).toEqual({ + nodes: ['10', '3', '6'], + links: [ + ['10', 0, '3', 2], + ['10', 1, '3', 3], + ['10', 2, '3', 0], + ['10', 3, '6', 0], + ['10', 4, '-20', 1], + ['3', 0, '-20', 0], + ['6', 0, '3', 1] + ] + }) - await subgraphBreadcrumb.clickItem( - 'subgraph-8beb610f-ddd1-4489-ae0d-2f732a4042ae' - ) - expect((await topology()).nodes).toEqual(['10', '3', '6']) - await subgraphBreadcrumb.clickItem('root') - expect((await topology()).nodes).toEqual(['10', '8', '9']) - }) - }) + const inner = await comfyPage.nodeOps.getNodeRefById('10') + await inner.navigateIntoSubgraph() + expect(await topology()).toEqual({ + nodes: ['4', '5', '7'], + links: [ + ['4', 0, '-20', 2], + ['4', 1, '-20', 3], + ['4', 1, '7', 0], + ['4', 2, '-20', 4], + ['5', 0, '-20', 1], + ['7', 0, '-20', 0] + ] + }) + + await subgraphBreadcrumb.clickItem( + 'subgraph-8beb610f-ddd1-4489-ae0d-2f732a4042ae' + ) + expect(await topology()).toEqual({ + nodes: ['11', '3', '6'], + links: [ + ['11', 0, '3', 2], + ['11', 1, '3', 3], + ['11', 2, '3', 0], + ['11', 3, '6', 0], + ['11', 4, '-20', 1], + ['3', 0, '-20', 0], + ['6', 0, '3', 1] + ] + }) + await subgraphBreadcrumb.clickItem('root') + expect(await topology()).toEqual({ + nodes: ['10', '8', '9'], + links: [ + ['10', 0, '8', 0], + ['10', 1, '8', 1], + ['8', 0, '9', 0] + ] + }) + }) + } + ) } } ) From a1e87e558de93647f6e1fefd1cfc0fe321859983 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Fri, 11 Sep 2026 21:37:28 -0700 Subject: [PATCH 04/28] test: correct subgraph lifecycle contracts --- .../subgraph/subgraphEcsScenarios.spec.ts | 168 +++++++++++++----- 1 file changed, 125 insertions(+), 43 deletions(-) diff --git a/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts b/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts index bfc16dbf214..1535e80c2ee 100644 --- a/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts +++ b/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts @@ -2,6 +2,9 @@ import { expect, mergeTests } from '@playwright/test' import { comfyPageFixture } from '@e2e/fixtures/ComfyPage' import { subgraphBreadcrumbFixture } from '@e2e/fixtures/helpers/SubgraphBreadcrumbHelper' +import type { NodeReference } from '@e2e/fixtures/utils/litegraphUtils' + +import { zComfyWorkflow } from '@/platform/workflow/validation/schemas/workflowSchema' const test = mergeTests(comfyPageFixture, subgraphBreadcrumbFixture) @@ -25,7 +28,7 @@ test.describe( } }) - test('parent edits reach the exact interior widget and copied hosts remain independent', async ({ + test('promoted widget values remain independent across copied hosts', async ({ comfyPage }) => { await comfyPage.workflow.loadWorkflow( @@ -33,22 +36,54 @@ test.describe( ) const original = await comfyPage.nodeOps.getNodeRefById('11') - const parentWidget = comfyPage.page.getByRole('textbox', { - name: 'text', - exact: true - }) + const hostWidget = async (node: NodeReference, nodeId: string) => { + if (mode.vueNodesEnabled) { + return comfyPage.vueNodes + .getNodeLocator(nodeId) + .getByRole('textbox', { name: 'text', exact: true }) + } + + const position = await ( + await node.getWidgetByName('text') + ).getPosition() + const textboxes = comfyPage.page.getByRole('textbox', { + name: 'text', + exact: true + }) + const boxes = await textboxes.evaluateAll((elements) => + elements.map((element) => { + const { x, y, width, height } = + element.getBoundingClientRect() + return { x, y, width, height } + }) + ) + const closestIndex = boxes.reduce( + (best, box, index) => { + const distance = Math.hypot( + box.x + box.width / 2 - position.x, + box.y + box.height / 2 - position.y + ) + return distance < best.distance ? { index, distance } : best + }, + { index: -1, distance: Number.POSITIVE_INFINITY } + ).index + if (closestIndex < 0) { + throw new Error( + `Text widget for node ${nodeId} was not rendered` + ) + } + return textboxes.nth(closestIndex) + } + + const parentWidget = await hostWidget(original, '11') await expect(parentWidget).toHaveCount(1) await parentWidget.fill('original parent edit') await expect(parentWidget).toHaveValue('original parent edit') - - await original.navigateIntoSubgraph() - const interiorWidget = comfyPage.page.getByRole('textbox', { - name: 'text', - exact: true - }) - await expect(interiorWidget).toHaveCount(1) - await expect(interiorWidget).toHaveValue('original parent edit') - await comfyPage.subgraph.exitViaBreadcrumb() + await expect + .poll(() => + original.getWidgetByName('text').then((w) => w.getValue()) + ) + .toBe('original parent edit') await original.click('title') await comfyPage.clipboard.copy() @@ -72,32 +107,43 @@ test.describe( return String(copy.id) }) const copy = await comfyPage.nodeOps.getNodeRefById(copyId) - const hostWidgets = comfyPage.page.getByRole('textbox', { - name: 'text', - exact: true - }) - await expect(hostWidgets).toHaveCount(2) - const originalWidget = hostWidgets.first() - const copyWidget = hostWidgets.last() + const copyWidget = await hostWidget(copy, copyId) + await expect(copyWidget).toHaveCount(1) await copyWidget.fill('copy-only edit') await expect(copyWidget).toHaveValue('copy-only edit') + const originalWidget = await hostWidget(original, '11') await expect(originalWidget).toHaveValue('original parent edit') + await expect + .poll(() => + copy.getWidgetByName('text').then((w) => w.getValue()) + ) + .toBe('copy-only edit') + await expect + .poll(() => + original.getWidgetByName('text').then((w) => w.getValue()) + ) + .toBe('original parent edit') await copy.delete() await expect.poll(() => copy.exists()).toBe(false) await expect(parentWidget).toHaveValue('original parent edit') await parentWidget.fill('original survives duplicate deletion') - await original.navigateIntoSubgraph() - await expect(interiorWidget).toHaveValue( - 'original survives duplicate deletion' - ) + await expect + .poll(() => + original.getWidgetByName('text').then((w) => w.getValue()) + ) + .toBe('original survives duplicate deletion') }) for (const deleteOriginal of [true, false]) { test(`surviving ${deleteOriginal ? 'copy' : 'original'} opens and edits after save/reload`, async ({ comfyPage }) => { + test.fail( + !mode.vueNodesEnabled && deleteOriginal, + 'LiteGraph serialization retains a deleted original subgraph host' + ) await comfyPage.workflow.setupWorkflowsDirectory({}) await comfyPage.workflow.loadWorkflow( 'subgraphs/subgraph-with-promoted-text-widget' @@ -130,10 +176,40 @@ test.describe( ) const survivorId = deleteOriginal ? copyId : '11' await removed.delete() - await comfyPage.menu.topbar.saveWorkflow( - `${mode.label.toLowerCase()}-${deleteOriginal ? 'copy' : 'original'}-survivor` + await expect.poll(() => removed.exists()).toBe(false) + const workflowName = `${mode.label.toLowerCase()}-${deleteOriginal ? 'copy' : 'original'}-survivor` + const workflowPath = `/api/userdata/${encodeURIComponent(`workflows/${workflowName}.json`)}` + const saveResponse = comfyPage.page.waitForResponse( + (response) => + new URL(response.url()).pathname === workflowPath && + response.request().method() === 'POST' + ) + await comfyPage.menu.topbar.saveWorkflow(workflowName) + expect((await saveResponse).status()).toBe(200) + + const persistedResponse = await comfyPage.request.get( + `${comfyPage.apiUrl}${workflowPath}`, + { headers: { 'Comfy-User': comfyPage.id } } + ) + expect(persistedResponse.ok()).toBe(true) + const persistedWorkflow = zComfyWorkflow.parse( + await persistedResponse.json() ) + expect( + persistedWorkflow.nodes + .filter((node) => + persistedWorkflow.definitions?.subgraphs.some( + (subgraph) => subgraph.id === node.type + ) + ) + .map((node) => String(node.id)) + ).toEqual([survivorId]) + await comfyPage.workflow.reloadAndWaitForApp() + await comfyPage.menu.workflowsTab.open() + await comfyPage.menu.workflowsTab + .getPersistedItem(workflowName) + .click() const survivor = await comfyPage.nodeOps.getNodeRefById(survivorId) @@ -144,13 +220,11 @@ test.describe( }) await expect(survivorWidget).toHaveCount(1) await survivorWidget.fill('editable after reload') - await survivor.navigateIntoSubgraph() - await expect( - comfyPage.page.getByRole('textbox', { - name: 'text', - exact: true - }) - ).toHaveValue('editable after reload') + await expect + .poll(() => + survivor.getWidgetByName('text').then((w) => w.getValue()) + ) + .toBe('editable after reload') }) } @@ -197,22 +271,30 @@ test.describe( .toEqual(originalPosition) const outer = await comfyPage.nodeOps.getNodeRefById('10') - await outer.navigateIntoSubgraph() + if (mode.vueNodesEnabled) { + await comfyPage.vueNodes.enterSubgraph('10') + } else { + await outer.navigateIntoSubgraph() + } expect(await topology()).toEqual({ - nodes: ['10', '3', '6'], + nodes: ['11', '3', '6'], links: [ - ['10', 0, '3', 2], - ['10', 1, '3', 3], - ['10', 2, '3', 0], - ['10', 3, '6', 0], - ['10', 4, '-20', 1], + ['11', 0, '3', 2], + ['11', 1, '3', 3], + ['11', 2, '3', 0], + ['11', 3, '6', 0], + ['11', 4, '-20', 1], ['3', 0, '-20', 0], ['6', 0, '3', 1] ] }) - const inner = await comfyPage.nodeOps.getNodeRefById('10') - await inner.navigateIntoSubgraph() + const inner = await comfyPage.nodeOps.getNodeRefById('11') + if (mode.vueNodesEnabled) { + await comfyPage.vueNodes.enterSubgraph('11') + } else { + await inner.navigateIntoSubgraph() + } expect(await topology()).toEqual({ nodes: ['4', '5', '7'], links: [ From 6b813db7faa8a971f5d7654738257ec5533c1313 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Fri, 11 Sep 2026 21:56:30 -0700 Subject: [PATCH 05/28] test: fix subgraph deletion target --- .../subgraph/subgraphEcsScenarios.spec.ts | 50 +++++++++++++------ 1 file changed, 36 insertions(+), 14 deletions(-) diff --git a/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts b/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts index 1535e80c2ee..fe78377e6e7 100644 --- a/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts +++ b/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts @@ -5,6 +5,7 @@ import { subgraphBreadcrumbFixture } from '@e2e/fixtures/helpers/SubgraphBreadcr import type { NodeReference } from '@e2e/fixtures/utils/litegraphUtils' import { zComfyWorkflow } from '@/platform/workflow/validation/schemas/workflowSchema' +import { toNodeId } from '@/types/nodeId' const test = mergeTests(comfyPageFixture, subgraphBreadcrumbFixture) @@ -140,10 +141,6 @@ test.describe( test(`surviving ${deleteOriginal ? 'copy' : 'original'} opens and edits after save/reload`, async ({ comfyPage }) => { - test.fail( - !mode.vueNodesEnabled && deleteOriginal, - 'LiteGraph serialization retains a deleted original subgraph host' - ) await comfyPage.workflow.setupWorkflowsDirectory({}) await comfyPage.workflow.loadWorkflow( 'subgraphs/subgraph-with-promoted-text-widget' @@ -171,12 +168,29 @@ test.describe( ) ) - const removed = await comfyPage.nodeOps.getNodeRefById( - deleteOriginal ? '11' : copyId - ) const survivorId = deleteOriginal ? copyId : '11' - await removed.delete() - await expect.poll(() => removed.exists()).toBe(false) + const removedId = toNodeId(deleteOriginal ? '11' : copyId) + await comfyPage.page.evaluate((removedId) => { + const node = window.app!.rootGraph.getNodeById(removedId) + if (!node) throw new Error(`Node ${removedId} not found`) + window.app!.canvas.deselectAll() + window.app!.canvas.selectNode(node) + }, removedId) + await comfyPage.page.keyboard.press('Delete') + await comfyPage.nextFrame() + await expect + .poll(() => + comfyPage.page.evaluate( + (removedId) => ({ + isRootGraphActive: + window.app!.canvas.graph === window.app!.rootGraph, + removedNodeExists: + window.app!.rootGraph.getNodeById(removedId) !== null + }), + removedId + ) + ) + .toEqual({ isRootGraphActive: true, removedNodeExists: false }) const workflowName = `${mode.label.toLowerCase()}-${deleteOriginal ? 'copy' : 'original'}-survivor` const workflowPath = `/api/userdata/${encodeURIComponent(`workflows/${workflowName}.json`)}` const saveResponse = comfyPage.page.waitForResponse( @@ -185,7 +199,14 @@ test.describe( response.request().method() === 'POST' ) await comfyPage.menu.topbar.saveWorkflow(workflowName) - expect((await saveResponse).status()).toBe(200) + const encodedSave = await saveResponse + expect(encodedSave.status()).toBe(200) + expect(encodedSave.request().headers()['comfy-user']).toBe( + comfyPage.id + ) + const encodedWorkflow = zComfyWorkflow.parse( + encodedSave.request().postDataJSON() + ) const persistedResponse = await comfyPage.request.get( `${comfyPage.apiUrl}${workflowPath}`, @@ -195,15 +216,16 @@ test.describe( const persistedWorkflow = zComfyWorkflow.parse( await persistedResponse.json() ) - expect( - persistedWorkflow.nodes + const serializedHostIds = (workflow: typeof encodedWorkflow) => + workflow.nodes .filter((node) => - persistedWorkflow.definitions?.subgraphs.some( + workflow.definitions?.subgraphs.some( (subgraph) => subgraph.id === node.type ) ) .map((node) => String(node.id)) - ).toEqual([survivorId]) + expect(serializedHostIds(encodedWorkflow)).toEqual([survivorId]) + expect(serializedHostIds(persistedWorkflow)).toEqual([survivorId]) await comfyPage.workflow.reloadAndWaitForApp() await comfyPage.menu.workflowsTab.open() From d9aae63cc669b11cdc15d5aca808cdbe3e5a21e7 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Fri, 11 Sep 2026 23:25:30 -0700 Subject: [PATCH 06/28] test: strengthen subgraph host lifecycle scenarios --- .../subgraph/subgraphEcsScenarios.spec.ts | 96 ++++++++++++++----- 1 file changed, 70 insertions(+), 26 deletions(-) diff --git a/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts b/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts index fe78377e6e7..7cc624e43ed 100644 --- a/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts +++ b/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts @@ -126,9 +126,23 @@ test.describe( ) .toBe('original parent edit') + await originalWidget.fill('original second edit') + await expect(originalWidget).toHaveValue('original second edit') + await expect(copyWidget).toHaveValue('copy-only edit') + await expect + .poll(() => + original.getWidgetByName('text').then((w) => w.getValue()) + ) + .toBe('original second edit') + await expect + .poll(() => + copy.getWidgetByName('text').then((w) => w.getValue()) + ) + .toBe('copy-only edit') + await copy.delete() await expect.poll(() => copy.exists()).toBe(false) - await expect(parentWidget).toHaveValue('original parent edit') + await expect(parentWidget).toHaveValue('original second edit') await parentWidget.fill('original survives duplicate deletion') await expect .poll(() => @@ -169,6 +183,18 @@ test.describe( ) const survivorId = deleteOriginal ? copyId : '11' + const survivorNodeId = toNodeId(survivorId) + const survivorGraphId = await comfyPage.page.evaluate( + (survivorNodeId) => { + const survivor = + window.app!.rootGraph.getNodeById(survivorNodeId) + if (!survivor?.isSubgraphNode()) { + throw new Error(`Subgraph host ${survivorNodeId} not found`) + } + return survivor.subgraph.id + }, + survivorNodeId + ) const removedId = toNodeId(deleteOriginal ? '11' : copyId) await comfyPage.page.evaluate((removedId) => { const node = window.app!.rootGraph.getNodeById(removedId) @@ -232,21 +258,38 @@ test.describe( await comfyPage.menu.workflowsTab .getPersistedItem(workflowName) .click() + await comfyPage.menu.workflowsTab.close() const survivor = await comfyPage.nodeOps.getNodeRefById(survivorId) await expect.poll(() => survivor.exists()).toBe(true) - const survivorWidget = comfyPage.page.getByRole('textbox', { - name: 'text', - exact: true - }) - await expect(survivorWidget).toHaveCount(1) - await survivorWidget.fill('editable after reload') + if (mode.vueNodesEnabled) { + await comfyPage.vueNodes.enterSubgraph(survivorId) + } else { + await survivor.navigateIntoSubgraph() + } await expect .poll(() => - survivor.getWidgetByName('text').then((w) => w.getValue()) + comfyPage.page.evaluate(() => window.app!.canvas.graph?.id) + ) + .toBe(survivorGraphId) + + const innerId = await comfyPage.page.evaluate(() => { + const graph = window.app!.canvas.graph + if (!graph) throw new Error('Surviving subgraph did not open') + const inner = graph.nodes.find( + (node) => node.type === 'CLIPTextEncode' ) - .toBe('editable after reload') + if (!inner) throw new Error('Inner text node not found') + return String(inner.id) + }) + const inner = await comfyPage.nodeOps.getNodeRefById(innerId) + await expect.poll(() => inner.exists()).toBe(true) + const originalInnerPosition = await inner.getPosition() + await inner.dragBy({ x: 40, y: 20 }) + await expect + .poll(() => inner.getPosition()) + .not.toEqual(originalInnerPosition) }) } @@ -257,19 +300,21 @@ test.describe( await comfyPage.workflow.loadWorkflow('subgraphs/nested-subgraph') const topology = () => - comfyPage.page.evaluate(() => ({ - nodes: window - .app!.canvas.graph!.nodes.map((node) => String(node.id)) - .sort(), - links: [...window.app!.canvas.graph!.links.values()] - .map((link) => [ - String(link.origin_id), - link.origin_slot, - String(link.target_id), - link.target_slot - ]) - .sort() - })) + comfyPage.page.evaluate(() => { + const graph = window.app!.canvas.graph + if (!graph) throw new Error('Canvas graph is not available') + return { + nodes: graph.nodes.map((node) => String(node.id)).sort(), + links: [...graph.links.values()] + .map((link) => [ + String(link.origin_id), + link.origin_slot, + String(link.target_id), + link.target_slot + ]) + .sort() + } + }) expect(await topology()).toEqual({ nodes: ['10', '8', '9'], @@ -281,15 +326,14 @@ test.describe( }) const rootNode = await comfyPage.nodeOps.getNodeRefById('8') - const originalPosition = - await rootNode.getProperty<[number, number]>('pos') + const originalPosition = await rootNode.getPosition() await rootNode.dragBy({ x: 80, y: 40 }) await expect - .poll(() => rootNode.getProperty<[number, number]>('pos')) + .poll(() => rootNode.getPosition()) .not.toEqual(originalPosition) await comfyPage.keyboard.undo() await expect - .poll(() => rootNode.getProperty<[number, number]>('pos')) + .poll(() => rootNode.getPosition()) .toEqual(originalPosition) const outer = await comfyPage.nodeOps.getNodeRefById('10') From 7b854c933e95441a3e1467f57c8d8f3762a062cc Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Sat, 12 Sep 2026 01:42:46 -0700 Subject: [PATCH 07/28] test: use canvas geometry helper for replacement Addresses review feedback: https://github.com/Comfy-Org/ComfyUI_frontend/pull/17516#discussion_r3995540425 --- browser_tests/tests/nodeReplacement.spec.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/browser_tests/tests/nodeReplacement.spec.ts b/browser_tests/tests/nodeReplacement.spec.ts index cfc44207401..9b45fabc5b0 100644 --- a/browser_tests/tests/nodeReplacement.spec.ts +++ b/browser_tests/tests/nodeReplacement.spec.ts @@ -88,6 +88,9 @@ test.describe('Node replacement', { tag: ['@node', '@ui'] }, () => { test('Replace Node replaces a single group in-place', async ({ comfyPage }) => { + const before = await comfyPage.canvasOps.getNodeGeometry( + toNodeId(1) + ) const swapGroup = getSwapNodesGroup(comfyPage.page) await swapGroup .getByRole('button', { name: /replace node/i }) @@ -109,6 +112,8 @@ test.describe('Node replacement', { tag: ['@node', '@ui'] }, () => { ksampler?.id, 'Replaced node should keep the original id' ).toBe(1) + expect(ksampler?.pos).toEqual(before.pos) + expect(ksampler?.size).toEqual(before.size) const linkFromReplacedToDecode = workflow.links?.find( (l) => l[1] === 1 && l[3] === 2 From 5e402eb41c56dd10a6a1185b28b1fbbe609aeede Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Sat, 12 Sep 2026 01:43:33 -0700 Subject: [PATCH 08/28] test: move promoted widget lookup to node reference Addresses review feedback: https://github.com/Comfy-Org/ComfyUI_frontend/pull/17516#discussion_r3995540431 --- .../fixtures/utils/litegraphUtils.ts | 34 ++++++++++++++ .../subgraph/subgraphEcsScenarios.spec.ts | 46 ++----------------- 2 files changed, 37 insertions(+), 43 deletions(-) diff --git a/browser_tests/fixtures/utils/litegraphUtils.ts b/browser_tests/fixtures/utils/litegraphUtils.ts index d3a1e76d0e3..aa45cf4a1b4 100644 --- a/browser_tests/fixtures/utils/litegraphUtils.ts +++ b/browser_tests/fixtures/utils/litegraphUtils.ts @@ -406,6 +406,40 @@ export class NodeReference { return new NodeWidgetReference(index, this) } + async getPromotedTextWidget(name: string) { + const vueNode = this.comfyPage.vueNodes.getNodeLocator(String(this.id)) + if ((await vueNode.count()) > 0) { + return vueNode.getByRole('textbox', { name, exact: true }) + } + + const position = await (await this.getWidgetByName(name)).getPosition() + const textboxes = this.comfyPage.page.getByRole('textbox', { + name, + exact: true + }) + const boxes = await textboxes.evaluateAll((elements) => + elements.map((element) => { + const { x, y, width, height } = element.getBoundingClientRect() + return { x, y, width, height } + }) + ) + const closestIndex = boxes.reduce( + (best, box, index) => { + const distance = Math.hypot( + box.x + box.width / 2 - position.x, + box.y + box.height / 2 - position.y + ) + return distance < best.distance ? { index, distance } : best + }, + { index: -1, distance: Number.POSITIVE_INFINITY } + ).index + if (closestIndex < 0) { + throw new Error( + `Text widget "${name}" for node ${this.id} was not rendered` + ) + } + return textboxes.nth(closestIndex) + } async click( position: 'title' | 'collapse', options?: { diff --git a/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts b/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts index 7cc624e43ed..8512fa9ffd2 100644 --- a/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts +++ b/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts @@ -2,7 +2,6 @@ import { expect, mergeTests } from '@playwright/test' import { comfyPageFixture } from '@e2e/fixtures/ComfyPage' import { subgraphBreadcrumbFixture } from '@e2e/fixtures/helpers/SubgraphBreadcrumbHelper' -import type { NodeReference } from '@e2e/fixtures/utils/litegraphUtils' import { zComfyWorkflow } from '@/platform/workflow/validation/schemas/workflowSchema' import { toNodeId } from '@/types/nodeId' @@ -37,46 +36,7 @@ test.describe( ) const original = await comfyPage.nodeOps.getNodeRefById('11') - const hostWidget = async (node: NodeReference, nodeId: string) => { - if (mode.vueNodesEnabled) { - return comfyPage.vueNodes - .getNodeLocator(nodeId) - .getByRole('textbox', { name: 'text', exact: true }) - } - - const position = await ( - await node.getWidgetByName('text') - ).getPosition() - const textboxes = comfyPage.page.getByRole('textbox', { - name: 'text', - exact: true - }) - const boxes = await textboxes.evaluateAll((elements) => - elements.map((element) => { - const { x, y, width, height } = - element.getBoundingClientRect() - return { x, y, width, height } - }) - ) - const closestIndex = boxes.reduce( - (best, box, index) => { - const distance = Math.hypot( - box.x + box.width / 2 - position.x, - box.y + box.height / 2 - position.y - ) - return distance < best.distance ? { index, distance } : best - }, - { index: -1, distance: Number.POSITIVE_INFINITY } - ).index - if (closestIndex < 0) { - throw new Error( - `Text widget for node ${nodeId} was not rendered` - ) - } - return textboxes.nth(closestIndex) - } - - const parentWidget = await hostWidget(original, '11') + const parentWidget = await original.getPromotedTextWidget('text') await expect(parentWidget).toHaveCount(1) await parentWidget.fill('original parent edit') await expect(parentWidget).toHaveValue('original parent edit') @@ -108,12 +68,12 @@ test.describe( return String(copy.id) }) const copy = await comfyPage.nodeOps.getNodeRefById(copyId) - const copyWidget = await hostWidget(copy, copyId) + const copyWidget = await copy.getPromotedTextWidget('text') await expect(copyWidget).toHaveCount(1) await copyWidget.fill('copy-only edit') await expect(copyWidget).toHaveValue('copy-only edit') - const originalWidget = await hostWidget(original, '11') + const originalWidget = await original.getPromotedTextWidget('text') await expect(originalWidget).toHaveValue('original parent edit') await expect .poll(() => From f17bd0c150280433d3af1d1ac30c9cc943282e31 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Sat, 12 Sep 2026 01:44:12 -0700 Subject: [PATCH 09/28] test: copy subgraph hosts through node reference Addresses review feedback: https://github.com/Comfy-Org/ComfyUI_frontend/pull/17516#discussion_r3995540427 --- browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts b/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts index 8512fa9ffd2..9287f75bff1 100644 --- a/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts +++ b/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts @@ -46,8 +46,7 @@ test.describe( ) .toBe('original parent edit') - await original.click('title') - await comfyPage.clipboard.copy() + await original.copy() await comfyPage.clipboard.paste() await expect .poll(() => @@ -120,8 +119,7 @@ test.describe( 'subgraphs/subgraph-with-promoted-text-widget' ) const original = await comfyPage.nodeOps.getNodeRefById('11') - await original.click('title') - await comfyPage.clipboard.copy() + await original.copy() await comfyPage.clipboard.paste() await expect From c5896442e1a0d41889f7435e65ff10a18c4ff783 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Sat, 12 Sep 2026 01:44:39 -0700 Subject: [PATCH 10/28] test: delete selected host with focused keyboard helper Addresses review feedback: https://github.com/Comfy-Org/ComfyUI_frontend/pull/17516#discussion_r3995540423 --- browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts b/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts index 9287f75bff1..b9648917a5f 100644 --- a/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts +++ b/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts @@ -160,8 +160,7 @@ test.describe( window.app!.canvas.deselectAll() window.app!.canvas.selectNode(node) }, removedId) - await comfyPage.page.keyboard.press('Delete') - await comfyPage.nextFrame() + await comfyPage.keyboard.delete() await expect .poll(() => comfyPage.page.evaluate( From 1de5e6d17007c4a7b28d3a7f9ad49a16426b4367 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Sat, 12 Sep 2026 01:45:08 -0700 Subject: [PATCH 11/28] test: isolate root undo from nested navigation Addresses review feedback: https://github.com/Comfy-Org/ComfyUI_frontend/pull/17516#discussion_r3995540432 --- .../subgraph/subgraphEcsScenarios.spec.ts | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts b/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts index b9648917a5f..b6c1371dca8 100644 --- a/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts +++ b/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts @@ -250,7 +250,22 @@ test.describe( }) } - test('nested controls and breadcrumbs preserve exact topology and root undo', async ({ + test('root movement can be undone', async ({ comfyPage }) => { + await comfyPage.workflow.loadWorkflow('subgraphs/nested-subgraph') + + const rootNode = await comfyPage.nodeOps.getNodeRefById('8') + const originalPosition = await rootNode.getPosition() + await rootNode.dragBy({ x: 80, y: 40 }) + await expect + .poll(() => rootNode.getPosition()) + .not.toEqual(originalPosition) + await comfyPage.keyboard.undo() + await expect + .poll(() => rootNode.getPosition()) + .toEqual(originalPosition) + }) + + test('nested controls and breadcrumbs preserve exact topology', async ({ comfyPage, subgraphBreadcrumb }) => { @@ -282,17 +297,6 @@ test.describe( ] }) - const rootNode = await comfyPage.nodeOps.getNodeRefById('8') - const originalPosition = await rootNode.getPosition() - await rootNode.dragBy({ x: 80, y: 40 }) - await expect - .poll(() => rootNode.getPosition()) - .not.toEqual(originalPosition) - await comfyPage.keyboard.undo() - await expect - .poll(() => rootNode.getPosition()) - .toEqual(originalPosition) - const outer = await comfyPage.nodeOps.getNodeRefById('10') if (mode.vueNodesEnabled) { await comfyPage.vueNodes.enterSubgraph('10') From 36d64c3a01f103f67eb9b6769c229411f5bb0678 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Sat, 12 Sep 2026 01:45:50 -0700 Subject: [PATCH 12/28] test: name subgraph user phases in traces Addresses review feedback: https://github.com/Comfy-Org/ComfyUI_frontend/pull/17516#discussion_r3995540428 --- .../subgraph/subgraphEcsScenarios.spec.ts | 146 +++++++++++++----- 1 file changed, 104 insertions(+), 42 deletions(-) diff --git a/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts b/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts index b6c1371dca8..387d888653f 100644 --- a/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts +++ b/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts @@ -38,7 +38,11 @@ test.describe( const original = await comfyPage.nodeOps.getNodeRefById('11') const parentWidget = await original.getPromotedTextWidget('text') await expect(parentWidget).toHaveCount(1) - await parentWidget.fill('original parent edit') + + await test.step('user edits the original host', async () => { + await parentWidget.fill('original parent edit') + }) + await expect(parentWidget).toHaveValue('original parent edit') await expect .poll(() => @@ -46,8 +50,11 @@ test.describe( ) .toBe('original parent edit') - await original.copy() - await comfyPage.clipboard.paste() + await test.step('user copies and pastes the host', async () => { + await original.copy() + await comfyPage.clipboard.paste() + }) + await expect .poll(() => comfyPage.page.evaluate( @@ -69,7 +76,10 @@ test.describe( const copy = await comfyPage.nodeOps.getNodeRefById(copyId) const copyWidget = await copy.getPromotedTextWidget('text') await expect(copyWidget).toHaveCount(1) - await copyWidget.fill('copy-only edit') + + await test.step('user edits only the copied host', async () => { + await copyWidget.fill('copy-only edit') + }) await expect(copyWidget).toHaveValue('copy-only edit') const originalWidget = await original.getPromotedTextWidget('text') @@ -85,7 +95,10 @@ test.describe( ) .toBe('original parent edit') - await originalWidget.fill('original second edit') + await test.step('user edits the original host again', async () => { + await originalWidget.fill('original second edit') + }) + await expect(originalWidget).toHaveValue('original second edit') await expect(copyWidget).toHaveValue('copy-only edit') await expect @@ -99,7 +112,10 @@ test.describe( ) .toBe('copy-only edit') - await copy.delete() + await test.step('user deletes the copied host', async () => { + await copy.delete() + }) + await expect.poll(() => copy.exists()).toBe(false) await expect(parentWidget).toHaveValue('original second edit') await parentWidget.fill('original survives duplicate deletion') @@ -119,8 +135,11 @@ test.describe( 'subgraphs/subgraph-with-promoted-text-widget' ) const original = await comfyPage.nodeOps.getNodeRefById('11') - await original.copy() - await comfyPage.clipboard.paste() + + await test.step('user copies and pastes the host', async () => { + await original.copy() + await comfyPage.clipboard.paste() + }) await expect .poll(() => @@ -160,7 +179,11 @@ test.describe( window.app!.canvas.deselectAll() window.app!.canvas.selectNode(node) }, removedId) - await comfyPage.keyboard.delete() + + await test.step(`user deletes the ${deleteOriginal ? 'original' : 'copy'}`, async () => { + await comfyPage.keyboard.delete() + }) + await expect .poll(() => comfyPage.page.evaluate( @@ -181,7 +204,11 @@ test.describe( new URL(response.url()).pathname === workflowPath && response.request().method() === 'POST' ) - await comfyPage.menu.topbar.saveWorkflow(workflowName) + + await test.step('user saves the surviving host', async () => { + await comfyPage.menu.topbar.saveWorkflow(workflowName) + }) + const encodedSave = await saveResponse expect(encodedSave.status()).toBe(200) expect(encodedSave.request().headers()['comfy-user']).toBe( @@ -191,10 +218,12 @@ test.describe( encodedSave.request().postDataJSON() ) - const persistedResponse = await comfyPage.request.get( - `${comfyPage.apiUrl}${workflowPath}`, - { headers: { 'Comfy-User': comfyPage.id } } - ) + const persistedResponse = + await test.step('user reads the saved workflow', () => + comfyPage.request.get(`${comfyPage.apiUrl}${workflowPath}`, { + headers: { 'Comfy-User': comfyPage.id } + })) + expect(persistedResponse.ok()).toBe(true) const persistedWorkflow = zComfyWorkflow.parse( await persistedResponse.json() @@ -210,21 +239,27 @@ test.describe( expect(serializedHostIds(encodedWorkflow)).toEqual([survivorId]) expect(serializedHostIds(persistedWorkflow)).toEqual([survivorId]) - await comfyPage.workflow.reloadAndWaitForApp() - await comfyPage.menu.workflowsTab.open() - await comfyPage.menu.workflowsTab - .getPersistedItem(workflowName) - .click() - await comfyPage.menu.workflowsTab.close() + await test.step('user reloads and opens the saved workflow', async () => { + await comfyPage.workflow.reloadAndWaitForApp() + await comfyPage.menu.workflowsTab.open() + await comfyPage.menu.workflowsTab + .getPersistedItem(workflowName) + .click() + await comfyPage.menu.workflowsTab.close() + }) const survivor = await comfyPage.nodeOps.getNodeRefById(survivorId) await expect.poll(() => survivor.exists()).toBe(true) - if (mode.vueNodesEnabled) { - await comfyPage.vueNodes.enterSubgraph(survivorId) - } else { - await survivor.navigateIntoSubgraph() - } + + await test.step('user opens the surviving host', async () => { + if (mode.vueNodesEnabled) { + await comfyPage.vueNodes.enterSubgraph(survivorId) + } else { + await survivor.navigateIntoSubgraph() + } + }) + await expect .poll(() => comfyPage.page.evaluate(() => window.app!.canvas.graph?.id) @@ -243,7 +278,11 @@ test.describe( const inner = await comfyPage.nodeOps.getNodeRefById(innerId) await expect.poll(() => inner.exists()).toBe(true) const originalInnerPosition = await inner.getPosition() - await inner.dragBy({ x: 40, y: 20 }) + + await test.step('user edits the surviving inner graph', async () => { + await inner.dragBy({ x: 40, y: 20 }) + }) + await expect .poll(() => inner.getPosition()) .not.toEqual(originalInnerPosition) @@ -255,11 +294,19 @@ test.describe( const rootNode = await comfyPage.nodeOps.getNodeRefById('8') const originalPosition = await rootNode.getPosition() - await rootNode.dragBy({ x: 80, y: 40 }) + + await test.step('user moves a root node', async () => { + await rootNode.dragBy({ x: 80, y: 40 }) + }) + await expect .poll(() => rootNode.getPosition()) .not.toEqual(originalPosition) - await comfyPage.keyboard.undo() + + await test.step('user undoes the root movement', async () => { + await comfyPage.keyboard.undo() + }) + await expect .poll(() => rootNode.getPosition()) .toEqual(originalPosition) @@ -298,11 +345,15 @@ test.describe( }) const outer = await comfyPage.nodeOps.getNodeRefById('10') - if (mode.vueNodesEnabled) { - await comfyPage.vueNodes.enterSubgraph('10') - } else { - await outer.navigateIntoSubgraph() - } + + await test.step('user opens the outer subgraph', async () => { + if (mode.vueNodesEnabled) { + await comfyPage.vueNodes.enterSubgraph('10') + } else { + await outer.navigateIntoSubgraph() + } + }) + expect(await topology()).toEqual({ nodes: ['11', '3', '6'], links: [ @@ -317,11 +368,15 @@ test.describe( }) const inner = await comfyPage.nodeOps.getNodeRefById('11') - if (mode.vueNodesEnabled) { - await comfyPage.vueNodes.enterSubgraph('11') - } else { - await inner.navigateIntoSubgraph() - } + + await test.step('user opens the inner subgraph', async () => { + if (mode.vueNodesEnabled) { + await comfyPage.vueNodes.enterSubgraph('11') + } else { + await inner.navigateIntoSubgraph() + } + }) + expect(await topology()).toEqual({ nodes: ['4', '5', '7'], links: [ @@ -334,9 +389,12 @@ test.describe( ] }) - await subgraphBreadcrumb.clickItem( - 'subgraph-8beb610f-ddd1-4489-ae0d-2f732a4042ae' - ) + await test.step('user navigates back to the outer subgraph', async () => { + await subgraphBreadcrumb.clickItem( + 'subgraph-8beb610f-ddd1-4489-ae0d-2f732a4042ae' + ) + }) + expect(await topology()).toEqual({ nodes: ['11', '3', '6'], links: [ @@ -349,7 +407,11 @@ test.describe( ['6', 0, '3', 1] ] }) - await subgraphBreadcrumb.clickItem('root') + + await test.step('user navigates back to the root graph', async () => { + await subgraphBreadcrumb.clickItem('root') + }) + expect(await topology()).toEqual({ nodes: ['10', '8', '9'], links: [ From 9ea823ceb0065382f6262f6710fbf711df750de6 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Sat, 12 Sep 2026 07:22:47 -0700 Subject: [PATCH 13/28] test: cover blank promoted widget save --- .../subgraph/subgraphEcsScenarios.spec.ts | 77 +++++++++++++++++++ fleet/passes/ecs-wake-1411-blank-name.md | 7 ++ 2 files changed, 84 insertions(+) create mode 100644 fleet/passes/ecs-wake-1411-blank-name.md diff --git a/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts b/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts index 387d888653f..7d2c93dc137 100644 --- a/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts +++ b/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts @@ -126,6 +126,83 @@ test.describe( .toBe('original survives duplicate deletion') }) + test('blank promoted text saves and reloads with its host intact', async ({ + comfyPage + }) => { + await comfyPage.workflow.setupWorkflowsDirectory({}) + await comfyPage.workflow.loadWorkflow('default') + + const clipNode = await comfyPage.nodeOps.getNodeRefById('6') + await clipNode.click('title') + const host = await clipNode.convertToSubgraph() + const hostId = host.id + const hostIdentity = await comfyPage.page.evaluate((hostId) => { + const node = window.app!.rootGraph.getNodeById(hostId) + if (!node?.isSubgraphNode()) + throw new Error('Subgraph host not found') + return { type: node.type, subgraphId: node.subgraph.id } + }, hostId) + + await expect + .poll(() => + comfyPage.subgraph.getPromotedWidgetOrder(String(hostId)) + ) + .toContain('text') + const promotedName = await host.getPromotedTextWidget('text') + await expect(promotedName).toHaveCount(1) + + await test.step('user clears the promoted text value', async () => { + await promotedName.clear() + }) + + await expect(promotedName).toHaveValue('') + const workflowName = `${mode.label.toLowerCase()}-blank-promoted-name` + const workflowPath = `/api/userdata/${encodeURIComponent(`workflows/${workflowName}.json`)}` + const saveResponse = comfyPage.page.waitForResponse( + (response) => + new URL(response.url()).pathname === workflowPath && + response.request().method() === 'POST' + ) + + await test.step('user saves without an error', async () => { + await comfyPage.menu.topbar.saveWorkflow(workflowName) + }) + + expect((await saveResponse).status()).toBe(200) + await expect(comfyPage.toast.toastErrors).toHaveCount(0) + + await test.step('user reloads and opens the saved workflow', async () => { + await comfyPage.workflow.reloadAndWaitForApp() + await comfyPage.menu.workflowsTab.open() + await comfyPage.menu.workflowsTab + .getPersistedItem(workflowName) + .click() + await comfyPage.menu.workflowsTab.close() + }) + + const reloadedHost = await comfyPage.nodeOps.getNodeRefById(hostId) + await expect.poll(() => reloadedHost.exists()).toBe(true) + await expect + .poll(() => + comfyPage.page.evaluate((hostId) => { + const node = window.app!.rootGraph.getNodeById(hostId) + if (!node?.isSubgraphNode()) return null + return { type: node.type, subgraphId: node.subgraph.id } + }, hostId) + ) + .toEqual(hostIdentity) + const reloadedName = + await reloadedHost.getPromotedTextWidget('text') + await expect(reloadedName).toHaveValue('') + await expect + .poll(() => + reloadedHost + .getWidgetByName('text') + .then((widget) => widget.getValue()) + ) + .toBe('') + }) + for (const deleteOriginal of [true, false]) { test(`surviving ${deleteOriginal ? 'copy' : 'original'} opens and edits after save/reload`, async ({ comfyPage diff --git a/fleet/passes/ecs-wake-1411-blank-name.md b/fleet/passes/ecs-wake-1411-blank-name.md new file mode 100644 index 00000000000..dbed579100a --- /dev/null +++ b/fleet/passes/ecs-wake-1411-blank-name.md @@ -0,0 +1,7 @@ +# ECS-QA-031 receipt + +- Added both-renderer coverage for a promoted text widget cleared through the host UI. +- Verified save POST status 200, no error toast, persisted blank value after reload, and unchanged host type/subgraph identity. +- Focused run: 2 passed with one Playwright worker and the shared browser lock. +- Mutation control changed the persisted blank assertion to `mutation-control`: 2 failed with received value `""`; reverted before commit. +- State: pending CI on PR #17516. From ba24b5586dccb73efefb2dff5c94ef82e75d1b3a Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Sat, 12 Sep 2026 07:23:50 -0700 Subject: [PATCH 14/28] Revert "test: cover blank promoted widget save" This reverts commit 9ea823ceb0065382f6262f6710fbf711df750de6. --- .../subgraph/subgraphEcsScenarios.spec.ts | 77 ------------------- fleet/passes/ecs-wake-1411-blank-name.md | 7 -- 2 files changed, 84 deletions(-) delete mode 100644 fleet/passes/ecs-wake-1411-blank-name.md diff --git a/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts b/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts index 7d2c93dc137..387d888653f 100644 --- a/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts +++ b/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts @@ -126,83 +126,6 @@ test.describe( .toBe('original survives duplicate deletion') }) - test('blank promoted text saves and reloads with its host intact', async ({ - comfyPage - }) => { - await comfyPage.workflow.setupWorkflowsDirectory({}) - await comfyPage.workflow.loadWorkflow('default') - - const clipNode = await comfyPage.nodeOps.getNodeRefById('6') - await clipNode.click('title') - const host = await clipNode.convertToSubgraph() - const hostId = host.id - const hostIdentity = await comfyPage.page.evaluate((hostId) => { - const node = window.app!.rootGraph.getNodeById(hostId) - if (!node?.isSubgraphNode()) - throw new Error('Subgraph host not found') - return { type: node.type, subgraphId: node.subgraph.id } - }, hostId) - - await expect - .poll(() => - comfyPage.subgraph.getPromotedWidgetOrder(String(hostId)) - ) - .toContain('text') - const promotedName = await host.getPromotedTextWidget('text') - await expect(promotedName).toHaveCount(1) - - await test.step('user clears the promoted text value', async () => { - await promotedName.clear() - }) - - await expect(promotedName).toHaveValue('') - const workflowName = `${mode.label.toLowerCase()}-blank-promoted-name` - const workflowPath = `/api/userdata/${encodeURIComponent(`workflows/${workflowName}.json`)}` - const saveResponse = comfyPage.page.waitForResponse( - (response) => - new URL(response.url()).pathname === workflowPath && - response.request().method() === 'POST' - ) - - await test.step('user saves without an error', async () => { - await comfyPage.menu.topbar.saveWorkflow(workflowName) - }) - - expect((await saveResponse).status()).toBe(200) - await expect(comfyPage.toast.toastErrors).toHaveCount(0) - - await test.step('user reloads and opens the saved workflow', async () => { - await comfyPage.workflow.reloadAndWaitForApp() - await comfyPage.menu.workflowsTab.open() - await comfyPage.menu.workflowsTab - .getPersistedItem(workflowName) - .click() - await comfyPage.menu.workflowsTab.close() - }) - - const reloadedHost = await comfyPage.nodeOps.getNodeRefById(hostId) - await expect.poll(() => reloadedHost.exists()).toBe(true) - await expect - .poll(() => - comfyPage.page.evaluate((hostId) => { - const node = window.app!.rootGraph.getNodeById(hostId) - if (!node?.isSubgraphNode()) return null - return { type: node.type, subgraphId: node.subgraph.id } - }, hostId) - ) - .toEqual(hostIdentity) - const reloadedName = - await reloadedHost.getPromotedTextWidget('text') - await expect(reloadedName).toHaveValue('') - await expect - .poll(() => - reloadedHost - .getWidgetByName('text') - .then((widget) => widget.getValue()) - ) - .toBe('') - }) - for (const deleteOriginal of [true, false]) { test(`surviving ${deleteOriginal ? 'copy' : 'original'} opens and edits after save/reload`, async ({ comfyPage diff --git a/fleet/passes/ecs-wake-1411-blank-name.md b/fleet/passes/ecs-wake-1411-blank-name.md deleted file mode 100644 index dbed579100a..00000000000 --- a/fleet/passes/ecs-wake-1411-blank-name.md +++ /dev/null @@ -1,7 +0,0 @@ -# ECS-QA-031 receipt - -- Added both-renderer coverage for a promoted text widget cleared through the host UI. -- Verified save POST status 200, no error toast, persisted blank value after reload, and unchanged host type/subgraph identity. -- Focused run: 2 passed with one Playwright worker and the shared browser lock. -- Mutation control changed the persisted blank assertion to `mutation-control`: 2 failed with received value `""`; reverted before commit. -- State: pending CI on PR #17516. From 8a3b7f3a15b1a3e90590d577943797a494a854cf Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Sat, 12 Sep 2026 07:32:47 -0700 Subject: [PATCH 15/28] test: preserve cleared promoted widget labels across reload --- .../subgraph/subgraphEcsScenarios.spec.ts | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts b/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts index 387d888653f..b6b9fc9ede9 100644 --- a/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts +++ b/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts @@ -126,6 +126,91 @@ test.describe( .toBe('original survives duplicate deletion') }) + test('clearing a promoted widget label preserves its value and host after reload', async ({ + comfyPage + }) => { + test.slow() + await comfyPage.workflow.setupWorkflowsDirectory({}) + await comfyPage.workflow.loadWorkflow( + 'subgraphs/subgraph-with-promoted-text-widget' + ) + const host = await comfyPage.nodeOps.getNodeRefById('11') + const text = await host.getPromotedTextWidget('text') + await text.fill('Value must not be cleared with the label') + const identity = await comfyPage.page.evaluate((hostId) => { + const node = window.app!.rootGraph.getNodeById(hostId) + if (!node?.isSubgraphNode()) throw new Error('Missing host') + return { type: node.type, subgraphId: node.subgraph.id } + }, toNodeId('11')) + + await host.click('title') + const panel = comfyPage.menu.propertiesPanel.root + if (!(await panel.isVisible())) { + await comfyPage.menu.propertiesPanel.toggleButton.click() + } + await expect(panel).toBeVisible() + await panel.getByText('text', { exact: true }).click() + const labelInput = panel.getByPlaceholder('text', { exact: true }) + await labelInput.fill('Temporary promoted label') + await labelInput.press('Enter') + await expect( + panel.getByText('Temporary promoted label', { exact: true }) + ).toBeVisible() + await panel + .getByText('Temporary promoted label', { exact: true }) + .click() + await labelInput.clear() + await labelInput.press('Enter') + await expect(panel.getByText('text', { exact: true })).toBeVisible() + await expect( + panel.getByText('Temporary promoted label', { exact: true }) + ).toHaveCount(0) + + const workflowName = `${mode.label.toLowerCase()}-cleared-promoted-label` + const workflowPath = `/api/userdata/${encodeURIComponent(`workflows/${workflowName}.json`)}` + const save = comfyPage.page.waitForResponse( + (response) => + new URL(response.url()).pathname === workflowPath && + response.request().method() === 'POST' + ) + await comfyPage.menu.topbar.saveWorkflow(workflowName) + expect((await save).status()).toBe(200) + await expect(comfyPage.toast.toastErrors).toHaveCount(0) + await comfyPage.workflow.reloadAndWaitForApp() + await comfyPage.menu.workflowsTab.open() + await comfyPage.menu.workflowsTab + .getPersistedItem(workflowName) + .click() + await comfyPage.menu.workflowsTab.close() + + await expect + .poll(() => + comfyPage.page.evaluate((hostId) => { + const node = window.app!.rootGraph.getNodeById(hostId) + if (!node?.isSubgraphNode()) return null + const widget = node.widgets.find( + (entry) => entry.name === 'text' + ) + return { + type: node.type, + subgraphId: node.subgraph.id, + label: widget?.label ?? null, + value: widget?.value + } + }, toNodeId('11')) + ) + .toEqual({ + ...identity, + label: null, + value: 'Value must not be cleared with the label' + }) + const restored = await comfyPage.nodeOps.getNodeRefById('11') + await expect( + await restored.getPromotedTextWidget('text') + ).toHaveValue('Value must not be cleared with the label') + await expect(comfyPage.toast.toastErrors).toHaveCount(0) + }) + for (const deleteOriginal of [true, false]) { test(`surviving ${deleteOriginal ? 'copy' : 'original'} opens and edits after save/reload`, async ({ comfyPage From a32b72ca5d4e10e345c256691bfcee87eb842aae Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Sat, 12 Sep 2026 09:30:16 -0700 Subject: [PATCH 16/28] test: promote widget through UI before clearing its label --- .../subgraph/subgraphEcsScenarios.spec.ts | 35 +++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts b/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts index b6b9fc9ede9..ea0c71693c4 100644 --- a/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts +++ b/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts @@ -2,6 +2,7 @@ import { expect, mergeTests } from '@playwright/test' import { comfyPageFixture } from '@e2e/fixtures/ComfyPage' import { subgraphBreadcrumbFixture } from '@e2e/fixtures/helpers/SubgraphBreadcrumbHelper' +import { fitToViewInstant } from '@e2e/fixtures/utils/fitToView' import { zComfyWorkflow } from '@/platform/workflow/validation/schemas/workflowSchema' import { toNodeId } from '@/types/nodeId' @@ -132,10 +133,33 @@ test.describe( test.slow() await comfyPage.workflow.setupWorkflowsDirectory({}) await comfyPage.workflow.loadWorkflow( - 'subgraphs/subgraph-with-promoted-text-widget' + 'subgraphs/subgraph-with-text-widget' ) const host = await comfyPage.nodeOps.getNodeRefById('11') + await expect.poll(() => host.getProperty('widgets')).toHaveLength(0) + + await test.step('user promotes the inner text widget', async () => { + await fitToViewInstant(comfyPage, { zoom: 1 }) + if (mode.vueNodesEnabled) { + await comfyPage.subgraph.editor.ensureOpen( + comfyPage.vueNodes.getNodeLocator('11') + ) + } else { + await host.click('title') + await host.clickContextMenuOption('Edit Subgraph Widgets') + await expect(comfyPage.subgraph.editor.root).toBeVisible() + } + const item = comfyPage.subgraph.editor.resolveItem({ + nodeName: 'CLIP Text Encode (Prompt)', + widgetName: 'text' + }) + await comfyPage.subgraph.editor.togglePromotionOnItem(item, true) + await comfyPage.menu.propertiesPanel.toggleButton.click() + await fitToViewInstant(comfyPage, { zoom: 1 }) + }) + const text = await host.getPromotedTextWidget('text') + await expect(text).toHaveCount(1) await text.fill('Value must not be cleared with the label') const identity = await comfyPage.page.evaluate((hostId) => { const node = window.app!.rootGraph.getNodeById(hostId) @@ -143,12 +167,19 @@ test.describe( return { type: node.type, subgraphId: node.subgraph.id } }, toNodeId('11')) - await host.click('title') + if (mode.vueNodesEnabled) { + await comfyPage.vueNodes.selectNode('11') + } else { + await host.click('title') + } const panel = comfyPage.menu.propertiesPanel.root if (!(await panel.isVisible())) { await comfyPage.menu.propertiesPanel.toggleButton.click() } await expect(panel).toBeVisible() + await panel + .getByRole('tab', { name: 'Parameters', exact: true }) + .click() await panel.getByText('text', { exact: true }).click() const labelInput = panel.getByPlaceholder('text', { exact: true }) await labelInput.fill('Temporary promoted label') From e431e3041525cdfef8ab27335231ba048ed80c31 Mon Sep 17 00:00:00 2001 From: Amp Date: Mon, 14 Sep 2026 20:11:01 +0000 Subject: [PATCH 17/28] test: structure subgraph scenarios as user stories Amp-Thread-ID: https://ampcode.com/threads/T-01a0943a-a2e0-7689-988b-58f82077a59e --- browser_tests/fixtures/ComfyPage.ts | 37 ++ .../fixtures/components/SubgraphEditor.ts | 26 + .../fixtures/data/subgraphTopologies.ts | 38 ++ .../fixtures/helpers/SubgraphHelper.ts | 107 ++++ .../fixtures/helpers/WorkflowHelper.ts | 33 ++ .../fixtures/utils/litegraphUtils.ts | 61 +- ...subgraphDuplicateIndependentValues.spec.ts | 48 ++ .../subgraph/subgraphEcsScenarios.spec.ts | 544 ------------------ .../tests/subgraph/subgraphLifecycle.spec.ts | 64 +++ .../tests/subgraph/subgraphNavigation.spec.ts | 62 +- .../tests/subgraph/subgraphOperations.spec.ts | 27 + .../subgraphPromotedLabelPersistence.spec.ts | 75 +++ 12 files changed, 572 insertions(+), 550 deletions(-) create mode 100644 browser_tests/fixtures/data/subgraphTopologies.ts delete mode 100644 browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts create mode 100644 browser_tests/tests/subgraph/subgraphPromotedLabelPersistence.spec.ts diff --git a/browser_tests/fixtures/ComfyPage.ts b/browser_tests/fixtures/ComfyPage.ts index 8bb53537851..a7423360b91 100644 --- a/browser_tests/fixtures/ComfyPage.ts +++ b/browser_tests/fixtures/ComfyPage.ts @@ -92,6 +92,43 @@ class ComfyPropertiesPanel { name: 'Toggle properties panel' }) } + + async open(): Promise { + if (!(await this.root.isVisible())) await this.toggleButton.click() + await comfyExpect(this.root).toBeVisible() + } + + async renameParameterLabel( + currentLabel: string, + nextLabel: string + ): Promise { + await this.root + .getByRole('tab', { name: 'Parameters', exact: true }) + .click() + await this.root.getByText(currentLabel, { exact: true }).click() + const labelInput = this.root.getByPlaceholder(currentLabel, { exact: true }) + await labelInput.fill(nextLabel) + await labelInput.press('Enter') + await comfyExpect( + this.root.getByText(nextLabel, { exact: true }) + ).toBeVisible() + } + + async clearParameterLabel( + currentLabel: string, + defaultLabel: string + ): Promise { + await this.root.getByText(currentLabel, { exact: true }).click() + const labelInput = this.root.getByPlaceholder(defaultLabel, { exact: true }) + await labelInput.clear() + await labelInput.press('Enter') + await comfyExpect( + this.root.getByText(defaultLabel, { exact: true }) + ).toBeVisible() + await comfyExpect( + this.root.getByText(currentLabel, { exact: true }) + ).toHaveCount(0) + } } class ComfyMenu { diff --git a/browser_tests/fixtures/components/SubgraphEditor.ts b/browser_tests/fixtures/components/SubgraphEditor.ts index 277c80ef9dc..88211e64599 100644 --- a/browser_tests/fixtures/components/SubgraphEditor.ts +++ b/browser_tests/fixtures/components/SubgraphEditor.ts @@ -4,6 +4,8 @@ import { comfyExpect as expect } from '@e2e/fixtures/ComfyPage' import type { ComfyPage } from '@e2e/fixtures/ComfyPage' import { TestIds } from '@e2e/fixtures/selectors' import { dragByIndex } from '@e2e/fixtures/utils/dragAndDrop' +import { fitToViewInstant } from '@e2e/fixtures/utils/fitToView' +import type { NodeReference } from '@e2e/fixtures/utils/litegraphUtils' import { VueNodeFixture } from '@e2e/fixtures/utils/vueNodeFixtures' export class SubgraphEditor { @@ -86,6 +88,30 @@ export class SubgraphEditor { const item = this.resolveItem(options) await this.togglePromotionOnItem(item, options.toState) } + + async promoteWidget( + host: NodeReference, + options: { + nodeName?: string + nodeId?: string + widgetName: string + } + ): Promise { + await fitToViewInstant(this.comfyPage, { zoom: 1 }) + if (this.comfyPage.isVueNodes) { + await this.ensureOpen( + this.comfyPage.vueNodes.getNodeLocator(String(host.id)) + ) + } else { + await host.clickContextMenuOption('Edit Subgraph Widgets') + await expect(this.root).toBeVisible() + } + await this.togglePromotionOnItem(this.resolveItem(options), true) + await this.comfyPage.menu.propertiesPanel.toggleButton.click() + await expect(this.root).toBeHidden() + await fitToViewInstant(this.comfyPage, { zoom: 1 }) + } + async dragItem(fromIndex: number, toIndex: number) { await dragByIndex(this.promotionItems, fromIndex, toIndex) await this.comfyPage.nextFrame() diff --git a/browser_tests/fixtures/data/subgraphTopologies.ts b/browser_tests/fixtures/data/subgraphTopologies.ts new file mode 100644 index 00000000000..c0632e576d5 --- /dev/null +++ b/browser_tests/fixtures/data/subgraphTopologies.ts @@ -0,0 +1,38 @@ +import type { GraphTopology } from '@e2e/fixtures/helpers/SubgraphHelper' + +export const nestedSubgraphTopologies = { + root: { + nodes: ['10', '8', '9'], + links: [ + ['10', 0, '8', 0], + ['10', 1, '8', 1], + ['8', 0, '9', 0] + ] + }, + outer: { + nodes: ['11', '3', '6'], + links: [ + ['11', 0, '3', 2], + ['11', 1, '3', 3], + ['11', 2, '3', 0], + ['11', 3, '6', 0], + ['11', 4, '-20', 1], + ['3', 0, '-20', 0], + ['6', 0, '3', 1] + ] + }, + inner: { + nodes: ['4', '5', '7'], + links: [ + ['4', 0, '-20', 2], + ['4', 1, '-20', 3], + ['4', 1, '7', 0], + ['4', 2, '-20', 4], + ['5', 0, '-20', 1], + ['7', 0, '-20', 0] + ] + } +} satisfies Record<'root' | 'outer' | 'inner', GraphTopology> + +export const outerSubgraphBreadcrumbId = + 'subgraph-8beb610f-ddd1-4489-ae0d-2f732a4042ae' diff --git a/browser_tests/fixtures/helpers/SubgraphHelper.ts b/browser_tests/fixtures/helpers/SubgraphHelper.ts index affc1947555..ab827534f1d 100644 --- a/browser_tests/fixtures/helpers/SubgraphHelper.ts +++ b/browser_tests/fixtures/helpers/SubgraphHelper.ts @@ -18,6 +18,16 @@ import { SubgraphSlotReference } from '@e2e/fixtures/utils/litegraphUtils' import { getAllHostPromotedWidgets } from '@e2e/fixtures/utils/promotedWidgets' import type { PromotedWidgetEntry } from '@e2e/fixtures/utils/promotedWidgets' +export interface GraphTopology { + nodes: string[] + links: [string, number, string, number][] +} + +export interface SubgraphHostIdentity { + type: string + subgraphId: string +} + export class SubgraphHelper { public readonly editor: SubgraphEditor @@ -454,6 +464,24 @@ export class SubgraphHelper { } } + async enterSubgraph(node: NodeReference): Promise { + const subgraphId = await this.page.evaluate((id) => { + const host = window.app!.canvas.graph?.getNodeById(id) + if (!host?.isSubgraphNode()) { + throw new Error(`Expected visible subgraph node ${id}`) + } + return host.subgraph.id + }, node.id) + + if (this.comfyPage.isVueNodes) { + await this.comfyPage.vueNodes.enterSubgraph(String(node.id)) + await this.comfyPage.vueNodes.waitForNodes() + } else { + await node.navigateIntoSubgraph() + } + await expect.poll(() => this.getActiveGraphId()).toBe(subgraphId) + } + async isInSubgraph(): Promise { return this.page.evaluate(() => { const graph = window.app!.canvas.graph @@ -521,6 +549,85 @@ export class SubgraphHelper { return getAllHostPromotedWidgets(this.comfyPage) } + async getHostIdentity(node: NodeReference): Promise { + return this.page.evaluate((id) => { + const host = window.app!.rootGraph.getNodeById(id) + if (!host?.isSubgraphNode()) { + throw new Error(`Subgraph host ${id} not found`) + } + return { type: host.type, subgraphId: host.subgraph.id } + }, node.id) + } + + async expectPromotedWidget( + node: NodeReference, + name: string, + expected: SubgraphHostIdentity & { label: string | null; value: unknown } + ): Promise { + await expect + .poll(() => + this.page.evaluate( + ([id, widgetName]) => { + const host = window.app!.rootGraph.getNodeById(id) + if (!host?.isSubgraphNode()) return null + const widget = host.widgets.find( + (candidate) => candidate.name === widgetName + ) + return { + type: host.type, + subgraphId: host.subgraph.id, + label: widget?.label ?? null, + value: widget?.value + } + }, + [node.id, name] as const + ) + ) + .toEqual(expected) + } + + async expectPersistedHostIds( + workflowName: string, + expectedIds: string[] + ): Promise { + const workflow = + await this.comfyPage.workflow.getPersistedWorkflow(workflowName) + this.expectHostIds(workflow, expectedIds) + } + + expectHostIds(workflow: ComfyWorkflowJSON, expectedIds: string[]): void { + const hostIds = workflow.nodes + .filter((node) => + workflow.definitions?.subgraphs.some( + (subgraph) => subgraph.id === node.type + ) + ) + .map((node) => String(node.id)) + expect(hostIds).toEqual(expectedIds) + } + + async getActiveTopology(): Promise { + return this.page.evaluate(() => { + const graph = window.app!.canvas.graph + if (!graph) throw new Error('Canvas graph was not loaded') + return { + nodes: graph.nodes.map((node) => String(node.id)).sort(), + links: [...graph.links.values()] + .map<[string, number, string, number]>((link) => [ + String(link.origin_id), + link.origin_slot, + String(link.target_id), + link.target_slot + ]) + .sort() + } + }) + } + + async expectActiveTopology(expected: GraphTopology): Promise { + await expect.poll(() => this.getActiveTopology()).toEqual(expected) + } + /** Reads from `window.app.canvas.graph` (viewed root or nested subgraph). */ async getNodeCount(): Promise { return this.page.evaluate(() => { diff --git a/browser_tests/fixtures/helpers/WorkflowHelper.ts b/browser_tests/fixtures/helpers/WorkflowHelper.ts index 9e2f70c5e17..3683da3de23 100644 --- a/browser_tests/fixtures/helpers/WorkflowHelper.ts +++ b/browser_tests/fixtures/helpers/WorkflowHelper.ts @@ -8,6 +8,7 @@ import type { ComfyApiWorkflow, ComfyWorkflowJSON } from '@/platform/workflow/validation/schemas/workflowSchema' +import { zComfyWorkflow } from '@/platform/workflow/validation/schemas/workflowSchema' import type { WorkspaceStore } from '@e2e/types/globals' import type { ComfyPage } from '@e2e/fixtures/ComfyPage' import { assetPath } from '@e2e/fixtures/utils/paths' @@ -132,6 +133,38 @@ export class WorkflowHelper { } } + async getPersistedWorkflow(workflowName: string): Promise { + const workflowPath = `/api/userdata/${encodeURIComponent(`workflows/${workflowName}.json`)}` + const response = await this.comfyPage.request.get( + `${this.comfyPage.apiUrl}${workflowPath}`, + { headers: { 'Comfy-User': this.comfyPage.id } } + ) + expect(response.ok()).toBe(true) + return zComfyWorkflow.parse(await response.json()) + } + + async saveWorkflow(workflowName: string): Promise { + const workflowPath = `/api/userdata/${encodeURIComponent(`workflows/${workflowName}.json`)}` + const saveResponse = this.comfyPage.page.waitForResponse( + (response) => + new URL(response.url()).pathname === workflowPath && + response.request().method() === 'POST' + ) + await this.comfyPage.menu.topbar.saveWorkflow(workflowName) + const response = await saveResponse + expect(response.status()).toBe(200) + expect(response.request().headers()['comfy-user']).toBe(this.comfyPage.id) + return zComfyWorkflow.parse(response.request().postDataJSON()) + } + + async openPersistedWorkflow(workflowName: string): Promise { + await this.reloadAndWaitForApp() + const { workflowsTab } = this.comfyPage.menu + await workflowsTab.open() + await workflowsTab.getPersistedItem(workflowName).click() + await workflowsTab.close() + } + async deleteWorkflow( workflowName: string, whenMissing: 'ignoreMissing' | 'throwIfMissing' = 'ignoreMissing' diff --git a/browser_tests/fixtures/utils/litegraphUtils.ts b/browser_tests/fixtures/utils/litegraphUtils.ts index aa45cf4a1b4..07135477734 100644 --- a/browser_tests/fixtures/utils/litegraphUtils.ts +++ b/browser_tests/fixtures/utils/litegraphUtils.ts @@ -276,6 +276,9 @@ export class NodeReference { return !!node }, this.id) } + async expectExists(expected = true): Promise { + await expect.poll(() => this.exists()).toBe(expected) + } getType(): Promise { return this.getProperty('type') } @@ -440,6 +443,42 @@ export class NodeReference { } return textboxes.nth(closestIndex) } + async fillPromotedTextWidget(name: string, value: string): Promise { + const widget = await this.getPromotedTextWidget(name) + await widget.fill(value) + await expect(widget).toHaveValue(value) + await expect + .poll(async () => (await this.getWidgetByName(name)).getValue()) + .toBe(value) + } + async expectPromotedTextWidgetValue( + name: string, + value: string + ): Promise { + const widget = await this.getPromotedTextWidget(name) + await expect(widget).toHaveValue(value) + await expect + .poll(async () => (await this.getWidgetByName(name)).getValue()) + .toBe(value) + } + async expectPromotedWidgetCount(expected: number): Promise { + await expect + .poll(async () => (await this.getProperty('widgets')).length) + .toBe(expected) + } + async select(): Promise { + if (this.comfyPage.isVueNodes) { + await this.comfyPage.vueNodes.selectNode(String(this.id)) + } else { + await this.comfyPage.page.evaluate((id) => { + const node = window.app!.canvas.graph?.getNodeById(id) + if (!node) throw new Error(`Node ${id} not found`) + window.app!.canvas.deselectAll() + window.app!.canvas.selectNode(node) + }, this.id) + await this.comfyPage.nextFrame() + } + } async click( position: 'title' | 'collapse', options?: { @@ -476,10 +515,26 @@ export class NodeReference { await this.click('title') await this.comfyPage.clipboard.copy() } + async duplicate(): Promise { + const getNodeIds = () => + this.comfyPage.page.evaluate(() => + window.app!.canvas.graph!.nodes.map((node) => String(node.id)) + ) + const existingIds = new Set(await getNodeIds()) + + await this.copy() + await this.comfyPage.clipboard.paste() + + const getAddedIds = async () => + (await getNodeIds()).filter((id) => !existingIds.has(id)) + await expect.poll(getAddedIds).toHaveLength(1) + const [addedId] = await getAddedIds() + if (!addedId) throw new Error(`Copy of node ${this.id} was not created`) + return this.comfyPage.nodeOps.getNodeRefById(addedId) + } async delete(): Promise { - await this.click('title') - await this.comfyPage.page.keyboard.press('Delete') - await this.comfyPage.nextFrame() + await this.select() + await this.comfyPage.keyboard.delete() } async connectWidget( originSlotIndex: number, diff --git a/browser_tests/tests/subgraph/subgraphDuplicateIndependentValues.spec.ts b/browser_tests/tests/subgraph/subgraphDuplicateIndependentValues.spec.ts index 17429a82f21..d7397d0434d 100644 --- a/browser_tests/tests/subgraph/subgraphDuplicateIndependentValues.spec.ts +++ b/browser_tests/tests/subgraph/subgraphDuplicateIndependentValues.spec.ts @@ -56,3 +56,51 @@ test.describe( }) } ) + +for (const renderer of [ + { name: 'LiteGraph', tag: ['@slow', '@subgraph', '@ui'] }, + { name: 'Vue', tag: ['@slow', '@subgraph', '@ui', '@vue-nodes'] } +]) { + test.describe(`${renderer.name} renderer`, { tag: renderer.tag }, () => { + test('editing a copied host does not change the original', async ({ + comfyPage + }) => { + await comfyPage.workflow.loadWorkflow( + 'subgraphs/subgraph-with-promoted-text-widget' + ) + const original = await comfyPage.nodeOps.getNodeRefById('11') + + await test.step('Edit the original host', async () => { + await original.fillPromotedTextWidget('text', 'original parent edit') + }) + + const copy = await test.step('Copy the host', () => original.duplicate()) + + await test.step('Edit only the copy', async () => { + await copy.fillPromotedTextWidget('text', 'copy-only edit') + await original.expectPromotedTextWidgetValue( + 'text', + 'original parent edit' + ) + }) + + await test.step('Edit the original without changing the copy', async () => { + await original.fillPromotedTextWidget('text', 'original second edit') + await copy.expectPromotedTextWidgetValue('text', 'copy-only edit') + }) + + await test.step('Delete the copy and continue editing the original', async () => { + await copy.delete() + await copy.expectExists(false) + await original.expectPromotedTextWidgetValue( + 'text', + 'original second edit' + ) + await original.fillPromotedTextWidget( + 'text', + 'original survives duplicate deletion' + ) + }) + }) + }) +} diff --git a/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts b/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts deleted file mode 100644 index ea0c71693c4..00000000000 --- a/browser_tests/tests/subgraph/subgraphEcsScenarios.spec.ts +++ /dev/null @@ -1,544 +0,0 @@ -import { expect, mergeTests } from '@playwright/test' - -import { comfyPageFixture } from '@e2e/fixtures/ComfyPage' -import { subgraphBreadcrumbFixture } from '@e2e/fixtures/helpers/SubgraphBreadcrumbHelper' -import { fitToViewInstant } from '@e2e/fixtures/utils/fitToView' - -import { zComfyWorkflow } from '@/platform/workflow/validation/schemas/workflowSchema' -import { toNodeId } from '@/types/nodeId' - -const test = mergeTests(comfyPageFixture, subgraphBreadcrumbFixture) - -const modes = [ - { label: 'LiteGraph', vueNodesEnabled: false }, - { label: 'Vue', vueNodesEnabled: true } -] as const - -test.describe( - 'Subgraph ECS user scenarios', - { tag: ['@subgraph', '@ui'] }, - () => { - for (const mode of modes) { - test.describe( - `${mode.label} renderer`, - { tag: mode.vueNodesEnabled ? '@vue-nodes' : undefined }, - () => { - test.use({ - initialSettings: { - 'Comfy.VueNodes.Enabled': mode.vueNodesEnabled - } - }) - - test('promoted widget values remain independent across copied hosts', async ({ - comfyPage - }) => { - await comfyPage.workflow.loadWorkflow( - 'subgraphs/subgraph-with-promoted-text-widget' - ) - - const original = await comfyPage.nodeOps.getNodeRefById('11') - const parentWidget = await original.getPromotedTextWidget('text') - await expect(parentWidget).toHaveCount(1) - - await test.step('user edits the original host', async () => { - await parentWidget.fill('original parent edit') - }) - - await expect(parentWidget).toHaveValue('original parent edit') - await expect - .poll(() => - original.getWidgetByName('text').then((w) => w.getValue()) - ) - .toBe('original parent edit') - - await test.step('user copies and pastes the host', async () => { - await original.copy() - await comfyPage.clipboard.paste() - }) - - await expect - .poll(() => - comfyPage.page.evaluate( - () => - window.app!.graph.nodes.filter((node) => - node.isSubgraphNode() - ).length - ) - ) - .toBe(2) - - const copyId = await comfyPage.page.evaluate(() => { - const copy = window.app!.graph.nodes.find( - (node) => node.isSubgraphNode() && String(node.id) !== '11' - ) - if (!copy) throw new Error('Pasted subgraph host was not created') - return String(copy.id) - }) - const copy = await comfyPage.nodeOps.getNodeRefById(copyId) - const copyWidget = await copy.getPromotedTextWidget('text') - await expect(copyWidget).toHaveCount(1) - - await test.step('user edits only the copied host', async () => { - await copyWidget.fill('copy-only edit') - }) - - await expect(copyWidget).toHaveValue('copy-only edit') - const originalWidget = await original.getPromotedTextWidget('text') - await expect(originalWidget).toHaveValue('original parent edit') - await expect - .poll(() => - copy.getWidgetByName('text').then((w) => w.getValue()) - ) - .toBe('copy-only edit') - await expect - .poll(() => - original.getWidgetByName('text').then((w) => w.getValue()) - ) - .toBe('original parent edit') - - await test.step('user edits the original host again', async () => { - await originalWidget.fill('original second edit') - }) - - await expect(originalWidget).toHaveValue('original second edit') - await expect(copyWidget).toHaveValue('copy-only edit') - await expect - .poll(() => - original.getWidgetByName('text').then((w) => w.getValue()) - ) - .toBe('original second edit') - await expect - .poll(() => - copy.getWidgetByName('text').then((w) => w.getValue()) - ) - .toBe('copy-only edit') - - await test.step('user deletes the copied host', async () => { - await copy.delete() - }) - - await expect.poll(() => copy.exists()).toBe(false) - await expect(parentWidget).toHaveValue('original second edit') - await parentWidget.fill('original survives duplicate deletion') - await expect - .poll(() => - original.getWidgetByName('text').then((w) => w.getValue()) - ) - .toBe('original survives duplicate deletion') - }) - - test('clearing a promoted widget label preserves its value and host after reload', async ({ - comfyPage - }) => { - test.slow() - await comfyPage.workflow.setupWorkflowsDirectory({}) - await comfyPage.workflow.loadWorkflow( - 'subgraphs/subgraph-with-text-widget' - ) - const host = await comfyPage.nodeOps.getNodeRefById('11') - await expect.poll(() => host.getProperty('widgets')).toHaveLength(0) - - await test.step('user promotes the inner text widget', async () => { - await fitToViewInstant(comfyPage, { zoom: 1 }) - if (mode.vueNodesEnabled) { - await comfyPage.subgraph.editor.ensureOpen( - comfyPage.vueNodes.getNodeLocator('11') - ) - } else { - await host.click('title') - await host.clickContextMenuOption('Edit Subgraph Widgets') - await expect(comfyPage.subgraph.editor.root).toBeVisible() - } - const item = comfyPage.subgraph.editor.resolveItem({ - nodeName: 'CLIP Text Encode (Prompt)', - widgetName: 'text' - }) - await comfyPage.subgraph.editor.togglePromotionOnItem(item, true) - await comfyPage.menu.propertiesPanel.toggleButton.click() - await fitToViewInstant(comfyPage, { zoom: 1 }) - }) - - const text = await host.getPromotedTextWidget('text') - await expect(text).toHaveCount(1) - await text.fill('Value must not be cleared with the label') - const identity = await comfyPage.page.evaluate((hostId) => { - const node = window.app!.rootGraph.getNodeById(hostId) - if (!node?.isSubgraphNode()) throw new Error('Missing host') - return { type: node.type, subgraphId: node.subgraph.id } - }, toNodeId('11')) - - if (mode.vueNodesEnabled) { - await comfyPage.vueNodes.selectNode('11') - } else { - await host.click('title') - } - const panel = comfyPage.menu.propertiesPanel.root - if (!(await panel.isVisible())) { - await comfyPage.menu.propertiesPanel.toggleButton.click() - } - await expect(panel).toBeVisible() - await panel - .getByRole('tab', { name: 'Parameters', exact: true }) - .click() - await panel.getByText('text', { exact: true }).click() - const labelInput = panel.getByPlaceholder('text', { exact: true }) - await labelInput.fill('Temporary promoted label') - await labelInput.press('Enter') - await expect( - panel.getByText('Temporary promoted label', { exact: true }) - ).toBeVisible() - await panel - .getByText('Temporary promoted label', { exact: true }) - .click() - await labelInput.clear() - await labelInput.press('Enter') - await expect(panel.getByText('text', { exact: true })).toBeVisible() - await expect( - panel.getByText('Temporary promoted label', { exact: true }) - ).toHaveCount(0) - - const workflowName = `${mode.label.toLowerCase()}-cleared-promoted-label` - const workflowPath = `/api/userdata/${encodeURIComponent(`workflows/${workflowName}.json`)}` - const save = comfyPage.page.waitForResponse( - (response) => - new URL(response.url()).pathname === workflowPath && - response.request().method() === 'POST' - ) - await comfyPage.menu.topbar.saveWorkflow(workflowName) - expect((await save).status()).toBe(200) - await expect(comfyPage.toast.toastErrors).toHaveCount(0) - await comfyPage.workflow.reloadAndWaitForApp() - await comfyPage.menu.workflowsTab.open() - await comfyPage.menu.workflowsTab - .getPersistedItem(workflowName) - .click() - await comfyPage.menu.workflowsTab.close() - - await expect - .poll(() => - comfyPage.page.evaluate((hostId) => { - const node = window.app!.rootGraph.getNodeById(hostId) - if (!node?.isSubgraphNode()) return null - const widget = node.widgets.find( - (entry) => entry.name === 'text' - ) - return { - type: node.type, - subgraphId: node.subgraph.id, - label: widget?.label ?? null, - value: widget?.value - } - }, toNodeId('11')) - ) - .toEqual({ - ...identity, - label: null, - value: 'Value must not be cleared with the label' - }) - const restored = await comfyPage.nodeOps.getNodeRefById('11') - await expect( - await restored.getPromotedTextWidget('text') - ).toHaveValue('Value must not be cleared with the label') - await expect(comfyPage.toast.toastErrors).toHaveCount(0) - }) - - for (const deleteOriginal of [true, false]) { - test(`surviving ${deleteOriginal ? 'copy' : 'original'} opens and edits after save/reload`, async ({ - comfyPage - }) => { - await comfyPage.workflow.setupWorkflowsDirectory({}) - await comfyPage.workflow.loadWorkflow( - 'subgraphs/subgraph-with-promoted-text-widget' - ) - const original = await comfyPage.nodeOps.getNodeRefById('11') - - await test.step('user copies and pastes the host', async () => { - await original.copy() - await comfyPage.clipboard.paste() - }) - - await expect - .poll(() => - comfyPage.page.evaluate(() => - window.app!.graph.nodes.some( - (node) => - node.isSubgraphNode() && String(node.id) !== '11' - ) - ) - ) - .toBe(true) - const copyId = await comfyPage.page.evaluate(() => - String( - window.app!.graph.nodes.find( - (node) => node.isSubgraphNode() && String(node.id) !== '11' - )!.id - ) - ) - - const survivorId = deleteOriginal ? copyId : '11' - const survivorNodeId = toNodeId(survivorId) - const survivorGraphId = await comfyPage.page.evaluate( - (survivorNodeId) => { - const survivor = - window.app!.rootGraph.getNodeById(survivorNodeId) - if (!survivor?.isSubgraphNode()) { - throw new Error(`Subgraph host ${survivorNodeId} not found`) - } - return survivor.subgraph.id - }, - survivorNodeId - ) - const removedId = toNodeId(deleteOriginal ? '11' : copyId) - await comfyPage.page.evaluate((removedId) => { - const node = window.app!.rootGraph.getNodeById(removedId) - if (!node) throw new Error(`Node ${removedId} not found`) - window.app!.canvas.deselectAll() - window.app!.canvas.selectNode(node) - }, removedId) - - await test.step(`user deletes the ${deleteOriginal ? 'original' : 'copy'}`, async () => { - await comfyPage.keyboard.delete() - }) - - await expect - .poll(() => - comfyPage.page.evaluate( - (removedId) => ({ - isRootGraphActive: - window.app!.canvas.graph === window.app!.rootGraph, - removedNodeExists: - window.app!.rootGraph.getNodeById(removedId) !== null - }), - removedId - ) - ) - .toEqual({ isRootGraphActive: true, removedNodeExists: false }) - const workflowName = `${mode.label.toLowerCase()}-${deleteOriginal ? 'copy' : 'original'}-survivor` - const workflowPath = `/api/userdata/${encodeURIComponent(`workflows/${workflowName}.json`)}` - const saveResponse = comfyPage.page.waitForResponse( - (response) => - new URL(response.url()).pathname === workflowPath && - response.request().method() === 'POST' - ) - - await test.step('user saves the surviving host', async () => { - await comfyPage.menu.topbar.saveWorkflow(workflowName) - }) - - const encodedSave = await saveResponse - expect(encodedSave.status()).toBe(200) - expect(encodedSave.request().headers()['comfy-user']).toBe( - comfyPage.id - ) - const encodedWorkflow = zComfyWorkflow.parse( - encodedSave.request().postDataJSON() - ) - - const persistedResponse = - await test.step('user reads the saved workflow', () => - comfyPage.request.get(`${comfyPage.apiUrl}${workflowPath}`, { - headers: { 'Comfy-User': comfyPage.id } - })) - - expect(persistedResponse.ok()).toBe(true) - const persistedWorkflow = zComfyWorkflow.parse( - await persistedResponse.json() - ) - const serializedHostIds = (workflow: typeof encodedWorkflow) => - workflow.nodes - .filter((node) => - workflow.definitions?.subgraphs.some( - (subgraph) => subgraph.id === node.type - ) - ) - .map((node) => String(node.id)) - expect(serializedHostIds(encodedWorkflow)).toEqual([survivorId]) - expect(serializedHostIds(persistedWorkflow)).toEqual([survivorId]) - - await test.step('user reloads and opens the saved workflow', async () => { - await comfyPage.workflow.reloadAndWaitForApp() - await comfyPage.menu.workflowsTab.open() - await comfyPage.menu.workflowsTab - .getPersistedItem(workflowName) - .click() - await comfyPage.menu.workflowsTab.close() - }) - - const survivor = - await comfyPage.nodeOps.getNodeRefById(survivorId) - await expect.poll(() => survivor.exists()).toBe(true) - - await test.step('user opens the surviving host', async () => { - if (mode.vueNodesEnabled) { - await comfyPage.vueNodes.enterSubgraph(survivorId) - } else { - await survivor.navigateIntoSubgraph() - } - }) - - await expect - .poll(() => - comfyPage.page.evaluate(() => window.app!.canvas.graph?.id) - ) - .toBe(survivorGraphId) - - const innerId = await comfyPage.page.evaluate(() => { - const graph = window.app!.canvas.graph - if (!graph) throw new Error('Surviving subgraph did not open') - const inner = graph.nodes.find( - (node) => node.type === 'CLIPTextEncode' - ) - if (!inner) throw new Error('Inner text node not found') - return String(inner.id) - }) - const inner = await comfyPage.nodeOps.getNodeRefById(innerId) - await expect.poll(() => inner.exists()).toBe(true) - const originalInnerPosition = await inner.getPosition() - - await test.step('user edits the surviving inner graph', async () => { - await inner.dragBy({ x: 40, y: 20 }) - }) - - await expect - .poll(() => inner.getPosition()) - .not.toEqual(originalInnerPosition) - }) - } - - test('root movement can be undone', async ({ comfyPage }) => { - await comfyPage.workflow.loadWorkflow('subgraphs/nested-subgraph') - - const rootNode = await comfyPage.nodeOps.getNodeRefById('8') - const originalPosition = await rootNode.getPosition() - - await test.step('user moves a root node', async () => { - await rootNode.dragBy({ x: 80, y: 40 }) - }) - - await expect - .poll(() => rootNode.getPosition()) - .not.toEqual(originalPosition) - - await test.step('user undoes the root movement', async () => { - await comfyPage.keyboard.undo() - }) - - await expect - .poll(() => rootNode.getPosition()) - .toEqual(originalPosition) - }) - - test('nested controls and breadcrumbs preserve exact topology', async ({ - comfyPage, - subgraphBreadcrumb - }) => { - await comfyPage.workflow.loadWorkflow('subgraphs/nested-subgraph') - - const topology = () => - comfyPage.page.evaluate(() => { - const graph = window.app!.canvas.graph - if (!graph) throw new Error('Canvas graph is not available') - return { - nodes: graph.nodes.map((node) => String(node.id)).sort(), - links: [...graph.links.values()] - .map((link) => [ - String(link.origin_id), - link.origin_slot, - String(link.target_id), - link.target_slot - ]) - .sort() - } - }) - - expect(await topology()).toEqual({ - nodes: ['10', '8', '9'], - links: [ - ['10', 0, '8', 0], - ['10', 1, '8', 1], - ['8', 0, '9', 0] - ] - }) - - const outer = await comfyPage.nodeOps.getNodeRefById('10') - - await test.step('user opens the outer subgraph', async () => { - if (mode.vueNodesEnabled) { - await comfyPage.vueNodes.enterSubgraph('10') - } else { - await outer.navigateIntoSubgraph() - } - }) - - expect(await topology()).toEqual({ - nodes: ['11', '3', '6'], - links: [ - ['11', 0, '3', 2], - ['11', 1, '3', 3], - ['11', 2, '3', 0], - ['11', 3, '6', 0], - ['11', 4, '-20', 1], - ['3', 0, '-20', 0], - ['6', 0, '3', 1] - ] - }) - - const inner = await comfyPage.nodeOps.getNodeRefById('11') - - await test.step('user opens the inner subgraph', async () => { - if (mode.vueNodesEnabled) { - await comfyPage.vueNodes.enterSubgraph('11') - } else { - await inner.navigateIntoSubgraph() - } - }) - - expect(await topology()).toEqual({ - nodes: ['4', '5', '7'], - links: [ - ['4', 0, '-20', 2], - ['4', 1, '-20', 3], - ['4', 1, '7', 0], - ['4', 2, '-20', 4], - ['5', 0, '-20', 1], - ['7', 0, '-20', 0] - ] - }) - - await test.step('user navigates back to the outer subgraph', async () => { - await subgraphBreadcrumb.clickItem( - 'subgraph-8beb610f-ddd1-4489-ae0d-2f732a4042ae' - ) - }) - - expect(await topology()).toEqual({ - nodes: ['11', '3', '6'], - links: [ - ['11', 0, '3', 2], - ['11', 1, '3', 3], - ['11', 2, '3', 0], - ['11', 3, '6', 0], - ['11', 4, '-20', 1], - ['3', 0, '-20', 0], - ['6', 0, '3', 1] - ] - }) - - await test.step('user navigates back to the root graph', async () => { - await subgraphBreadcrumb.clickItem('root') - }) - - expect(await topology()).toEqual({ - nodes: ['10', '8', '9'], - links: [ - ['10', 0, '8', 0], - ['10', 1, '8', 1], - ['8', 0, '9', 0] - ] - }) - }) - } - ) - } - } -) diff --git a/browser_tests/tests/subgraph/subgraphLifecycle.spec.ts b/browser_tests/tests/subgraph/subgraphLifecycle.spec.ts index 888f80056d2..253e08640ad 100644 --- a/browser_tests/tests/subgraph/subgraphLifecycle.spec.ts +++ b/browser_tests/tests/subgraph/subgraphLifecycle.spec.ts @@ -321,4 +321,68 @@ test.describe('Subgraph Lifecycle', { tag: ['@subgraph'] }, () => { ).toEqual([]) }) }) + + for (const renderer of [ + { name: 'LiteGraph', tag: ['@slow', '@ui'] }, + { name: 'Vue', tag: ['@slow', '@ui', '@vue-nodes'] } + ]) { + test.describe( + `${renderer.name} host persistence`, + { tag: renderer.tag }, + () => { + for (const scenario of [ + { survivorName: 'copy', removedName: 'original' }, + { survivorName: 'original', removedName: 'copy' } + ] as const) { + test(`the ${scenario.survivorName} remains editable after deleting the ${scenario.removedName} and reopening`, async ({ + comfyPage + }) => { + test.slow() + await comfyPage.workflow.setupWorkflowsDirectory({}) + await comfyPage.workflow.loadWorkflow( + 'subgraphs/subgraph-with-promoted-text-widget' + ) + const original = await comfyPage.nodeOps.getNodeRefById('11') + const copy = await original.duplicate() + const survivor = scenario.survivorName === 'copy' ? copy : original + const removed = scenario.removedName === 'copy' ? copy : original + + await test.step(`Delete the ${scenario.removedName}`, async () => { + await removed.delete() + await removed.expectExists(false) + await survivor.expectExists() + }) + + const workflowName = `${renderer.name.toLowerCase()}-${scenario.survivorName}-survivor` + + await test.step('Save and reopen the workflow', async () => { + const savedWorkflow = + await comfyPage.workflow.saveWorkflow(workflowName) + comfyPage.subgraph.expectHostIds(savedWorkflow, [ + String(survivor.id) + ]) + await comfyPage.subgraph.expectPersistedHostIds(workflowName, [ + String(survivor.id) + ]) + await comfyPage.workflow.openPersistedWorkflow(workflowName) + await survivor.expectExists() + }) + + await test.step('Open and edit the surviving host', async () => { + await comfyPage.subgraph.enterSubgraph(survivor) + const inner = await comfyPage.nodeOps.getNodeRefByType( + 'CLIPTextEncode', + true + ) + const originalPosition = await inner.getPosition() + await inner.dragBy({ x: 40, y: 20 }) + await expect + .poll(() => inner.getPosition()) + .not.toEqual(originalPosition) + }) + }) + } + } + ) + } }) diff --git a/browser_tests/tests/subgraph/subgraphNavigation.spec.ts b/browser_tests/tests/subgraph/subgraphNavigation.spec.ts index 74f1714ecb3..0f46e668435 100644 --- a/browser_tests/tests/subgraph/subgraphNavigation.spec.ts +++ b/browser_tests/tests/subgraph/subgraphNavigation.spec.ts @@ -1,9 +1,16 @@ -import { expect } from '@playwright/test' - -import { comfyPageFixture as test } from '@e2e/fixtures/ComfyPage' +import { expect, mergeTests } from '@playwright/test' + +import { comfyPageFixture } from '@e2e/fixtures/ComfyPage' +import { + nestedSubgraphTopologies, + outerSubgraphBreadcrumbId +} from '@e2e/fixtures/data/subgraphTopologies' +import { subgraphBreadcrumbFixture } from '@e2e/fixtures/helpers/SubgraphBreadcrumbHelper' import { TestIds } from '@e2e/fixtures/selectors' import { toNodeId } from '@/types/nodeId' +const test = mergeTests(comfyPageFixture, subgraphBreadcrumbFixture) + const UPDATED_SUBGRAPH_TITLE = 'Updated Subgraph Title' function hasVisibleNodeInViewport() { @@ -335,4 +342,53 @@ test.describe('Subgraph Navigation', { tag: ['@slow', '@subgraph'] }, () => { .toEqual({ exists: true, progress: undefined }) }) }) + + for (const renderer of [ + { name: 'LiteGraph', tag: '@ui' }, + { name: 'Vue', tag: ['@ui', '@vue-nodes'] } + ]) { + test.describe(`${renderer.name} renderer`, { tag: renderer.tag }, () => { + test('nested controls and breadcrumbs preserve exact topology', async ({ + comfyPage, + subgraphBreadcrumb + }) => { + await comfyPage.workflow.loadWorkflow('subgraphs/nested-subgraph') + await comfyPage.subgraph.expectActiveTopology( + nestedSubgraphTopologies.root + ) + + const outer = await comfyPage.nodeOps.getNodeRefById('10') + + await test.step('Open the outer subgraph', async () => { + await comfyPage.subgraph.enterSubgraph(outer) + await comfyPage.subgraph.expectActiveTopology( + nestedSubgraphTopologies.outer + ) + }) + + const inner = await comfyPage.nodeOps.getNodeRefById('11') + + await test.step('Open the inner subgraph', async () => { + await comfyPage.subgraph.enterSubgraph(inner) + await comfyPage.subgraph.expectActiveTopology( + nestedSubgraphTopologies.inner + ) + }) + + await test.step('Return to the outer subgraph', async () => { + await subgraphBreadcrumb.clickItem(outerSubgraphBreadcrumbId) + await comfyPage.subgraph.expectActiveTopology( + nestedSubgraphTopologies.outer + ) + }) + + await test.step('Return to the root graph', async () => { + await subgraphBreadcrumb.clickItem('root') + await comfyPage.subgraph.expectActiveTopology( + nestedSubgraphTopologies.root + ) + }) + }) + }) + } }) diff --git a/browser_tests/tests/subgraph/subgraphOperations.spec.ts b/browser_tests/tests/subgraph/subgraphOperations.spec.ts index f515484333c..ccea6dfc4de 100644 --- a/browser_tests/tests/subgraph/subgraphOperations.spec.ts +++ b/browser_tests/tests/subgraph/subgraphOperations.spec.ts @@ -71,5 +71,32 @@ test.describe('Subgraph Operations', { tag: ['@slow', '@subgraph'] }, () => { .poll(() => comfyPage.subgraph.getNodeCount()) .toBe(initialCount) }) + + for (const renderer of [ + { name: 'LiteGraph', tag: '@ui' }, + { name: 'Vue', tag: ['@ui', '@vue-nodes'] } + ]) { + test.describe(`${renderer.name} renderer`, { tag: renderer.tag }, () => { + test('root node movement is undoable', async ({ comfyPage }) => { + await comfyPage.workflow.loadWorkflow('subgraphs/nested-subgraph') + const rootNode = await comfyPage.nodeOps.getNodeRefById('8') + const originalPosition = await rootNode.getPosition() + + await test.step('Move a root node', async () => { + await rootNode.dragBy({ x: 80, y: 40 }) + await expect + .poll(() => rootNode.getPosition()) + .not.toEqual(originalPosition) + }) + + await test.step('Undo the movement', async () => { + await comfyPage.keyboard.undo() + await expect + .poll(() => rootNode.getPosition()) + .toEqual(originalPosition) + }) + }) + }) + } }) }) diff --git a/browser_tests/tests/subgraph/subgraphPromotedLabelPersistence.spec.ts b/browser_tests/tests/subgraph/subgraphPromotedLabelPersistence.spec.ts new file mode 100644 index 00000000000..636325c9a55 --- /dev/null +++ b/browser_tests/tests/subgraph/subgraphPromotedLabelPersistence.spec.ts @@ -0,0 +1,75 @@ +import { + comfyExpect as expect, + comfyPageFixture as test +} from '@e2e/fixtures/ComfyPage' + +for (const renderer of [ + { name: 'LiteGraph', tag: ['@slow', '@subgraph', '@ui'] }, + { name: 'Vue', tag: ['@slow', '@subgraph', '@ui', '@vue-nodes'] } +]) { + test.describe( + `${renderer.name} promoted widget labels`, + { tag: renderer.tag }, + () => { + test('clearing a promoted label preserves its value after reopening', async ({ + comfyPage + }) => { + test.slow() + await comfyPage.workflow.setupWorkflowsDirectory({}) + await comfyPage.workflow.loadWorkflow( + 'subgraphs/subgraph-with-text-widget' + ) + const host = await comfyPage.nodeOps.getNodeRefById('11') + await host.expectPromotedWidgetCount(0) + + await test.step('Promote and edit the text widget', async () => { + await comfyPage.subgraph.editor.promoteWidget(host, { + nodeName: 'CLIP Text Encode (Prompt)', + widgetName: 'text' + }) + await host.fillPromotedTextWidget( + 'text', + 'Value must not be cleared with the label' + ) + }) + + const identity = await comfyPage.subgraph.getHostIdentity(host) + + await test.step('Rename and clear the promoted label', async () => { + await host.select() + await comfyPage.menu.propertiesPanel.open() + await comfyPage.menu.propertiesPanel.renameParameterLabel( + 'text', + 'Temporary promoted label' + ) + await comfyPage.menu.propertiesPanel.clearParameterLabel( + 'Temporary promoted label', + 'text' + ) + }) + + const workflowName = `${renderer.name.toLowerCase()}-cleared-promoted-label` + + await test.step('Save and reopen the workflow', async () => { + await comfyPage.workflow.saveWorkflow(workflowName) + await expect(comfyPage.toast.toastErrors).toHaveCount(0) + await comfyPage.workflow.openPersistedWorkflow(workflowName) + }) + + await test.step('The host keeps its value without a custom label', async () => { + const restored = await comfyPage.nodeOps.getNodeRefById('11') + await comfyPage.subgraph.expectPromotedWidget(restored, 'text', { + ...identity, + label: null, + value: 'Value must not be cleared with the label' + }) + await restored.expectPromotedTextWidgetValue( + 'text', + 'Value must not be cleared with the label' + ) + await expect(comfyPage.toast.toastErrors).toHaveCount(0) + }) + }) + } + ) +} From 4ea70f80864704205d2c7aef5959c8a2f6c2d476 Mon Sep 17 00:00:00 2001 From: Amp Date: Mon, 14 Sep 2026 20:38:43 +0000 Subject: [PATCH 18/28] test: sort subgraph links explicitly Amp-Thread-ID: https://ampcode.com/threads/T-01a0943a-a2e0-7689-988b-58f82077a59e --- browser_tests/fixtures/helpers/SubgraphHelper.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/browser_tests/fixtures/helpers/SubgraphHelper.ts b/browser_tests/fixtures/helpers/SubgraphHelper.ts index ab827534f1d..b9ced51cdb0 100644 --- a/browser_tests/fixtures/helpers/SubgraphHelper.ts +++ b/browser_tests/fixtures/helpers/SubgraphHelper.ts @@ -619,7 +619,7 @@ export class SubgraphHelper { String(link.target_id), link.target_slot ]) - .sort() + .sort((a, b) => a.join(':').localeCompare(b.join(':'))) } }) } From fd14fdb6b40b3d4355e92f9971cea7fcd3b61ddc Mon Sep 17 00:00:00 2001 From: Amp Date: Mon, 14 Sep 2026 20:45:41 +0000 Subject: [PATCH 19/28] test: harden subgraph workflow helpers Amp-Thread-ID: https://ampcode.com/threads/T-01a0943a-a2e0-7689-988b-58f82077a59e --- browser_tests/fixtures/helpers/WorkflowHelper.ts | 3 ++- browser_tests/fixtures/utils/litegraphUtils.ts | 2 +- browser_tests/tests/subgraph/subgraphLifecycle.spec.ts | 4 +++- .../tests/subgraph/subgraphPromotedLabelPersistence.spec.ts | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/browser_tests/fixtures/helpers/WorkflowHelper.ts b/browser_tests/fixtures/helpers/WorkflowHelper.ts index 3683da3de23..deb3aa37afc 100644 --- a/browser_tests/fixtures/helpers/WorkflowHelper.ts +++ b/browser_tests/fixtures/helpers/WorkflowHelper.ts @@ -157,11 +157,12 @@ export class WorkflowHelper { return zComfyWorkflow.parse(response.request().postDataJSON()) } - async openPersistedWorkflow(workflowName: string): Promise { + async reloadAndOpenPersistedWorkflow(workflowName: string): Promise { await this.reloadAndWaitForApp() const { workflowsTab } = this.comfyPage.menu await workflowsTab.open() await workflowsTab.getPersistedItem(workflowName).click() + await this.waitForWorkflowIdle() await workflowsTab.close() } diff --git a/browser_tests/fixtures/utils/litegraphUtils.ts b/browser_tests/fixtures/utils/litegraphUtils.ts index 07135477734..2168774281c 100644 --- a/browser_tests/fixtures/utils/litegraphUtils.ts +++ b/browser_tests/fixtures/utils/litegraphUtils.ts @@ -411,7 +411,7 @@ export class NodeReference { } async getPromotedTextWidget(name: string) { const vueNode = this.comfyPage.vueNodes.getNodeLocator(String(this.id)) - if ((await vueNode.count()) > 0) { + if (this.comfyPage.isVueNodes) { return vueNode.getByRole('textbox', { name, exact: true }) } diff --git a/browser_tests/tests/subgraph/subgraphLifecycle.spec.ts b/browser_tests/tests/subgraph/subgraphLifecycle.spec.ts index 253e08640ad..32c98be3157 100644 --- a/browser_tests/tests/subgraph/subgraphLifecycle.spec.ts +++ b/browser_tests/tests/subgraph/subgraphLifecycle.spec.ts @@ -364,7 +364,9 @@ test.describe('Subgraph Lifecycle', { tag: ['@subgraph'] }, () => { await comfyPage.subgraph.expectPersistedHostIds(workflowName, [ String(survivor.id) ]) - await comfyPage.workflow.openPersistedWorkflow(workflowName) + await comfyPage.workflow.reloadAndOpenPersistedWorkflow( + workflowName + ) await survivor.expectExists() }) diff --git a/browser_tests/tests/subgraph/subgraphPromotedLabelPersistence.spec.ts b/browser_tests/tests/subgraph/subgraphPromotedLabelPersistence.spec.ts index 636325c9a55..d8c291279bd 100644 --- a/browser_tests/tests/subgraph/subgraphPromotedLabelPersistence.spec.ts +++ b/browser_tests/tests/subgraph/subgraphPromotedLabelPersistence.spec.ts @@ -53,7 +53,7 @@ for (const renderer of [ await test.step('Save and reopen the workflow', async () => { await comfyPage.workflow.saveWorkflow(workflowName) await expect(comfyPage.toast.toastErrors).toHaveCount(0) - await comfyPage.workflow.openPersistedWorkflow(workflowName) + await comfyPage.workflow.reloadAndOpenPersistedWorkflow(workflowName) }) await test.step('The host keeps its value without a custom label', async () => { From d1c2145fb592de94b9c682f097dee621d9cb3abd Mon Sep 17 00:00:00 2001 From: christian-byrne Date: Tue, 15 Sep 2026 14:56:25 -0700 Subject: [PATCH 20/28] test: cover promoted advanced widget values --- .../tests/subgraph/subgraphPromotion.spec.ts | 53 +++++++++++++++---- 1 file changed, 43 insertions(+), 10 deletions(-) diff --git a/browser_tests/tests/subgraph/subgraphPromotion.spec.ts b/browser_tests/tests/subgraph/subgraphPromotion.spec.ts index 3a59efabd9f..1cfade876a1 100644 --- a/browser_tests/tests/subgraph/subgraphPromotion.spec.ts +++ b/browser_tests/tests/subgraph/subgraphPromotion.spec.ts @@ -115,12 +115,27 @@ test.describe( 'Promoted advanced widget remains visible when global advanced widgets are disabled', { tag: ['@node'] }, async ({ comfyPage }) => { + const settingId = 'Comfy.Node.AlwaysShowAdvancedWidgets' + const settingName = 'Always show advanced widgets on all nodes' + const parentValue = '2.25' + + await test.step('Verify the named global setting is disabled', async () => { + await comfyPage.settings.setSetting(settingId, false) + await comfyPage.settingDialog.open() + await comfyPage.settingDialog.searchBox.fill(settingName) + const settingRow = comfyPage.settingDialog.root.locator( + `[data-setting-id="${settingId}"]` + ) + await expect(settingRow).toContainText(settingName) + await expect(settingRow.getByRole('switch')).toHaveAttribute( + 'aria-checked', + 'false' + ) + await comfyPage.settingDialog.close() + }) + const subgraphNodeId = await test.step('Convert a node with hidden advanced widgets to a subgraph', async () => { - await comfyPage.settings.setSetting( - 'Comfy.Node.AlwaysShowAdvancedWidgets', - false - ) const modelSamplingNode = await comfyPage.nodeOps.addNode( 'ModelSamplingFlux', {}, @@ -153,17 +168,35 @@ test.describe( await comfyPage.subgraph.exitViaBreadcrumb() }) - await test.step('Keep the promoted widget visible on the host', async () => { + await test.step('Edit the visible promoted widget on the host', async () => { await expectPromotedWidgetNamesToContain( comfyPage, subgraphNodeId, 'max_shift' ) - await expect( - comfyPage.vueNodes - .getNodeLocator(subgraphNodeId) - .getByLabel('max_shift', { exact: true }) - ).toBeVisible() + const promotedWidget = comfyPage.vueNodes + .getNodeLocator(subgraphNodeId) + .getByLabel('max_shift', { exact: true }) + await expect(promotedWidget).toBeVisible() + const promotedInput = promotedWidget.getByRole('spinbutton') + await promotedInput.fill(parentValue) + await expect(promotedInput).toHaveValue(parentValue) + }) + + await test.step('Keep the shared interior definition value unchanged', async () => { + await comfyPage.vueNodes.enterSubgraph(subgraphNodeId) + await expect + .poll(() => + comfyPage.page.evaluate(() => { + const interiorNode = window.app!.canvas.graph?.nodes.find( + (node) => node.type === 'ModelSamplingFlux' + ) + return interiorNode?.widgets?.find( + (widget) => widget.name === 'max_shift' + )?.value + }) + ) + .toBe(1.15) }) } ) From 7599fe6a6e2580c920cef39d050453ed0bcb60a4 Mon Sep 17 00:00:00 2001 From: christian-byrne Date: Tue, 15 Sep 2026 15:11:34 -0700 Subject: [PATCH 21/28] test: remove unresolved promoted widget contract --- .../tests/subgraph/subgraphPromotion.spec.ts | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/browser_tests/tests/subgraph/subgraphPromotion.spec.ts b/browser_tests/tests/subgraph/subgraphPromotion.spec.ts index 1cfade876a1..5cf5e33a114 100644 --- a/browser_tests/tests/subgraph/subgraphPromotion.spec.ts +++ b/browser_tests/tests/subgraph/subgraphPromotion.spec.ts @@ -182,22 +182,6 @@ test.describe( await promotedInput.fill(parentValue) await expect(promotedInput).toHaveValue(parentValue) }) - - await test.step('Keep the shared interior definition value unchanged', async () => { - await comfyPage.vueNodes.enterSubgraph(subgraphNodeId) - await expect - .poll(() => - comfyPage.page.evaluate(() => { - const interiorNode = window.app!.canvas.graph?.nodes.find( - (node) => node.type === 'ModelSamplingFlux' - ) - return interiorNode?.widgets?.find( - (widget) => widget.name === 'max_shift' - )?.value - }) - ) - .toBe(1.15) - }) } ) From 10f91e7b1dd88e22a12e1d942d3c4fd56485610f Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Wed, 16 Sep 2026 21:30:18 -0700 Subject: [PATCH 22/28] test: persist promoted values after duplicate deletion --- .../SubgraphDuplicateDeleteOrder.test.ts | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/lib/litegraph/src/subgraph/SubgraphDuplicateDeleteOrder.test.ts b/src/lib/litegraph/src/subgraph/SubgraphDuplicateDeleteOrder.test.ts index 2f30ebeef46..24211648b93 100644 --- a/src/lib/litegraph/src/subgraph/SubgraphDuplicateDeleteOrder.test.ts +++ b/src/lib/litegraph/src/subgraph/SubgraphDuplicateDeleteOrder.test.ts @@ -5,12 +5,12 @@ import type { LGraph, LLink, Reroute, - Subgraph, - SubgraphNode + Subgraph } from '@/lib/litegraph/src/litegraph' import { LGraphNode as LGraphNodeClass, - LiteGraph + LiteGraph, + SubgraphNode } from '@/lib/litegraph/src/litegraph' import { createTestNode } from '@/lib/litegraph/src/__fixtures__/nodeHelpers' import { useWidgetValueStore } from '@/stores/widgetValueStore' @@ -191,6 +191,23 @@ function expectSurvivorUndamaged( expect(rootGraph.subgraphs.get(definition.id)).toBe(definition) + const serializedSurvivor = survivor.serialize() + useWidgetValueStore().clearNode(rootGraph.id, survivor.id) + const reloadedSurvivor = new SubgraphNode( + rootGraph, + definition, + serializedSurvivor + ) + reloadedSurvivor.configure(serializedSurvivor) + + expect(promotedValueOf(reloadedSurvivor)).toBe(survivorValue) + const reloadedWidgetId = promotedId(reloadedSurvivor) + if (!reloadedWidgetId) + throw new Error('expected a reloaded promoted widget id') + expect(useWidgetValueStore().setValue(reloadedWidgetId, 333)).toBe(true) + expect(promotedValueOf(reloadedSurvivor)).toBe(333) + expect(reloadedSurvivor.serialize().widgets_values).toEqual([333]) + rootGraph.remove(survivor) expect(rootGraph.subgraphs.has(definition.id)).toBe(false) } From 6ec053bcf721fc6c60347f9f7b158002c6a45753 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Wed, 16 Sep 2026 21:39:30 -0700 Subject: [PATCH 23/28] test: reuse promoted widget lookup in survivor assertions --- .../src/subgraph/SubgraphDuplicateDeleteOrder.test.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/lib/litegraph/src/subgraph/SubgraphDuplicateDeleteOrder.test.ts b/src/lib/litegraph/src/subgraph/SubgraphDuplicateDeleteOrder.test.ts index 24211648b93..cc21b3defd3 100644 --- a/src/lib/litegraph/src/subgraph/SubgraphDuplicateDeleteOrder.test.ts +++ b/src/lib/litegraph/src/subgraph/SubgraphDuplicateDeleteOrder.test.ts @@ -170,15 +170,11 @@ function expectSurvivorUndamaged( const survivorLink = scenario.links[survivorIndex] const survivorReroute = scenario.reroutes[survivorIndex] const survivorValue = promotedValueOf(survivor) - const survivorWidgetId = survivor.inputs.find( - (input) => input.name === PROMOTED_INPUT - )?.widgetId + const survivorWidgetId = promotedId(survivor) rootGraph.remove(removed) - expect(survivorWidgetId).not.toBe( - removed.inputs.find((input) => input.name === PROMOTED_INPUT)?.widgetId - ) + expect(survivorWidgetId).not.toBe(promotedId(removed)) expect(promotedValueOf(survivor)).toBe(survivorValue) const liveLink = rootGraph.links.get(survivorLink.id) From cf30662def382402abd6213b85b38017652f0e93 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Wed, 16 Sep 2026 21:41:56 -0700 Subject: [PATCH 24/28] test: assert independently specified survivor values --- .../litegraph/src/subgraph/SubgraphDuplicateDeleteOrder.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/litegraph/src/subgraph/SubgraphDuplicateDeleteOrder.test.ts b/src/lib/litegraph/src/subgraph/SubgraphDuplicateDeleteOrder.test.ts index cc21b3defd3..4891b8d4a76 100644 --- a/src/lib/litegraph/src/subgraph/SubgraphDuplicateDeleteOrder.test.ts +++ b/src/lib/litegraph/src/subgraph/SubgraphDuplicateDeleteOrder.test.ts @@ -169,7 +169,7 @@ function expectSurvivorUndamaged( const survivor = scenario.instances[survivorIndex] const survivorLink = scenario.links[survivorIndex] const survivorReroute = scenario.reroutes[survivorIndex] - const survivorValue = promotedValueOf(survivor) + const survivorValue = [111, 222][survivorIndex] const survivorWidgetId = promotedId(survivor) rootGraph.remove(removed) From fb0e853fb07ed9d3dbb1ad2098bba75570f3d027 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Wed, 16 Sep 2026 23:33:08 -0700 Subject: [PATCH 25/28] test: persist independent subgraph host values --- ...subgraphDuplicateIndependentValues.spec.ts | 83 +++++++++++-------- 1 file changed, 49 insertions(+), 34 deletions(-) diff --git a/browser_tests/tests/subgraph/subgraphDuplicateIndependentValues.spec.ts b/browser_tests/tests/subgraph/subgraphDuplicateIndependentValues.spec.ts index d7397d0434d..c75890c457a 100644 --- a/browser_tests/tests/subgraph/subgraphDuplicateIndependentValues.spec.ts +++ b/browser_tests/tests/subgraph/subgraphDuplicateIndependentValues.spec.ts @@ -62,45 +62,60 @@ for (const renderer of [ { name: 'Vue', tag: ['@slow', '@subgraph', '@ui', '@vue-nodes'] } ]) { test.describe(`${renderer.name} renderer`, { tag: renderer.tag }, () => { - test('editing a copied host does not change the original', async ({ - comfyPage - }) => { - await comfyPage.workflow.loadWorkflow( - 'subgraphs/subgraph-with-promoted-text-widget' - ) - const original = await comfyPage.nodeOps.getNodeRefById('11') + for (const scenario of [ + { survivorName: 'copy', removedName: 'original' }, + { survivorName: 'original', removedName: 'copy' } + ] as const) { + test(`the ${scenario.survivorName} keeps its independent value after deleting the ${scenario.removedName} and reopening`, async ({ + comfyPage + }) => { + test.slow() + await comfyPage.workflow.setupWorkflowsDirectory({}) + await comfyPage.workflow.loadWorkflow( + 'subgraphs/subgraph-with-promoted-text-widget' + ) + const original = await comfyPage.nodeOps.getNodeRefById('11') + const copy = await original.duplicate() + const survivor = scenario.survivorName === 'copy' ? copy : original + const removed = scenario.removedName === 'copy' ? copy : original + const survivorValue = `${scenario.survivorName} durable value` + const removedValue = `${scenario.removedName} discarded value` - await test.step('Edit the original host', async () => { - await original.fillPromotedTextWidget('text', 'original parent edit') - }) + await test.step('Set independent host values', async () => { + await survivor.fillPromotedTextWidget('text', survivorValue) + await removed.fillPromotedTextWidget('text', removedValue) + await survivor.expectPromotedTextWidgetValue('text', survivorValue) + await removed.expectPromotedTextWidgetValue('text', removedValue) + }) - const copy = await test.step('Copy the host', () => original.duplicate()) + await test.step(`Delete the ${scenario.removedName}`, async () => { + await removed.delete() + await removed.expectExists(false) + await survivor.expectPromotedTextWidgetValue('text', survivorValue) + }) - await test.step('Edit only the copy', async () => { - await copy.fillPromotedTextWidget('text', 'copy-only edit') - await original.expectPromotedTextWidgetValue( - 'text', - 'original parent edit' - ) - }) + const workflowName = `${renderer.name.toLowerCase()}-${scenario.survivorName}-host-value` - await test.step('Edit the original without changing the copy', async () => { - await original.fillPromotedTextWidget('text', 'original second edit') - await copy.expectPromotedTextWidgetValue('text', 'copy-only edit') - }) + await test.step('Save, reload, and reopen the workflow', async () => { + await comfyPage.workflow.saveWorkflow(workflowName) + await comfyPage.workflow.reloadAndOpenPersistedWorkflow(workflowName) + }) - await test.step('Delete the copy and continue editing the original', async () => { - await copy.delete() - await copy.expectExists(false) - await original.expectPromotedTextWidgetValue( - 'text', - 'original second edit' - ) - await original.fillPromotedTextWidget( - 'text', - 'original survives duplicate deletion' - ) + await test.step('Verify and edit the surviving host value', async () => { + const restored = await comfyPage.nodeOps.getNodeRefById( + String(survivor.id) + ) + await restored.expectPromotedTextWidgetValue('text', survivorValue) + await restored.fillPromotedTextWidget( + 'text', + `${survivorValue} edited after reopen` + ) + await restored.expectPromotedTextWidgetValue( + 'text', + `${survivorValue} edited after reopen` + ) + }) }) - }) + } }) } From 91460412a9b144034e93f9e4637f0f1b3ff69397 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Thu, 17 Sep 2026 01:38:44 -0700 Subject: [PATCH 26/28] test: cover remaining ECS widget contracts --- browser_tests/tests/primitiveNode.spec.ts | 65 +++++++++++++++++ .../tests/subgraph/subgraphPromotion.spec.ts | 70 ++++++++++++++++++- 2 files changed, 133 insertions(+), 2 deletions(-) diff --git a/browser_tests/tests/primitiveNode.spec.ts b/browser_tests/tests/primitiveNode.spec.ts index 7bf7fd10fd0..1dd6461b9c6 100644 --- a/browser_tests/tests/primitiveNode.spec.ts +++ b/browser_tests/tests/primitiveNode.spec.ts @@ -1,5 +1,7 @@ import { expect } from '@playwright/test' +import { toNodeId } from '@/types/nodeId' + import { comfyPageFixture as test } from '@e2e/fixtures/ComfyPage' import { TestIds } from '@e2e/fixtures/selectors' import type { NodeReference } from '@e2e/fixtures/utils/litegraphUtils' @@ -7,6 +9,69 @@ import type { NodeReference } from '@e2e/fixtures/utils/litegraphUtils' test.use({ initialSettings: { 'Comfy.UseNewMenu': 'Disabled' } }) test.describe('Primitive Node', { tag: ['@screenshot', '@node'] }, () => { + for (const renderer of [ + { name: 'LiteGraph', tag: '@ui' }, + { name: 'Vue', tag: ['@ui', '@vue-nodes'] } + ]) { + test.describe(`${renderer.name} renderer`, { tag: renderer.tag }, () => { + test('widget and socket coexist through connect and disconnect with the original value', async ({ + comfyPage + }) => { + await comfyPage.workflow.loadWorkflow( + 'primitive/primitive_node_unconnected' + ) + const primitive = await comfyPage.nodeOps.getNodeRefById(1) + const ksampler = await comfyPage.nodeOps.getNodeRefById(2) + const seed = await ksampler.getWidgetByName('seed') + const originalValue = await seed.getValue() + + await primitive.connectWidget(0, ksampler, 0) + await expect + .poll(() => + comfyPage.page.evaluate((nodeId) => { + const node = window.app!.graph.getNodeById(nodeId) + return { + hasWidget: node?.widgets?.some( + (widget) => widget.name === 'seed' + ), + socketLink: node?.inputs.find( + (input) => input.widget?.name === 'seed' + )?.link + } + }, toNodeId(2)) + ) + .toEqual({ hasWidget: true, socketLink: expect.any(Number) }) + + const disconnected = await comfyPage.page.evaluate((nodeId) => { + const node = window.app!.graph.getNodeById(nodeId) + const index = node?.inputs.findIndex( + (input) => input.widget?.name === 'seed' + ) + if (!node || index === undefined || index < 0) return false + return node.disconnectInput(index) + }, toNodeId(2)) + expect(disconnected).toBe(true) + await comfyPage.nextFrame() + await expect.poll(() => seed.getValue()).toBe(originalValue) + await expect + .poll(() => + comfyPage.page.evaluate((nodeId) => { + const node = window.app!.graph.getNodeById(nodeId) + return { + hasWidget: node?.widgets?.some( + (widget) => widget.name === 'seed' + ), + socketLink: node?.inputs.find( + (input) => input.widget?.name === 'seed' + )?.link + } + }, toNodeId(2)) + ) + .toEqual({ hasWidget: true, socketLink: null }) + }) + }) + } + test('Can load with correct size', async ({ comfyPage }) => { await comfyPage.workflow.loadWorkflow('primitive/primitive_node') await expect(comfyPage.canvas).toHaveScreenshot('primitive_node.png') diff --git a/browser_tests/tests/subgraph/subgraphPromotion.spec.ts b/browser_tests/tests/subgraph/subgraphPromotion.spec.ts index 5cf5e33a114..25da66f5e4c 100644 --- a/browser_tests/tests/subgraph/subgraphPromotion.spec.ts +++ b/browser_tests/tests/subgraph/subgraphPromotion.spec.ts @@ -5,7 +5,8 @@ import { comfyPageFixture as test } from '@e2e/fixtures/ComfyPage' import { fitToViewInstant } from '@e2e/fixtures/utils/fitToView' import { getPromotedWidgetNames, - getPromotedWidgetCount + getPromotedWidgetCount, + setPromotedHostWidgetValue } from '@e2e/fixtures/utils/promotedWidgets' async function expectPromotedWidgetNamesToContain( @@ -91,6 +92,8 @@ test.describe( 'Promoted Widget Visibility in Vue Mode', { tag: ['@vue-nodes'] }, () => { + test.use({ initialSettings: { 'Comfy.UseNewMenu': 'Top' } }) + test('Promoted widget connected to the subgraph input is interactive on the host', async ({ comfyPage }) => { @@ -113,12 +116,15 @@ test.describe( test( 'Promoted advanced widget remains visible when global advanced widgets are disabled', - { tag: ['@node'] }, + { tag: ['@node', '@slow'] }, async ({ comfyPage }) => { const settingId = 'Comfy.Node.AlwaysShowAdvancedWidgets' const settingName = 'Always show advanced widgets on all nodes' const parentValue = '2.25' + test.setTimeout(120_000) + await comfyPage.workflow.setupWorkflowsDirectory({}) + await test.step('Verify the named global setting is disabled', async () => { await comfyPage.settings.setSetting(settingId, false) await comfyPage.settingDialog.open() @@ -180,8 +186,68 @@ test.describe( await expect(promotedWidget).toBeVisible() const promotedInput = promotedWidget.getByRole('spinbutton') await promotedInput.fill(parentValue) + await promotedInput.press('Tab') await expect(promotedInput).toHaveValue(parentValue) }) + + const host = await comfyPage.nodeOps.getNodeRefById(subgraphNodeId) + const identity = await comfyPage.subgraph.getHostIdentity(host) + await comfyPage.subgraph.expectPromotedWidget(host, 'max_shift', { + ...identity, + label: 'max_shift', + value: Number(parentValue) + }) + + const workflowName = 'vue-advanced-promoted-host-value' + await comfyPage.workflow.saveWorkflow(workflowName) + await comfyPage.workflow.reloadAndOpenPersistedWorkflow( + workflowName + ) + + const restored = + await comfyPage.nodeOps.getNodeRefById(subgraphNodeId) + await comfyPage.subgraph.expectPromotedWidget( + restored, + 'max_shift', + { + ...identity, + label: 'max_shift', + value: Number(parentValue) + } + ) + + await comfyPage.menu.topbar.setVueNodesEnabled(false) + await fitToViewInstant(comfyPage, { zoom: 1 }) + const liteGraphWidget = await restored.getWidgetByName('max_shift') + expect(await liteGraphWidget.getValue()).toBe(Number(parentValue)) + expect( + await setPromotedHostWidgetValue( + comfyPage, + restored.id, + 'max_shift', + '2.5', + { useSetValue: true } + ) + ).toBe('2.5') + await comfyPage.menu.topbar.setVueNodesEnabled(true) + + const restoredInput = comfyPage.vueNodes + .getNodeLocator(subgraphNodeId) + .getByLabel('max_shift', { exact: true }) + .getByRole('spinbutton') + await expect(restoredInput).toBeVisible() + await restoredInput.fill('2.75') + await restoredInput.press('Tab') + await expect(restoredInput).toHaveValue('2.75') + await comfyPage.subgraph.expectPromotedWidget( + restored, + 'max_shift', + { + ...identity, + label: 'max_shift', + value: 2.75 + } + ) } ) From 722e25512ab402c52f8c1ad6633e12b9bac10405 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Thu, 17 Sep 2026 05:31:52 -0700 Subject: [PATCH 27/28] test: strengthen ECS widget lifecycle contracts --- browser_tests/tests/primitiveNode.spec.ts | 55 ++++++++++++++----- .../tests/subgraph/subgraphPromotion.spec.ts | 54 ++++++++---------- 2 files changed, 65 insertions(+), 44 deletions(-) diff --git a/browser_tests/tests/primitiveNode.spec.ts b/browser_tests/tests/primitiveNode.spec.ts index 1dd6461b9c6..e44a1273ae7 100644 --- a/browser_tests/tests/primitiveNode.spec.ts +++ b/browser_tests/tests/primitiveNode.spec.ts @@ -14,7 +14,7 @@ test.describe('Primitive Node', { tag: ['@screenshot', '@node'] }, () => { { name: 'Vue', tag: ['@ui', '@vue-nodes'] } ]) { test.describe(`${renderer.name} renderer`, { tag: renderer.tag }, () => { - test('widget and socket coexist through connect and disconnect with the original value', async ({ + test('widget and socket coexist through connect and disconnect with the connected value', async ({ comfyPage }) => { await comfyPage.workflow.loadWorkflow( @@ -24,23 +24,50 @@ test.describe('Primitive Node', { tag: ['@screenshot', '@node'] }, () => { const ksampler = await comfyPage.nodeOps.getNodeRefById(2) const seed = await ksampler.getWidgetByName('seed') const originalValue = await seed.getValue() + expect(originalValue).toBe(0) await primitive.connectWidget(0, ksampler, 0) + const primitiveWidget = await primitive.getWidget(0) + if (renderer.name === 'Vue') { + const input = comfyPage.vueNodes + .getNodeLocator(primitive.id) + .getByRole('spinbutton') + await input.fill('222') + await input.press('Tab') + } else { + await primitiveWidget.click() + await comfyPage.nodeOps.fillLegacyWidgetDialog('222') + } + expect(await primitiveWidget.getValue()).toBe(222) await expect .poll(() => - comfyPage.page.evaluate((nodeId) => { - const node = window.app!.graph.getNodeById(nodeId) - return { - hasWidget: node?.widgets?.some( - (widget) => widget.name === 'seed' - ), - socketLink: node?.inputs.find( - (input) => input.widget?.name === 'seed' - )?.link - } - }, toNodeId(2)) + comfyPage.page.evaluate( + ([nodeId, sourceNodeId]) => { + const node = window.app!.graph.getNodeById(nodeId) + return { + hasWidget: node?.widgets?.some( + (widget) => widget.name === 'seed' + ), + sourceValue: + window.app!.graph.getNodeById(sourceNodeId)?.widgets?.[0] + ?.value, + widgetValue: node?.widgets?.find( + (widget) => widget.name === 'seed' + )?.value, + socketLink: node?.inputs.find( + (input) => input.widget?.name === 'seed' + )?.link + } + }, + [toNodeId(2), toNodeId(1)] as const + ) ) - .toEqual({ hasWidget: true, socketLink: expect.any(Number) }) + .toEqual({ + hasWidget: true, + sourceValue: 222, + widgetValue: 222, + socketLink: expect.any(Number) + }) const disconnected = await comfyPage.page.evaluate((nodeId) => { const node = window.app!.graph.getNodeById(nodeId) @@ -52,7 +79,7 @@ test.describe('Primitive Node', { tag: ['@screenshot', '@node'] }, () => { }, toNodeId(2)) expect(disconnected).toBe(true) await comfyPage.nextFrame() - await expect.poll(() => seed.getValue()).toBe(originalValue) + await expect.poll(() => seed.getValue()).toBe(222) await expect .poll(() => comfyPage.page.evaluate((nodeId) => { diff --git a/browser_tests/tests/subgraph/subgraphPromotion.spec.ts b/browser_tests/tests/subgraph/subgraphPromotion.spec.ts index 25da66f5e4c..dc7d54668b5 100644 --- a/browser_tests/tests/subgraph/subgraphPromotion.spec.ts +++ b/browser_tests/tests/subgraph/subgraphPromotion.spec.ts @@ -5,8 +5,7 @@ import { comfyPageFixture as test } from '@e2e/fixtures/ComfyPage' import { fitToViewInstant } from '@e2e/fixtures/utils/fitToView' import { getPromotedWidgetNames, - getPromotedWidgetCount, - setPromotedHostWidgetValue + getPromotedWidgetCount } from '@e2e/fixtures/utils/promotedWidgets' async function expectPromotedWidgetNamesToContain( @@ -198,7 +197,7 @@ test.describe( value: Number(parentValue) }) - const workflowName = 'vue-advanced-promoted-host-value' + const workflowName = `vue-advanced-promoted-host-value-${Date.now()}` await comfyPage.workflow.saveWorkflow(workflowName) await comfyPage.workflow.reloadAndOpenPersistedWorkflow( workflowName @@ -220,34 +219,29 @@ test.describe( await fitToViewInstant(comfyPage, { zoom: 1 }) const liteGraphWidget = await restored.getWidgetByName('max_shift') expect(await liteGraphWidget.getValue()).toBe(Number(parentValue)) - expect( - await setPromotedHostWidgetValue( - comfyPage, - restored.id, - 'max_shift', - '2.5', - { useSetValue: true } - ) - ).toBe('2.5') - await comfyPage.menu.topbar.setVueNodesEnabled(true) - - const restoredInput = comfyPage.vueNodes - .getNodeLocator(subgraphNodeId) - .getByLabel('max_shift', { exact: true }) - .getByRole('spinbutton') - await expect(restoredInput).toBeVisible() - await restoredInput.fill('2.75') - await restoredInput.press('Tab') - await expect(restoredInput).toHaveValue('2.75') - await comfyPage.subgraph.expectPromotedWidget( - restored, - 'max_shift', - { - ...identity, - label: 'max_shift', - value: 2.75 - } + await liteGraphWidget.click() + await comfyPage.nodeOps.fillLegacyWidgetDialog('2.5') + expect(await liteGraphWidget.getValue()).toBe(2.5) + + const saveResponse = comfyPage.page.waitForResponse( + (response) => + response.request().method() === 'POST' && + new URL(response.url()).pathname.includes( + encodeURIComponent(`workflows/${workflowName}.json`) + ) + ) + await comfyPage.menu.topbar.triggerTopbarCommand(['File', 'Save']) + expect((await saveResponse).status()).toBe(200) + await comfyPage.workflow.reloadAndOpenPersistedWorkflow( + workflowName ) + const legacyRestored = + await comfyPage.nodeOps.getNodeRefById(subgraphNodeId) + expect( + await ( + await legacyRestored.getWidgetByName('max_shift') + ).getValue() + ).toBe(2.5) } ) From 7f8302c2831e5937397545e4f0e26457af515ebb Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Thu, 17 Sep 2026 07:43:48 -0700 Subject: [PATCH 28/28] test: isolate promoted widget persistence from default graph --- browser_tests/tests/subgraph/subgraphPromotion.spec.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/browser_tests/tests/subgraph/subgraphPromotion.spec.ts b/browser_tests/tests/subgraph/subgraphPromotion.spec.ts index dc7d54668b5..61214475dcf 100644 --- a/browser_tests/tests/subgraph/subgraphPromotion.spec.ts +++ b/browser_tests/tests/subgraph/subgraphPromotion.spec.ts @@ -123,6 +123,8 @@ test.describe( test.setTimeout(120_000) await comfyPage.workflow.setupWorkflowsDirectory({}) + await comfyPage.nodeOps.clearGraph() + await comfyPage.nodeOps.waitForGraphNodes(0) await test.step('Verify the named global setting is disabled', async () => { await comfyPage.settings.setSetting(settingId, false)