Skip to content

Commit

Permalink
Update playwright test fixture (#1139)
Browse files Browse the repository at this point in the history
* Update playwright test fixture

* fix resolve

* nit

* Wait dialog close
  • Loading branch information
huchenlei authored Oct 7, 2024
1 parent 8c156cc commit cfa7639
Showing 1 changed file with 10 additions and 28 deletions.
38 changes: 10 additions & 28 deletions browser_tests/ComfyPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,16 +247,11 @@ class Topbar {
}

async saveWorkflow(workflowName: string) {
this.page.on('dialog', async (dialog) => {
await dialog.accept(workflowName)
})
const workflowMenuItem = await this.getMenuItem('Workflow')
workflowMenuItem.click()
await this.page.evaluate(() => {
return new Promise<number>(requestAnimationFrame)
})
const saveButton = await this.getMenuItem('Save')
await saveButton.click()
await this.triggerTopbarCommand(['Workflow', 'Save'])
await this.page.locator('.p-dialog-content input').fill(workflowName)
await this.page.keyboard.press('Enter')
// Wait for the dialog to close.
await this.page.waitForTimeout(300)
}

async triggerTopbarCommand(path: string[]) {
Expand All @@ -273,9 +268,11 @@ class Topbar {

for (let i = 1; i < path.length; i++) {
const commandName = path[i]
const menuItem = this.page.locator(
`.top-menubar .p-menubar-submenu .p-menubar-item:has-text("${commandName}")`
)
const menuItem = this.page
.locator(
`.top-menubar .p-menubar-submenu .p-menubar-item:has-text("${commandName}")`
)
.first()
await menuItem.waitFor({ state: 'visible' })
await menuItem.hover()

Expand All @@ -299,21 +296,6 @@ class ComfyMenu {
.nth(0)
}

async saveWorkflow(name: string) {
const acceptDialog = async (dialog) => {
await dialog.accept(name)
}
this.page.on('dialog', acceptDialog)

await this.saveButton.click()

// Wait a moment to ensure the dialog has been handled
await this.page.waitForTimeout(300)

// Remove the dialog listener
this.page.off('dialog', acceptDialog)
}

get nodeLibraryTab() {
return new NodeLibrarySidebarTab(this.page)
}
Expand Down

0 comments on commit cfa7639

Please sign in to comment.