diff --git a/browser_tests/fixtures/ComfyPage.ts b/browser_tests/fixtures/ComfyPage.ts index 311669554..9696fe4f6 100644 --- a/browser_tests/fixtures/ComfyPage.ts +++ b/browser_tests/fixtures/ComfyPage.ts @@ -223,7 +223,7 @@ export class ComfyPage { this.nodeOps = new NodeOperationsHelper(this) this.settings = new SettingsHelper(page) this.keyboard = new KeyboardHelper(page, this.canvas) - this.clipboard = new ClipboardHelper(page, this.canvas) + this.clipboard = new ClipboardHelper(this.keyboard, this.canvas) this.workflow = new WorkflowHelper(this) this.contextMenu = new ContextMenu(page) } diff --git a/browser_tests/fixtures/helpers/ClipboardHelper.ts b/browser_tests/fixtures/helpers/ClipboardHelper.ts index e0c53b918..89e4b4603 100644 --- a/browser_tests/fixtures/helpers/ClipboardHelper.ts +++ b/browser_tests/fixtures/helpers/ClipboardHelper.ts @@ -1,29 +1,18 @@ -import type { Locator, Page } from '@playwright/test' +import type { Locator } from '@playwright/test' + +import type { KeyboardHelper } from './KeyboardHelper' export class ClipboardHelper { constructor( - private readonly page: Page, + private readonly keyboard: KeyboardHelper, private readonly canvas: Locator ) {} - private async nextFrame(): Promise { - await this.page.evaluate(() => new Promise(requestAnimationFrame)) - } - - private async ctrlSend( - keyToPress: string, - locator: Locator | null = this.canvas - ): Promise { - const target = locator ?? this.page.keyboard - await target.press(`Control+${keyToPress}`) - await this.nextFrame() - } - async copy(locator?: Locator | null): Promise { - await this.ctrlSend('KeyC', locator ?? this.canvas) + await this.keyboard.ctrlSend('KeyC', locator ?? this.canvas) } async paste(locator?: Locator | null): Promise { - await this.ctrlSend('KeyV', locator ?? this.canvas) + await this.keyboard.ctrlSend('KeyV', locator ?? this.canvas) } }