Comfy-Org / Comfy-Org/ComfyUI_frontend
browser_tests: Make jsonRoute generic and type mocked payloads with endpoint contracts
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 702
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 490
Description
## Summary
In `browser_tests/tests/dialogs/pricingTableDeepLink.spec.ts`, the `jsonRoute` helper currently accepts `body: unknown`, which erases response-shape validation for every mocked endpoint in the spec. This should be tightened so TypeScript catches contract drift between mock responses and the actual API schemas.
## Required Changes
1. Make `jsonRoute` generic:
```ts
function jsonRoute(body: T) { ... }
```
2. Type each mocked payload with its corresponding endpoint contract using the `satisfies` keyword, e.g.:
```ts
const featuresResponse = {
team_workspaces_enabled: true
} satisfies RemoteConfig
await page.route('**/api/features', (r) => r.fulfill(jsonRoute(featuresResponse)))
```
3. Apply the same pattern to all other `jsonRoute` call sites in the file, sourcing types from `packages/ingest-types`, `packages/registry-types`, `src/workbench/extensions/manager/types/generatedManagerTypes.ts`, or `src/schemas/` as applicable (per coding guidelines: "Type all API mock responses in `route.fulfill()` using generated types or schemas").
## Affected Files
- `browser_tests/tests/dialogs/pricingTableDeepLink.spec.ts` (lines 25-31 and all `jsonRoute` call sites)
## Rationale
Per the project coding guidelines, all API mock responses in `route.fulfill()` must be typed using generated types or schemas. Using `unknown` silently allows mock payloads to diverge from the real API contract, causing tests to pass against stale shapes.
## References
- PR: https://github.com/Comfy-Org/ComfyUI_frontend/pull/13001
- Review comment: https://github.com/Comfy-Org/ComfyUI_frontend/pull/13001#discussion_r3464340867
/cc @christian-byrne
Contributor guide
Assessment
This issue has not been assessed yet.