From cfa763962edc65c91fe5650fd4237e21f419d931 Mon Sep 17 00:00:00 2001 From: Chenlei Hu Date: Sun, 6 Oct 2024 21:21:55 -0400 Subject: [PATCH] Update playwright test fixture (#1139) * Update playwright test fixture * fix resolve * nit * Wait dialog close --- browser_tests/ComfyPage.ts | 38 ++++++++++---------------------------- 1 file changed, 10 insertions(+), 28 deletions(-) diff --git a/browser_tests/ComfyPage.ts b/browser_tests/ComfyPage.ts index 5b08c456e..c30143ceb 100644 --- a/browser_tests/ComfyPage.ts +++ b/browser_tests/ComfyPage.ts @@ -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(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) }