Dom widget playwright tests (#540)

* gitignore win32 browser_test files

just so i can local dev with playwright without git cluttering up

* experimental add test for dom widget node toggle open/closed

* Update test expectations [skip ci]

* vs code extension lied to me, manually fix loc

* Update test expectations [skip ci]

* okay that time was my fault

* Update test expectations [skip ci]

* yknow what dont expect exactly default after actually

* Update test expectations [skip ci]

* test for multiple far panning

* Update test expectations [skip ci]

* oops, flip that

* Update test expectations [skip ci]

* more stable pan coords

* Update test expectations [skip ci]

* 'move' is not strictly relative, so compensate accordingly

* Update test expectations [skip ci]

* test to zoom very far out

* Update test expectations [skip ci]

* add hackaround for node search menu popup

* Update test expectations [skip ci]

* make zoom work better

* Update test expectations [skip ci]

* fix preexisting typo

this function is never called so it's fine

* dom widget toggle needs a delay

otherwise it's a double click

* Update test expectations [skip ci]

---------

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Alex "mcmonkey" Goodwin
2024-08-19 17:54:07 -07:00
committed by GitHub
parent c227a8af9a
commit 339e201920
14 changed files with 59 additions and 6 deletions

1
.gitignore vendored
View File

@@ -34,6 +34,7 @@ tests-ui/workflows/examples
/playwright-report/
/blob-report/
/playwright/.cache/
browser_tests/*/*-win32.png
.env

View File

@@ -185,7 +185,7 @@ export class ComfyPage {
)
}
async realod() {
async reload() {
await this.page.reload({ timeout: 15000 })
await this.setup()
}
@@ -200,6 +200,10 @@ export class ComfyPage {
})
}
async delay(ms: number) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async loadWorkflow(workflowName: string) {
await this.workflowUploadInput.setInputFiles(
`./browser_tests/assets/${workflowName}.json`
@@ -226,6 +230,16 @@ export class ComfyPage {
await this.nextFrame()
}
async clickTextEncodeNodeToggler() {
await this.canvas.click({
position: {
x: 430,
y: 171
}
})
await this.nextFrame()
}
async clickTextEncodeNode2() {
await this.canvas.click({
position: {
@@ -295,16 +309,22 @@ export class ComfyPage {
await this.nextFrame()
}
async zoom(deltaY: number) {
async zoom(deltaY: number, steps: number = 1) {
await this.page.mouse.move(10, 10)
await this.page.mouse.wheel(0, deltaY)
for (let i = 0; i < steps; i++) {
await this.page.mouse.wheel(0, deltaY)
}
await this.nextFrame()
}
async pan(offset: Position) {
await this.page.mouse.move(10, 10)
async pan(offset: Position, safeSpot?: Position) {
safeSpot = safeSpot || { x: 10, y: 10 }
await this.page.mouse.move(safeSpot.x, safeSpot.y)
await this.page.mouse.down()
await this.page.mouse.move(offset.x, offset.y)
// TEMPORARY HACK: Multiple pans open the search menu, so cheat and keep it closed.
// TODO: Fix that (double-click at not-the-same-coordinations should not open the menu)
await this.page.keyboard.press('Escape')
await this.page.mouse.move(offset.x + safeSpot.x, offset.y + safeSpot.y)
await this.page.mouse.up()
await this.nextFrame()
}

View File

@@ -100,6 +100,15 @@ test.describe('Node Interaction', () => {
'batch-disconnect-links-disconnected.png'
)
})
test('Can toggle dom widget node open/closed', async ({ comfyPage }) => {
await expect(comfyPage.canvas).toHaveScreenshot('default.png')
await comfyPage.clickTextEncodeNodeToggler()
await expect(comfyPage.canvas).toHaveScreenshot('text-encode-toggled-off.png')
await comfyPage.delay(1000)
await comfyPage.clickTextEncodeNodeToggler()
await expect(comfyPage.canvas).toHaveScreenshot('text-encode-toggled-back-open.png')
})
})
test.describe('Canvas Interaction', () => {
@@ -110,6 +119,13 @@ test.describe('Canvas Interaction', () => {
await expect(comfyPage.canvas).toHaveScreenshot('zoomed-out.png')
})
test('Can zoom very far out', async ({ comfyPage }) => {
await comfyPage.zoom(100, 12)
await expect(comfyPage.canvas).toHaveScreenshot('zoomed-very-far-out.png')
await comfyPage.zoom(-100, 12)
await expect(comfyPage.canvas).toHaveScreenshot('zoomed-back-in.png')
})
test('Can zoom in/out with ctrl+shift+vertical-drag', async ({
comfyPage
}) => {
@@ -131,4 +147,20 @@ test.describe('Canvas Interaction', () => {
await comfyPage.pan({ x: 200, y: 200 })
await expect(comfyPage.canvas).toHaveScreenshot('panned.png')
})
test('Can pan very far and back', async ({ comfyPage }) => {
// intentionally slice the edge of where the clip text encode dom widgets are
await comfyPage.pan({ x: -800, y: -300 }, { x: 1000, y: 10 })
await expect(comfyPage.canvas).toHaveScreenshot('panned-step-one.png')
await comfyPage.pan({ x: -200, y: 0 }, { x: 1000, y: 10 })
await expect(comfyPage.canvas).toHaveScreenshot('panned-step-two.png')
await comfyPage.pan({ x: -2200, y: -2200 }, { x: 1000, y: 10 })
await expect(comfyPage.canvas).toHaveScreenshot('panned-far-away.png')
await comfyPage.pan({ x: 2200, y: 2200 }, { x: 1000, y: 10 })
await expect(comfyPage.canvas).toHaveScreenshot('panned-back-from-far.png')
await comfyPage.pan({ x: 200, y: 0 }, { x: 1000, y: 10 })
await expect(comfyPage.canvas).toHaveScreenshot('panned-back-to-two.png')
await comfyPage.pan({ x: 800, y: 300 }, { x: 1000, y: 10 })
await expect(comfyPage.canvas).toHaveScreenshot('panned-back-to-one.png')
})
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 75 KiB

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB