Comfy-Org / Comfy-Org/ComfyUI_frontend
test(assets-sidebar): mock API calls via OpenAPI spec and Playwright response mocking
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 699
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 490
Description
## Summary
During the review of PR #10616 (assets browser E2E tests), it was discussed that API calls in the Assets browser Playwright tests should be mocked **directly using the OpenAPI spec and Playwright's `page.route()` response mocking**, rather than relying on custom mock-data factories (`createMockJob`, `createMockJobs`, etc.).
## Motivation
- Using OpenAPI-spec-derived fixtures ensures mocked responses always conform to the actual API contract, catching shape mismatches early.
- Playwright's `page.route()` intercepts at the network level, making tests more realistic and less coupled to internal store/helper abstractions.
- Reduces maintenance burden when the API schema evolves — fixtures can be auto-generated from the spec.
## Proposed approach
1. Identify the relevant OpenAPI spec endpoints used by the Assets sidebar (e.g., job history, input files).
2. Generate or hand-write response fixtures that conform to those spec shapes.
3. Replace `comfyPage.assets.mockOutputHistory()` / `comfyPage.assets.mockInputFiles()` with `page.route()` intercepts returning spec-conformant JSON.
4. Optionally wire a script/CI step to validate mock fixtures against the live OpenAPI spec on schema changes.
## References
- PR: #10616
- Discussion comment: https://github.com/Comfy-Org/ComfyUI_frontend/pull/10616#discussion_r3003867841
- Requested by: @Myestery
┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-10636-test-assets-sidebar-mock-API-calls-via-OpenAPI-spec-and-Playwright-response-mocking-3316d73d365081a7b214eb704ef283bb) by [Unito](https://www.unito.io)
Contributor guide
Assessment
This issue has not been assessed yet.