fix: improve promoted widget label fix and expand E2E coverage

- Align draw() label override condition with label getter (unconditional
  when displayName is set)
- Remove fragile negative text assertion from Vue Node test
- Add round-trip persistence test (serialize -> reload -> verify labels)
- Add rename-inside-subgraph test (enter subgraph -> rename slot ->
  exit -> verify updated label on SubgraphNode)
This commit is contained in:
jaeone94
2026-03-22 21:48:07 +09:00
parent 7707dbfcd3
commit b1f141d76d
2 changed files with 72 additions and 14 deletions

View File

@@ -1,5 +1,7 @@
import { expect } from '@playwright/test'
import type { ComfyWorkflowJSON } from '@/platform/workflow/validation/schemas/workflowSchema'
import { comfyPageFixture as test } from '../fixtures/ComfyPage'
test.describe(
@@ -32,20 +34,76 @@ test.describe(
// The promoted widgets should display the renamed labels
await expect(nodeBody).toContainText('my_seed')
await expect(nodeBody).toContainText('num_steps')
})
})
// They should NOT display the original interior widget names
// (seed/steps would appear as standalone text only if labels are broken)
const bodyText = await nodeBody.textContent()
const seedOnlyMatches = bodyText
?.split('my_seed')
.join('')
.match(/\bseed\b/g)
const stepsOnlyMatches = bodyText
?.split('num_steps')
.join('')
.match(/\bsteps\b/g)
expect(seedOnlyMatches ?? []).toHaveLength(0)
expect(stepsOnlyMatches ?? []).toHaveLength(0)
test.describe('Round-trip persistence', () => {
test.beforeEach(async ({ comfyPage }) => {
await comfyPage.settings.setSetting('Comfy.UseNewMenu', 'Disabled')
})
test('Renamed labels survive serialize -> loadGraphData round-trip', async ({
comfyPage
}) => {
await comfyPage.workflow.loadWorkflow(WORKFLOW)
await comfyPage.nextFrame()
const serialized = await comfyPage.page.evaluate(() => {
return window.app!.graph!.serialize()
})
await comfyPage.page.evaluate((workflow: ComfyWorkflowJSON) => {
return window.app!.loadGraphData(workflow)
}, serialized as ComfyWorkflowJSON)
await comfyPage.nextFrame()
const widgetNames = await comfyPage.page.evaluate((nodeId) => {
const node = window.app!.canvas.graph!.getNodeById(nodeId)
return (node?.widgets ?? []).map((w) => w.name)
}, SUBGRAPH_NODE_ID)
expect(widgetNames).toContain('my_seed')
expect(widgetNames).toContain('num_steps')
})
})
test.describe('Rename inside subgraph', () => {
test.beforeEach(async ({ comfyPage }) => {
await comfyPage.settings.setSetting('Comfy.UseNewMenu', 'Disabled')
})
test('Renaming a promoted input slot inside the subgraph updates the label on the SubgraphNode', async ({
comfyPage
}) => {
await comfyPage.workflow.loadWorkflow(WORKFLOW)
await comfyPage.nextFrame()
const subgraphNode =
await comfyPage.nodeOps.getNodeRefById(SUBGRAPH_NODE_ID)
await subgraphNode.navigateIntoSubgraph()
// Rename the "seed" input slot (currently labeled "my_seed") to "renamed_seed"
await comfyPage.subgraph.rightClickInputSlot('seed')
await comfyPage.contextMenu.clickLitegraphMenuItem('Rename Slot')
await comfyPage.nextFrame()
await comfyPage.page.waitForSelector('.graphdialog input', {
state: 'visible'
})
await comfyPage.page.fill('.graphdialog input', 'renamed_seed')
await comfyPage.page.keyboard.press('Enter')
await comfyPage.nextFrame()
// Navigate back to root graph
await comfyPage.subgraph.exitViaBreadcrumb()
// Verify the promoted widget now shows the new label
const widgetNames = await comfyPage.page.evaluate((nodeId) => {
const node = window.app!.canvas.graph!.getNodeById(nodeId)
return (node?.widgets ?? []).map((w) => w.name)
}, SUBGRAPH_NODE_ID)
expect(widgetNames).toContain('renamed_seed')
})
})

View File

@@ -243,7 +243,7 @@ class PromotedWidgetView implements IPromotedWidgetView {
projected.computedHeight = this.computedHeight
projected.computedDisabled = this.computedDisabled
projected.value = this.value
if (this.displayName && this.displayName !== this.sourceWidgetName) {
if (this.displayName) {
projected.label = this.displayName
}