Comfy-Org / Comfy-Org/ComfyUI_frontend
Use OpenAPI-generated types for browser test mock data
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 699
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 490
Description
Browser tests currently construct API mock responses as untyped inline JSON literals in `route.fulfill()` calls. This makes mock data fragile — schema changes silently break tests without compile-time feedback.
## Problem
```ts
// releaseNotifications.spec.ts — no type checking
body: JSON.stringify([{ id: 1, project: 'comfyui', version: 'v0.3.44', ... }])
```
```ts
// AssetsHelper.ts — uses RawJobListItem but other mocks don't
body: JSON.stringify({ jobs: visibleJobs, pagination: { ... } })
```
## Existing infrastructure
- `packages/ingest-types/` — auto-generated from cloud `openapi.yaml` via `@hey-api/openapi-ts` (types + Zod schemas)
- `src/schemas/apiSchema.ts` — manual Zod schemas for ComfyUI Python backend endpoints (WS messages, execution results, settings)
- `src/schemas/nodeDefSchema.ts` — manual Zod for node definitions
- `generatedManagerTypes.ts` — auto-generated manager API types
The `openapi-ts.config.ts` excludes endpoints most commonly mocked in tests (`/api/jobs`, `/api/prompt`, `/api/queue`, `/api/settings`, `/api/object_info`) because they overlap with the Python backend and already have manual Zod schemas in `apiSchema.ts`.
## Proposed changes
1. **Update `docs/guidance/playwright.md`** — add guideline: API mock responses in `route.fulfill()` must use generated types or existing Zod-inferred types. No untyped inline JSON.
2. **Update `AGENTS.md`** — add rule under Testing Guidelines: "Use `src/schemas/` types and `packages/ingest-types` generated types when constructing mock API responses in browser tests."
3. **Refactor existing test mocks** to import and use the appropriate types:
- For cloud-only endpoints → `@comfyorg/ingest-types` generated types
- For Python backend endpoints (excluded from generation) → types inferred from manual Zod schemas in `apiSchema.ts`, `nodeDefSchema.ts`
4. **Consider adding typed fixture factories** for frequently mocked endpoints (releases, jobs, object_info) that enforce schema compliance at build time.
## Sub-issues
- [x] #10668 — Guideline + initial typed mock refactoring
- [ ] #10670 — Clean up dead QueueHelper
- [ ] #10671 — Expand typed factory pattern to more endpoints
- [ ] #10672 — Evaluate OpenAPI generation for excluded Python backend endpoints
- [ ] #10674 — Migrate `registry-types` from `openapi-typescript` to `@hey-api/openapi-ts` (enables Zod schema generation)
## Context
From Mar 27 2026 PR review session — action item for Christian to instruct agents to use schemas and types when writing browser tests.
┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-10656-Use-OpenAPI-generated-types-for-browser-test-mock-data-3316d73d365081c192f6f1536be0194e) by [Unito](https://www.unito.io)
Contributor guide
Assessment
This issue has not been assessed yet.