test: resolve painter clear viewport timeout and harden triggerSerialization

- Replaces forced click bypass on painter clear button with native dispatchEvent to fix out-of-viewport timeouts
- Hardens triggerSerialization helper with explicit object existence checks and concrete error messages
This commit is contained in:
Kelly Yang
2026-04-08 20:27:36 -07:00
parent 28e595d5da
commit 217eeb13a6
2 changed files with 26 additions and 7 deletions

View File

@@ -1,5 +1,5 @@
import type { Locator, Page } from '@playwright/test'
import type { TestGraphAccess } from '../types/globals'
import type { TestGraphAccess } from '@e2e/types/globals'
export async function drawStroke(
page: Page,
@@ -36,12 +36,31 @@ export async function hasCanvasContent(canvas: Locator): Promise<boolean> {
export async function triggerSerialization(page: Page): Promise<void> {
await page.evaluate(async () => {
const graph = window.graph! as TestGraphAccess
const node = graph._nodes_by_id['1']
const widget = node.widgets?.find((w) => w.name === 'mask')
if (!widget?.serializeValue) {
throw new Error('mask widget with serializeValue not found on node 1')
const graph = window.graph as TestGraphAccess | undefined
if (!graph) {
throw new Error(
'Global window.graph is absent. Ensure workflow fixture is loaded.'
)
}
const node = graph._nodes_by_id?.['1']
if (!node) {
throw new Error(
'Target node with ID "1" not found in graph._nodes_by_id.'
)
}
const widget = node.widgets?.find((w) => w.name === 'mask')
if (!widget) {
throw new Error('Widget "mask" not found on target node 1.')
}
if (typeof widget.serializeValue !== 'function') {
throw new Error(
'mask widget on node 1 does not have a serializeValue function.'
)
}
await widget.serializeValue(node, 0)
})
}

View File

@@ -303,7 +303,7 @@ test.describe('Painter', { tag: '@widget' }, () => {
.toBe(true)
const clearButton = painterWidget.getByTestId('painter-clear-button')
await clearButton.click({ force: true })
await clearButton.dispatchEvent('click')
await expect
.poll(() => hasCanvasContent(canvas), {