Update playwright test fixture (#1139)

* Update playwright test fixture

* fix resolve

* nit

* Wait dialog close
This commit is contained in:
Chenlei Hu
2024-10-06 21:21:55 -04:00
committed by GitHub
parent 8c156cc651
commit cfa763962e

View File

@@ -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[]) {
@@ -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()
@@ -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)
}