mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 06:20:11 +00:00
## Summary Add deterministic mock data fixtures for browser tests so they can use `page.route()` to intercept API calls without depending on a live backend. ## Changes - **`browser_tests/fixtures/data/nodeDefinitions.ts`** — Mock `ComfyNodeDef` objects for KSampler, CheckpointLoaderSimple, and CLIPTextEncode - **`browser_tests/fixtures/data/systemStats.ts`** — Mock `SystemStats` with realistic RTX 4090 GPU info - **`browser_tests/fixtures/data/README.md`** — Usage guide for `page.route()` interception All fixtures are typed against the Zod schemas in `src/schemas/` and pass `pnpm typecheck:browser`. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-10662-test-add-mock-data-fixtures-for-backend-API-responses-3316d73d3650813ea5c8c1faa215db63) by [Unito](https://www.unito.io) --------- Co-authored-by: dante01yoon <bunggl@naver.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: GitHub Action <action@github.com>
1.3 KiB
1.3 KiB
Mock Data Fixtures
Deterministic mock data for browser (Playwright) tests. Each fixture
exports typed objects that conform to generated types from
packages/ingest-types or Zod schemas in src/schemas/.
Usage with page.route()
Note:
comfyPageFixturenavigates to the app duringsetup(), before the test body runs. Routes must be registered before navigation to intercept initial page-load requests. Set up routes in a custom fixture ortest.beforeEachthat runs beforecomfyPage.setup().
import { createMockNodeDefinitions } from '../fixtures/data/nodeDefinitions'
import { mockSystemStats } from '../fixtures/data/systemStats'
// Extend the base set with test-specific nodes
const nodeDefs = createMockNodeDefinitions({
MyCustomNode: {
/* ... */
}
})
await page.route('**/api/object_info', (route) =>
route.fulfill({ json: nodeDefs })
)
await page.route('**/api/system_stats', (route) =>
route.fulfill({ json: mockSystemStats })
)
Adding new fixtures
- Locate the generated type in
packages/ingest-typesor Zod schema insrc/schemas/for the endpoint you need. - Create a new
.tsfile here that imports and satisfies the corresponding TypeScript type. - Keep values realistic but stable — avoid dates, random IDs, or values that would cause test flakiness.