From 5b6d1f5bdb6b42ceea7e1e0a55df547e120e3369 Mon Sep 17 00:00:00 2001 From: Alexander Brown <448862+DrJKL@users.noreply.github.com> Date: Sat, 31 Jan 2026 12:33:38 -0800 Subject: [PATCH] refactor: inject KeyboardHelper into ClipboardHelper Remove duplicated nextFrame and ctrlSend methods from ClipboardHelper by delegating to KeyboardHelper instead. Amp-Thread-ID: https://ampcode.com/threads/T-019c15b9-efed-72eb-b092-1e92a11f44e3 Co-authored-by: Amp --- browser_tests/fixtures/ComfyPage.ts | 2 +- .../fixtures/helpers/ClipboardHelper.ts | 23 +++++-------------- 2 files changed, 7 insertions(+), 18 deletions(-) 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) } }