|
| 1 | +import { |
| 2 | + type ComfyPage, |
| 3 | + comfyExpect as expect, |
| 4 | + comfyPageFixture as test |
| 5 | +} from '../../../../fixtures/ComfyPage' |
| 6 | +import type { Position } from '../../../../fixtures/types' |
| 7 | + |
| 8 | +test.describe('Vue Node Moving', () => { |
| 9 | + test.beforeEach(async ({ comfyPage }) => { |
| 10 | + await comfyPage.setSetting('Comfy.VueNodes.Enabled', true) |
| 11 | + await comfyPage.vueNodes.waitForNodes() |
| 12 | + }) |
| 13 | + |
| 14 | + const getLoadCheckpointHeaderPos = async (comfyPage: ComfyPage) => { |
| 15 | + const loadCheckpointHeaderPos = await comfyPage.page |
| 16 | + .getByText('Load Checkpoint') |
| 17 | + .boundingBox() |
| 18 | + |
| 19 | + if (!loadCheckpointHeaderPos) |
| 20 | + throw new Error('Load Checkpoint header not found') |
| 21 | + |
| 22 | + return loadCheckpointHeaderPos |
| 23 | + } |
| 24 | + |
| 25 | + const expectPosChanged = async (pos1: Position, pos2: Position) => { |
| 26 | + const diffX = Math.abs(pos2.x - pos1.x) |
| 27 | + const diffY = Math.abs(pos2.y - pos1.y) |
| 28 | + expect(diffX).toBeGreaterThan(0) |
| 29 | + expect(diffY).toBeGreaterThan(0) |
| 30 | + } |
| 31 | + |
| 32 | + test('should allow moving nodes by dragging', async ({ comfyPage }) => { |
| 33 | + const loadCheckpointHeaderPos = await getLoadCheckpointHeaderPos(comfyPage) |
| 34 | + await comfyPage.dragAndDrop(loadCheckpointHeaderPos, { |
| 35 | + x: 256, |
| 36 | + y: 256 |
| 37 | + }) |
| 38 | + |
| 39 | + const newHeaderPos = await getLoadCheckpointHeaderPos(comfyPage) |
| 40 | + await expectPosChanged(loadCheckpointHeaderPos, newHeaderPos) |
| 41 | + |
| 42 | + await expect(comfyPage.canvas).toHaveScreenshot('vue-node-moved-node.png') |
| 43 | + }) |
| 44 | + |
| 45 | + test('@mobile should allow moving nodes by dragging on touch devices', async ({ |
| 46 | + comfyPage |
| 47 | + }) => { |
| 48 | + // Disable minimap (gets in way of the node on small screens) |
| 49 | + await comfyPage.setSetting('Comfy.Minimap.Visible', false) |
| 50 | + |
| 51 | + const loadCheckpointHeaderPos = await getLoadCheckpointHeaderPos(comfyPage) |
| 52 | + await comfyPage.panWithTouch( |
| 53 | + { |
| 54 | + x: 64, |
| 55 | + y: 64 |
| 56 | + }, |
| 57 | + loadCheckpointHeaderPos |
| 58 | + ) |
| 59 | + |
| 60 | + const newHeaderPos = await getLoadCheckpointHeaderPos(comfyPage) |
| 61 | + await expectPosChanged(loadCheckpointHeaderPos, newHeaderPos) |
| 62 | + |
| 63 | + await expect(comfyPage.canvas).toHaveScreenshot( |
| 64 | + 'vue-node-moved-node-touch.png' |
| 65 | + ) |
| 66 | + }) |
| 67 | +}) |
0 commit comments