Comfy-Org / Comfy-Org/ComfyUI_frontend
refactor(browser-tests): create shared pollBoundingBox helper to replace 100+ inline poll patterns
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 699
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 490
Description
## Background
While reviewing [PR #11408](https://github.com/Comfy-Org/ComfyUI_frontend/pull/11408#discussion_r3107735142), it was noted that the pattern of polling an async bounding box query property via `expect.poll` has proliferated to **102+ occurrences** across **37+ test files**, with no shared abstraction. This issue tracks auditing all call sites and replacing them with a typed helper.
## Pattern being replaced
The repeated inline pattern looks like:
```ts
await expect
.poll(async () => (await node.boundingBox())?.width)
.toBeGreaterThan(box.width)
```
Variants seen in the codebase:
- **Property access:** `(await locator.boundingBox())?.x`
- **Full box polling (null check):** `await locator.boundingBox()`
- **Derived computation:** `b => b.x + b.width` (inlined inside the poll callback)
## Affected files (non-exhaustive)
- `browser_tests/tests/vueNodes/interactions/node/resize.spec.ts`
- `browser_tests/tests/vueNodes/interactions/node/select.spec.ts`
- `browser_tests/tests/vueNodes/interactions/node/contextMenu.spec.ts`
- `browser_tests/tests/vueNodes/nodeStates/collapse.spec.ts`
- `browser_tests/tests/vueNodes/nodeStates/pin.spec.ts`
- `browser_tests/tests/selectionToolbox.spec.ts`
- `browser_tests/tests/collapsedNodeLinks.spec.ts`
- `browser_tests/tests/builderSaveFlow.spec.ts`
- `browser_tests/fixtures/helpers/SubgraphHelper.ts`
- `browser_tests/fixtures/helpers/Preview3DPipelineFixture.ts`
- ...and ~27 more files
## Proposed helper API
Create a shared utility (e.g. `browser_tests/fixtures/utils/boundingBoxHelpers.ts`) exporting something like:
```ts
import type { Locator } from '@playwright/test'
import { expect } from '@playwright/test'
type DOMRectKey = keyof Pick
/**
* Poll a single named property of a locator's bounding box.
* Returns the property value, or null if the bounding box is not available.
*/
export function pollBox(
locator: Locator,
prop: K
): Promise { ... }
/**
* Poll a derived value computed from a locator's bounding box.
* Returns null if the bounding box is not available.
*/
export function pollBoxDerived(
locator: Locator,
derive: (box: DOMRect) => T
): Promise { ... }
/**
* Poll the full bounding box object (useful for null-existence assertions).
*/
export function pollBoundingBox(locator: Locator): Promise { ... }
```
Usage at call sites:
```ts
await expect.poll(() => pollBox(node, 'width')).toBeGreaterThan(box.width)
await expect.poll(() => pollBoxDerived(node, (b) => b.x + b.width)).toBeCloseTo(anchorX, 0)
await expect.poll(() => pollBoundingBox(node)).not.toBeNull()
```
## Tasks
- [ ] Audit all 100+ `.poll(async ()` usages in `browser_tests/` and categorize by variant
- [ ] Design final helper API covering all variant use-cases with strong TypeScript types
- [ ] Implement helper in a shared fixture utility file
- [ ] Replace all call sites to use the new helper
- [ ] Verify tests still pass after refactor
## References
- PR: https://github.com/Comfy-Org/ComfyUI_frontend/pull/11408
- Comment: https://github.com/Comfy-Org/ComfyUI_frontend/pull/11408#discussion_r3107735142
┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-11434-refactor-browser-tests-create-shared-pollBoundingBox-helper-to-replace-100-inline--3486d73d365081869aa4dffaff8c28d5) by [Unito](https://www.unito.io)
Contributor guide
Assessment
This issue has not been assessed yet.