Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,46 @@ test.describe('Vue Nodes Image Preview', { tag: '@vue-nodes' }, () => {
await expect(subgraphNode.imagePreview.locator('img')).toHaveCount(1)
}
)

// Regression test for incident-94: a mid-execution sampler preview inside a
// subgraph must promote to the outer, non-entered SubgraphNode.
wstest(
'Promotes a live sampler preview from inside a subgraph to the outer SubgraphNode',
async ({ comfyPage, getWebSocket }) => {
const execution = new ExecutionHelper(comfyPage, await getWebSocket())
const samplerNode = new VueNodeFixture(
comfyPage.vueNodes.getNodeByTitle('KSampler')
)
const subgraphNode = new VueNodeFixture(
comfyPage.vueNodes.getNodeByTitle('New Subgraph')
)

await test.step('Add node', async () => {
await comfyPage.menu.topbar.newWorkflowButton.click()
await comfyPage.nextFrame()

await comfyPage.searchBoxV2.addNode('KSampler')
await expect(samplerNode.root).toBeVisible()
})

await test.step('Create subgraph', async () => {
await samplerNode.title.click()
await comfyPage.page.keyboard.press('Control+Shift+e')
await expect(subgraphNode.root).toBeVisible()
})

await test.step('Fire live preview for the nested sampler', async () => {
const jobId = await execution.run()
execution.executionStart(jobId)
execution.executing(jobId, '2:1')
execution.latentPreview(jobId, '2:1')
})

await expect(
subgraphNode.root.getByAltText('Live sampling preview')
).toBeVisible()
}
)
})

async function countColumns(locator: Locator) {
Expand Down
19 changes: 19 additions & 0 deletions src/renderer/extensions/vueNodes/components/LGraphNode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'

import { toNodeId } from '@/types/nodeId'
import { createNodeLocatorId } from '@/types/nodeIdentification'
import { computed } from 'vue'
import type { ComponentProps } from 'vue-component-type-helpers'
import { createI18n } from 'vue-i18n'
Expand All @@ -12,6 +13,7 @@
import { TitleMode } from '@/lib/litegraph/src/types/globalEnums'
import LGraphNode from '@/renderer/extensions/vueNodes/components/LGraphNode.vue'
import { useVueElementTracking } from '@/renderer/extensions/vueNodes/composables/useVueNodeResizeTracking'
import { useNodePreviewState } from '@/renderer/extensions/vueNodes/preview/useNodePreviewState'
import { useCanvasStore } from '@/renderer/core/canvas/canvasStore'
import { useSettingStore } from '@/platform/settings/settingStore'
import { app } from '@/scripts/app'
Expand Down Expand Up @@ -388,4 +390,21 @@
expect(app.dragOverNode).toBe(mockData.mockLgraphNode)
})
})

