Comfy-Org / Comfy-Org/ComfyUI_frontend

test: Add helper for registering ComfyExtension hooks/callbacks in browser tests

Open
#10,626 0 comments 0 reactions 1 assignee Claimed by @christian-byrne View on GitHub
area:testing developer experience
Dominant language
TypeScript
Stars
2k
Forks
699
Avg merge
1d 7h
Merged PRs (30d)
490

Description

## Summary

When writing E2E regression tests that need to simulate extension behavior, tests currently must inline a full `window.app!.registerExtension({...})` call inside `page.evaluate()`. See the pattern introduced in PR #10623:

```ts
await comfyPage.page.evaluate(() => {
window.app!.registerExtension({
name: 'TestCheckStateDuringLoad',
afterConfigureGraph() {
// ...
}
})
})
```

As more tests adopt this pattern, it will be beneficial to introduce a reusable browser-test helper (e.g., on `ComfyPage` or a dedicated `ExtensionHelper`) that allows callers to declaratively register any `ComfyExtension` hook/callback without repeating the boilerplate evaluate wrapper.

## Proposed API (sketch)

```ts
// Possible surface on ComfyPage or a new ExtensionHelper fixture
await comfyPage.registerExtension({
name: 'MyTestExtension',
afterConfigureGraph() { ... },
// ...any other ComfyExtension hooks
})
```

## Motivation

- Reduces boilerplate across spec files.
- Provides a single place to handle serialization constraints (e.g., functions passed to `page.evaluate` must be serializable).
- Makes test intent clearer — callers express *what* hooks to register, not *how* to wire them into the page context.

## Context

- Tracking issue requested in: https://github.com/Comfy-Org/ComfyUI_frontend/pull/10623#discussion_r3002645765
- First usage / motivating example: https://github.com/Comfy-Org/ComfyUI_frontend/pull/10623
- Requested by: @christian-byrne

┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-10626-test-Add-helper-for-registering-ComfyExtension-hooks-callbacks-in-browser-tests-3306d73d365081b9bb7de5a2fb51f54f) by [Unito](https://www.unito.io)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.