Skip to content

Commit

Permalink
Add playwright undo tests (#638)
Browse files Browse the repository at this point in the history
  • Loading branch information
huchenlei authored Aug 26, 2024
1 parent f9ae5aa commit 03ac6ee
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
21 changes: 21 additions & 0 deletions browser_tests/ComfyPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
25 changes: 25 additions & 0 deletions browser_tests/interaction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
})
})

0 comments on commit 03ac6ee

Please sign in to comment.