Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions tests/integration/003-appWindow.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { expect } from '@playwright/test';

import { test } from './testExtensions';

test.describe('App Window', () => {
test('App window has title', async ({ app }) => {
const window = await app.firstWindow();
await expect(window).toHaveTitle('ComfyUI');
});

test('App quits when window is closed', async ({ app }) => {
const window = await app.firstWindow();

await window.close();
await app.app.waitForEvent('close');
});

test('beforeunload dialog should not block app quit with unsaved changes', async ({ installedApp }) => {
await installedApp.waitUntilLoaded();

// Create a workflow and add unsaved changes
await installedApp.createBlankWorkflow();
await installedApp.saveWorkflow();
await installedApp.addFirstNodeResult();

// Verify that closing with unsaved changes doesn't trigger beforeunload dialog
// (https://github.com/Comfy-Org/desktop/issues/688)
await installedApp.window.close({
runBeforeUnload: true,
});
await installedApp.window.waitForEvent('close');
});
});
15 changes: 0 additions & 15 deletions tests/integration/appWindow.spec.ts

This file was deleted.

17 changes: 17 additions & 0 deletions tests/integration/testInstallWizard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ export class TestInstallWizard {
readonly nextButton;
readonly cpuToggle;
readonly installLocationInput;
readonly installButton;

constructor(readonly window: Page) {
this.nextButton = this.getButton('Next');
this.getStartedButton = this.getButton('Get Started');
this.cpuToggle = this.window.locator('#cpu-mode');
this.installLocationInput = this.getInput('', true);
this.installButton = this.getButton('Install');
}

async clickNext() {
Expand All @@ -28,4 +30,19 @@ export class TestInstallWizard {
getInput(name: string, exact?: boolean) {
return this.window.getByRole('textbox', { name, exact });
}

async stepThroughOnboarding() {
await this.clickGetStarted();
await this.cpuToggle.click();
await this.clickNext();
await this.clickNext();
await this.clickNext();
await this.installButton.click();

// Wait for app to be ready
await this.window.waitForFunction(() => {
// @ts-expect-error window is not typed
return window['app'] && window['app'].extensionManager;
});
}
}
26 changes: 26 additions & 0 deletions tests/integration/testInstalledApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,30 @@ export class TestInstalledApp {
await expect(this.blockUi).not.toBeVisible();
}).toPass({ timeout, intervals: [500] });
}

/** Creates a new blank workflow */
async createBlankWorkflow() {
const newWorkflowButton = this.window.getByLabel('Create a new blank workflow');
await newWorkflowButton.click();
}

/** Saves the current workflow */
async saveWorkflow() {
await this.window.keyboard.press('Control+S');
await this.window.waitForSelector('#global-prompt', { state: 'visible' });
await this.window.keyboard.press('Enter');
await this.window.waitForSelector('#global-prompt', { state: 'hidden' });
}

/** Opens the node searchbox by double clicking on the canvas. */
async openNodeSearchbox() {
await this.window.mouse.dblclick(256, 256, { delay: 128 });
await this.window.waitForSelector('.p-autocomplete');
}

/** Opens the node searchbox and adds the first result to the graph. */
async addFirstNodeResult() {
await this.openNodeSearchbox();
await this.window.keyboard.press('Enter');
}
}
Loading