diff --git a/browser_tests/fixtures/ComfyPage.ts b/browser_tests/fixtures/ComfyPage.ts index 4e425bdcc..abf5feebb 100644 --- a/browser_tests/fixtures/ComfyPage.ts +++ b/browser_tests/fixtures/ComfyPage.ts @@ -737,6 +737,19 @@ export class ComfyPage { ) } + async confirmDialog(prompt: string, text: string = 'Yes') { + const modal = this.page.locator( + `.comfy-modal-content:has-text("${prompt}")` + ) + await expect(modal).toBeVisible() + await modal + .locator('.comfyui-button', { + hasText: text + }) + .click() + await expect(modal).toBeHidden() + } + async convertAllNodesToGroupNode(groupNodeName: string) { this.page.on('dialog', async (dialog) => { await dialog.accept(groupNodeName) diff --git a/browser_tests/fixtures/components/SidebarTab.ts b/browser_tests/fixtures/components/SidebarTab.ts index 76b74c6dc..836694be9 100644 --- a/browser_tests/fixtures/components/SidebarTab.ts +++ b/browser_tests/fixtures/components/SidebarTab.ts @@ -103,6 +103,12 @@ export class WorkflowsSidebarTab extends SidebarTab { .allInnerTexts() } + async getActiveWorkflowName() { + return await this.page + .locator('.comfyui-workflows-open .p-tree-node-selected .node-label') + .innerText() + } + async getTopLevelSavedWorkflowNames() { return await this.page .locator('.comfyui-workflows-browse .node-label') diff --git a/browser_tests/menu.spec.ts b/browser_tests/menu.spec.ts index 7349df3cd..3b956a04f 100644 --- a/browser_tests/menu.spec.ts +++ b/browser_tests/menu.spec.ts @@ -379,7 +379,9 @@ test.describe('Menu', () => { // Open the sidebar const tab = comfyPage.menu.workflowsTab await tab.open() + }) + test.afterEach(async ({ comfyPage }) => { await comfyPage.setupWorkflowsDirectory({}) }) @@ -450,6 +452,43 @@ test.describe('Menu', () => { ).toEqual(['*Unsaved Workflow.json', 'workflow3.json', 'workflow4.json']) }) + test('Can save workflow as with same name', async ({ comfyPage }) => { + await comfyPage.menu.topbar.saveWorkflow('workflow5.json') + expect( + await comfyPage.menu.workflowsTab.getOpenedWorkflowNames() + ).toEqual(['workflow5.json']) + + await comfyPage.menu.topbar.saveWorkflowAs('workflow5.json') + await comfyPage.confirmDialog('Overwrite existing file?', 'Yes') + expect( + await comfyPage.menu.workflowsTab.getOpenedWorkflowNames() + ).toEqual(['workflow5.json']) + }) + + test('Can overwrite other workflows with save as', async ({ + comfyPage + }) => { + const topbar = comfyPage.menu.topbar + await topbar.saveWorkflow('workflow1.json') + await topbar.saveWorkflowAs('workflow2.json') + expect( + await comfyPage.menu.workflowsTab.getOpenedWorkflowNames() + ).toEqual(['workflow1.json', 'workflow2.json']) + expect(await comfyPage.menu.workflowsTab.getActiveWorkflowName()).toEqual( + 'workflow2.json' + ) + + await topbar.saveWorkflowAs('workflow1.json') + await comfyPage.confirmDialog('Overwrite existing file?', 'Yes') + // The old workflow1.json should be deleted and the new one should be saved. + expect( + await comfyPage.menu.workflowsTab.getOpenedWorkflowNames() + ).toEqual(['workflow2.json', 'workflow1.json']) + expect(await comfyPage.menu.workflowsTab.getActiveWorkflowName()).toEqual( + 'workflow1.json' + ) + }) + test('Does not report warning when switching between opened workflows', async ({ comfyPage }) => { @@ -475,7 +514,7 @@ test.describe('Menu', () => { `tempWorkflow-${test.info().title}` ) const closeButton = comfyPage.page.locator( - '.comfyui-workflows-open .p-button-icon.pi-times' + '.comfyui-workflows-open .close-workflow-button' ) await closeButton.click() expect( diff --git a/src/components/sidebar/tabs/WorkflowsSidebarTab.vue b/src/components/sidebar/tabs/WorkflowsSidebarTab.vue index 21dae8f44..3f4ad7048 100644 --- a/src/components/sidebar/tabs/WorkflowsSidebarTab.vue +++ b/src/components/sidebar/tabs/WorkflowsSidebarTab.vue @@ -54,6 +54,7 @@