From 24dd8dec4ab474ba603ee71ef18fee2c15227df7 Mon Sep 17 00:00:00 2001 From: huchenlei Date: Tue, 5 Nov 2024 10:48:33 -0500 Subject: [PATCH] Add playwright test --- browser_tests/fixtures/components/Topbar.ts | 8 ++++++++ browser_tests/menu.spec.ts | 13 +++++++++++++ 2 files changed, 21 insertions(+) diff --git a/browser_tests/fixtures/components/Topbar.ts b/browser_tests/fixtures/components/Topbar.ts index fc0692b6..bc64fea1 100644 --- a/browser_tests/fixtures/components/Topbar.ts +++ b/browser_tests/fixtures/components/Topbar.ts @@ -36,6 +36,14 @@ export class Topbar { await this.page.waitForTimeout(300) } + async saveWorkflowAs(workflowName: string) { + await this.triggerTopbarCommand(['Workflow', 'Save As']) + 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[]) { if (path.length < 2) { throw new Error('Path is too short') diff --git a/browser_tests/menu.spec.ts b/browser_tests/menu.spec.ts index e5abc5b3..9f00c7c1 100644 --- a/browser_tests/menu.spec.ts +++ b/browser_tests/menu.spec.ts @@ -411,6 +411,19 @@ test.describe('Menu', () => { ) }) + test('Can save workflow as', async ({ comfyPage }) => { + await comfyPage.menu.workflowsTab.newBlankWorkflowButton.click() + await comfyPage.menu.topbar.saveWorkflowAs('workflow3.json') + expect( + await comfyPage.menu.workflowsTab.getOpenedWorkflowNames() + ).toEqual(['*Unsaved Workflow.json', 'workflow3.json']) + + await comfyPage.menu.topbar.saveWorkflowAs('workflow4.json') + expect( + await comfyPage.menu.workflowsTab.getOpenedWorkflowNames() + ).toEqual(['*Unsaved Workflow.json', 'workflow3.json', 'workflow4.json']) + }) + test('Does not report warning when switching between opened workflows', async ({ comfyPage }) => {