From 03ac6eea19c4472ab49e1c998ffa9a98d2db425c Mon Sep 17 00:00:00 2001 From: Chenlei Hu Date: Mon, 26 Aug 2024 10:47:37 -0400 Subject: [PATCH] Add playwright undo tests (#638) --- browser_tests/ComfyPage.ts | 21 +++++++++++++++++++++ browser_tests/interaction.spec.ts | 25 +++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/browser_tests/ComfyPage.ts b/browser_tests/ComfyPage.ts index 6413edf73..aa02583b2 100644 --- a/browser_tests/ComfyPage.ts +++ b/browser_tests/ComfyPage.ts @@ -413,6 +413,27 @@ export class ComfyPage { await this.nextFrame() } + async ctrlZ() { + await this.page.keyboard.down('Control') + await this.page.keyboard.press('KeyZ') + await this.page.keyboard.up('Control') + await this.nextFrame() + } + + async ctrlArrowUp() { + await this.page.keyboard.down('Control') + await this.page.keyboard.press('ArrowUp') + await this.page.keyboard.up('Control') + await this.nextFrame() + } + + async ctrlArrowDown() { + await this.page.keyboard.down('Control') + await this.page.keyboard.press('ArrowDown') + await this.page.keyboard.up('Control') + await this.nextFrame() + } + async closeMenu() { await this.page.click('button.comfy-close-menu-btn') await this.nextFrame() diff --git a/browser_tests/interaction.spec.ts b/browser_tests/interaction.spec.ts index 0e533119a..42d8a7df6 100644 --- a/browser_tests/interaction.spec.ts +++ b/browser_tests/interaction.spec.ts @@ -217,3 +217,28 @@ test.describe('Canvas Interaction', () => { await expect(comfyPage.canvas).toHaveScreenshot('panned-back-to-one.png') }) }) + +test.describe('Widget Interaction', () => { + test('Undo text input', async ({ comfyPage }) => { + const textBox = comfyPage.widgetTextBox + await textBox.click() + await textBox.fill('') + await expect(textBox).toHaveValue('') + await textBox.fill('Hello World') + await expect(textBox).toHaveValue('Hello World') + await comfyPage.ctrlZ() + await expect(textBox).toHaveValue('') + }) + + test('Undo attention edit', async ({ comfyPage }) => { + const textBox = comfyPage.widgetTextBox + await textBox.click() + await textBox.fill('1girl') + await expect(textBox).toHaveValue('1girl') + await textBox.selectText() + await comfyPage.ctrlArrowUp() + await expect(textBox).toHaveValue('(1girl:1.1)') + await comfyPage.ctrlZ() + await expect(textBox).toHaveValue('1girl') + }) +})