diff --git a/browser_tests/assets/nodes/load_image_with_ksampler.json b/browser_tests/assets/nodes/load_image_with_ksampler.json new file mode 100644 index 0000000000..fcd5dab906 --- /dev/null +++ b/browser_tests/assets/nodes/load_image_with_ksampler.json @@ -0,0 +1,47 @@ +{ + "last_node_id": 2, + "last_link_id": 0, + "nodes": [ + { + "id": 1, + "type": "LoadImage", + "pos": [50, 50], + "size": [315, 314], + "flags": {}, + "order": 0, + "mode": 0, + "inputs": [], + "outputs": [ + { "name": "IMAGE", "type": "IMAGE", "links": null }, + { "name": "MASK", "type": "MASK", "links": null } + ], + "properties": { "Node name for S&R": "LoadImage" }, + "widgets_values": ["example.png", "image"] + }, + { + "id": 2, + "type": "KSampler", + "pos": [500, 50], + "size": [315, 262], + "flags": {}, + "order": 1, + "mode": 0, + "inputs": [ + { "name": "model", "type": "MODEL", "link": null }, + { "name": "positive", "type": "CONDITIONING", "link": null }, + { "name": "negative", "type": "CONDITIONING", "link": null }, + { "name": "latent_image", "type": "LATENT", "link": null } + ], + "outputs": [{ "name": "LATENT", "type": "LATENT", "links": null }], + "properties": { "Node name for S&R": "KSampler" }, + "widgets_values": [0, "randomize", 20, 8, "euler", "normal", 1] + } + ], + "links": [], + "groups": [], + "config": {}, + "extra": { + "ds": { "offset": [0, 0], "scale": 1 } + }, + "version": 0.4 +} diff --git a/browser_tests/tests/imagePastePriority.spec.ts b/browser_tests/tests/imagePastePriority.spec.ts new file mode 100644 index 0000000000..9bbab8634c --- /dev/null +++ b/browser_tests/tests/imagePastePriority.spec.ts @@ -0,0 +1,58 @@ +import { expect } from '@playwright/test' + +import { comfyPageFixture as test } from '../fixtures/ComfyPage' + +test.describe( + 'Image paste priority over stale node metadata', + { tag: ['@node'] }, + () => { + test('Should not paste copied node when a LoadImage node is selected and clipboard has stale node metadata', async ({ + comfyPage + }) => { + await comfyPage.workflow.loadWorkflow('nodes/load_image_with_ksampler') + + const initialCount = await comfyPage.nodeOps.getGraphNodesCount() + expect(initialCount).toBe(2) + + // Copy the KSampler node (puts data-metadata in clipboard) + const ksamplerNodes = + await comfyPage.nodeOps.getNodeRefsByType('KSampler') + await ksamplerNodes[0].copy() + + // Select the LoadImage node + const loadImageNodes = + await comfyPage.nodeOps.getNodeRefsByType('LoadImage') + await loadImageNodes[0].click('title') + + // Simulate pasting when clipboard has stale node metadata (text/html + // with data-metadata) but no image file items. This replicates the bug + // scenario: user copied a node, then copied a web image (which replaces + // clipboard files but may leave stale text/html with node metadata). + await comfyPage.page.evaluate(() => { + const nodeData = { nodes: [{ type: 'KSampler', id: 99 }] } + const base64 = btoa(JSON.stringify(nodeData)) + const html = + '