describe('Subgraph live preview promotion (incident-94 regression)', () => {
it('renders the live preview image on a subgraph node with a populated preview', () => {
mockData.mockLgraphNode = { isSubgraphNode: () => true }
vi.mocked(useNodePreviewState).mockReturnValue({
locatorId: computed(() => createNodeLocatorId(null, mockNodeData.id)),
previewUrls: computed(() => ['blob:preview-url']),
hasPreview: computed(() => true),
latestPreviewUrl: computed(() => 'blob:preview-url'),
shouldShowPreviewImg: computed(() => true)
})

renderLGraphNode({ nodeData: mockNodeData })

expect(screen.getByRole('img')).toHaveAttribute('src', 'blob:preview-url')

Check failure on line 407 in src/renderer/extensions/vueNodes/components/LGraphNode.test.ts

View workflow job for this annotation

GitHub Actions / test

src/renderer/extensions/vueNodes/components/LGraphNode.test.ts > LGraphNode > Subgraph live preview promotion (incident-94 regression) > renders the live preview image on a subgraph node with a populated preview

TestingLibraryElementError: Unable to find an accessible element with the role "img" Here are the accessible roles: button: Name "g.enterSubgraph": <button class="relative inline-flex items-center justify-center gap-2 cursor-pointer touch-manipulation whitespace-nowrap appearance-none border-none font-inter transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([width]):not([height])]:size-4 [&_svg]:shrink-0 hover:bg-secondary-background-hover p-2 pointer-events-auto h-11 text-xs font-normal box-border w-full rounded-none bg-node-component-header-surface text-node-component-slot-text pt-8 pb-3 rounded-b-xl" data-testid="subgraph-enter-button" /> Name "g.resizeFromBottomRight": <div aria-label="g.resizeFromBottomRight" class="absolute h-5 w-5 opacity-0 pointer-events-auto focus-visible:outline focus-visible:outline-2 focus-visible:outline-white/40 touch-none -right-1 -bottom-1 cursor-se-resize group-hover/node:opacity-100" data-corner="SE" role="button" /> Name "g.resizeFromTopRight": <div aria-label="g.resizeFromTopRight" class="absolute h-5 w-5 opacity-0 pointer-events-auto focus-visible:outline focus-visible:outline-2 focus-visible:outline-white/40 touch-none -right-1 -top-1 cursor-ne-resize group-hover/node:opacity-100" data-corner="NE" role="button" /> Name "g.resizeFromBottomLeft": <div aria-label="g.resizeFromBottomLeft" class="absolute h-5 w-5 opacity-0 pointer-events-auto focus-visible:outline focus-visible:outline-2 focus-visible:outline-white/40 touch-none -left-1 -bottom-1 cursor-sw-resize group-hover/node:opacity-100" data-corner="SW" role="button" /> Name "g.resizeFromTopLeft": <div aria-label="g.resizeFromTopLeft" class="absolute h-5 w-5 opacity-0 pointer-events-auto focus-visible:outline focus-visible:outline-2 focus-visible:outline-white/40 touch-none -left-1 -top-1 cursor-nw-resize group-hover/node:opacity-100" data-corner="NW" role="button" /> -------------------------------------------------- Ignored nodes: comments, script, style <body> <div> <div class="group/node lg-node absolute isolate text-xs flex flex-col contain-layout contain-style drop-shadow-xl drop-shadow-black/40 min-h-(--node-height) min-w-(--min-node-width) cursor-grab pointer-events-auto" data-node-id="test-node-123" style="--min-node-width: 225px; transform: translate(100px, 20px); z-index: 0; opacity: 1; --node-width: 200px; --node-height: 130px;" tabindex="0" > <div class="flex flex-1 flex-col bg-node-component-header-surface w-(--node-width) min-w-(--min-node-width) rounded-xl" data-testid="node-inner-wrapper" > <div class="relative flex flex-col items-center justify-center" > <node-header-stub collapsed="false" nodedata="[object Object]" pricebadges="" /> </div> <div class="relative" /> <div class="flex flex-1 flex-col gap-1 bg-component-node-background pt-1 pb-3 rounded-b-xl" data-testid="node-body-test-node-123" > <node-slots-stub nodedata="[object Object]" unified="false" /> <div class="flex h-5 w-full gap-2 px-2 text-muted-foreground mt-auto" > <div class="flex h-6 items-center justify-center overflow-clip rounded-full bg-component-node-widget-background" > <div class="flex min-w-max items-center gap-1 rounded-sm bg-node-component-surface px-1 py-0.5 text-xs h-6 first:pl-2 last:pr-2" style="color: currentcolor; background-color: transparent;" > #test-node-123 </div> </div> </div> </div>

Check failure on line 407 in src/renderer/extensions/vueNodes/components/LGraphNode.test.ts

View workflow job for this annotation

GitHub Actions / test

src/renderer/extensions/vueNodes/components/LGraphNode.test.ts > LGraphNode > Subgraph live preview promotion (incident-94 regression) > renders the live preview image on a subgraph node with a populated preview

TestingLibraryElementError: Unable to find an accessible element with the role "img" Here are the accessible roles: button: Name "g.enterSubgraph": <button class="relative inline-flex items-center justify-center gap-2 cursor-pointer touch-manipulation whitespace-nowrap appearance-none border-none font-inter transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([width]):not([height])]:size-4 [&_svg]:shrink-0 hover:bg-secondary-background-hover p-2 pointer-events-auto h-11 text-xs font-normal box-border w-full rounded-none bg-node-component-header-surface text-node-component-slot-text pt-8 pb-3 rounded-b-xl" data-testid="subgraph-enter-button" /> Name "g.resizeFromBottomRight": <div aria-label="g.resizeFromBottomRight" class="absolute h-5 w-5 opacity-0 pointer-events-auto focus-visible:outline focus-visible:outline-2 focus-visible:outline-white/40 touch-none -right-1 -bottom-1 cursor-se-resize group-hover/node:opacity-100" data-corner="SE" role="button" /> Name "g.resizeFromTopRight": <div aria-label="g.resizeFromTopRight" class="absolute h-5 w-5 opacity-0 pointer-events-auto focus-visible:outline focus-visible:outline-2 focus-visible:outline-white/40 touch-none -right-1 -top-1 cursor-ne-resize group-hover/node:opacity-100" data-corner="NE" role="button" /> Name "g.resizeFromBottomLeft": <div aria-label="g.resizeFromBottomLeft" class="absolute h-5 w-5 opacity-0 pointer-events-auto focus-visible:outline focus-visible:outline-2 focus-visible:outline-white/40 touch-none -left-1 -bottom-1 cursor-sw-resize group-hover/node:opacity-100" data-corner="SW" role="button" /> Name "g.resizeFromTopLeft": <div aria-label="g.resizeFromTopLeft" class="absolute h-5 w-5 opacity-0 pointer-events-auto focus-visible:outline focus-visible:outline-2 focus-visible:outline-white/40 touch-none -left-1 -top-1 cursor-nw-resize group-hover/node:opacity-100" data-corner="NW" role="button" /> -------------------------------------------------- Ignored nodes: comments, script, style <body> <div> <div class="group/node lg-node absolute isolate text-xs flex flex-col contain-layout contain-style drop-shadow-xl drop-shadow-black/40 min-h-(--node-height) min-w-(--min-node-width) cursor-grab pointer-events-auto" data-node-id="test-node-123" style="--min-node-width: 225px; transform: translate(100px, 20px); z-index: 0; opacity: 1; --node-width: 200px; --node-height: 130px;" tabindex="0" > <div class="flex flex-1 flex-col bg-node-component-header-surface w-(--node-width) min-w-(--min-node-width) rounded-xl" data-testid="node-inner-wrapper" > <div class="relative flex flex-col items-center justify-center" > <node-header-stub collapsed="false" nodedata="[object Object]" pricebadges="" /> </div> <div class="relative" /> <div class="flex flex-1 flex-col gap-1 bg-component-node-background pt-1 pb-3 rounded-b-xl" data-testid="node-body-test-node-123" > <node-slots-stub nodedata="[object Object]" unified="false" /> <div class="flex h-5 w-full gap-2 px-2 text-muted-foreground mt-auto" > <div class="flex h-6 items-center justify-center overflow-clip rounded-full bg-component-node-widget-background" > <div class="flex min-w-max items-center gap-1 rounded-sm bg-node-component-surface px-1 py-0.5 text-xs h-6 first:pl-2 last:pr-2" style="color: currentcolor; background-color: transparent;" > #test-node-123 </div> </div> </div> </div>

Check failure on line 407 in src/renderer/extensions/vueNodes/components/LGraphNode.test.ts

View workflow job for this annotation

GitHub Actions / test

src/renderer/extensions/vueNodes/components/LGraphNode.test.ts > LGraphNode > Subgraph live preview promotion (incident-94 regression) > renders the live preview image on a subgraph node with a populated preview

TestingLibraryElementError: Unable to find an accessible element with the role "img" Here are the accessible roles: button: Name "g.enterSubgraph": <button class="relative inline-flex items-center justify-center gap-2 cursor-pointer touch-manipulation whitespace-nowrap appearance-none border-none font-inter transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([width]):not([height])]:size-4 [&_svg]:shrink-0 hover:bg-secondary-background-hover p-2 pointer-events-auto h-11 text-xs font-normal box-border w-full rounded-none bg-node-component-header-surface text-node-component-slot-text pt-8 pb-3 rounded-b-xl" data-testid="subgraph-enter-button" /> Name "g.resizeFromBottomRight": <div aria-label="g.resizeFromBottomRight" class="absolute h-5 w-5 opacity-0 pointer-events-auto focus-visible:outline focus-visible:outline-2 focus-visible:outline-white/40 touch-none -right-1 -bottom-1 cursor-se-resize group-hover/node:opacity-100" data-corner="SE" role="button" /> Name "g.resizeFromTopRight": <div aria-label="g.resizeFromTopRight" class="absolute h-5 w-5 opacity-0 pointer-events-auto focus-visible:outline focus-visible:outline-2 focus-visible:outline-white/40 touch-none -right-1 -top-1 cursor-ne-resize group-hover/node:opacity-100" data-corner="NE" role="button" /> Name "g.resizeFromBottomLeft": <div aria-label="g.resizeFromBottomLeft" class="absolute h-5 w-5 opacity-0 pointer-events-auto focus-visible:outline focus-visible:outline-2 focus-visible:outline-white/40 touch-none -left-1 -bottom-1 cursor-sw-resize group-hover/node:opacity-100" data-corner="SW" role="button" /> Name "g.resizeFromTopLeft": <div aria-label="g.resizeFromTopLeft" class="absolute h-5 w-5 opacity-0 pointer-events-auto focus-visible:outline focus-visible:outline-2 focus-visible:outline-white/40 touch-none -left-1 -top-1 cursor-nw-resize group-hover/node:opacity-100" data-corner="NW" role="button" /> -------------------------------------------------- Ignored nodes: comments, script, style <body> <div> <div class="group/node lg-node absolute isolate text-xs flex flex-col contain-layout contain-style drop-shadow-xl drop-shadow-black/40 min-h-(--node-height) min-w-(--min-node-width) cursor-grab pointer-events-auto" data-node-id="test-node-123" style="--min-node-width: 225px; transform: translate(100px, 20px); z-index: 0; opacity: 1; --node-width: 200px; --node-height: 130px;" tabindex="0" > <div class="flex flex-1 flex-col bg-node-component-header-surface w-(--node-width) min-w-(--min-node-width) rounded-xl" data-testid="node-inner-wrapper" > <div class="relative flex flex-col items-center justify-center" > <node-header-stub collapsed="false" nodedata="[object Object]" pricebadges="" /> </div> <div class="relative" /> <div class="flex flex-1 flex-col gap-1 bg-component-node-background pt-1 pb-3 rounded-b-xl" data-testid="node-body-test-node-123" > <node-slots-stub nodedata="[object Object]" unified="false" /> <div class="flex h-5 w-full gap-2 px-2 text-muted-foreground mt-auto" > <div class="flex h-6 items-center justify-center overflow-clip rounded-full bg-component-node-widget-background" > <div class="flex min-w-max items-center gap-1 rounded-sm bg-node-component-surface px-1 py-0.5 text-xs h-6 first:pl-2 last:pr-2" style="color: currentcolor; background-color: transparent;" > #test-node-123 </div> </div> </div> </div>
})
})
})
Loading