Files
ComfyUI_frontend/browser_tests/fixtures/helpers/KeyboardHelper.ts
jaeone94 4ded224173 test: add regression for collapsed bypass toggle, drive via user actions
Add two E2E tests covering the stale collapsedSize cache bug fixed in
2693ec256: toggling bypass on a collapsed node (which changes body width
via the Bypassed badge) previously left the selection bounding box at
the pre-toggle width.

Switch the existing Vue-mode and legacy-mode selection bounding box
tests from programmatic NodeReference.setCollapsed to the Alt+C
keyboard shortcut. Since the keybinding is mode-agnostic, the same
user-action path now drives both modes and removes the divergence
between DOM-driven Vue tests and programmatic legacy tests.

Add KeyboardHelper.collapse() (Alt+C) next to the existing bypass()
(Ctrl+B) so the shortcut has a discoverable helper. Drop the unused
NodeReference.setCollapsed helper introduced earlier in this PR.
2026-04-15 16:18:07 +09:00

59 lines
1.5 KiB
TypeScript

import type { Locator, Page } from '@playwright/test'
export class KeyboardHelper {
constructor(
private readonly page: Page,
private readonly canvas: Locator
) {}
private async nextFrame(): Promise<void> {
await this.page.evaluate(() => new Promise<number>(requestAnimationFrame))
}
async ctrlSend(
keyToPress: string,
locator: Locator | null = this.canvas
): Promise<void> {
const target = locator ?? this.page.keyboard
await target.press(`Control+${keyToPress}`)
await this.nextFrame()
}
async altSend(
keyToPress: string,
locator: Locator | null = this.canvas
): Promise<void> {
const target = locator ?? this.page.keyboard
await target.press(`Alt+${keyToPress}`)
await this.nextFrame()
}
async selectAll(locator?: Locator | null): Promise<void> {
await this.ctrlSend('KeyA', locator)
}
async bypass(locator?: Locator | null): Promise<void> {
await this.ctrlSend('KeyB', locator)
}
async collapse(locator?: Locator | null): Promise<void> {
await this.altSend('KeyC', locator)
}
async undo(locator?: Locator | null): Promise<void> {
await this.ctrlSend('KeyZ', locator)
}
async redo(locator?: Locator | null): Promise<void> {
await this.ctrlSend('KeyY', locator)
}
async moveUp(locator?: Locator | null): Promise<void> {
await this.ctrlSend('ArrowUp', locator)
}
async moveDown(locator?: Locator | null): Promise<void> {
await this.ctrlSend('ArrowDown', locator)
}
}