Files
ComfyUI_frontend/browser_tests/fixtures/data
Christian Byrne 83f4e7060a test(infra): AssetHelper with builder pattern + deterministic fixtures (#10545)
## What

Adds `AssetHelper` — a builder-pattern helper for mocking asset-related
API endpoints in Playwright E2E tests, plus deterministic fixture data.

## Why

12+ asset-related API endpoints need mocking for asset browser tests
(PNL-02), cloud dialog testing (DLG-08), and other asset-dependent E2E
scenarios. Random mock data from existing `createMockAssets()` is
unsuitable for deterministic E2E assertions.

## What's included

### `AssetHelper.ts` (307 LOC)
- Fluent builder API: `assetHelper.withModels(3).withImages(5).mock()`
- Stateful mock store (Map) for upload→verify→delete flows
- Endpoint coverage: GET/POST/PUT/DELETE `/assets`, download progress
- `mockError()` for error state testing
- `clearMocks()` cleanup matching QueueHelper/FeatureFlagHelper pattern

### `assetFixtures.ts` (304 LOC)
- 11 stable named constants (checkpoints, loras, VAE, embedding, inputs,
outputs)
- Factory functions: `generateModels()`, `generateInputFiles()`,
`generateOutputAssets()`
- Fixed IDs/dates/sizes — no randomness, safe for screenshot comparisons

### ComfyPage integration
- Available as `comfyPage.assets` in all tests

## Testing
- TypeScript compiles clean
- Follows existing QueueHelper/FeatureFlagHelper conventions

## Unblocks
- PNL-02: Asset browser tests (@Jaewon Yoon)
- DLG-08: Assets modal / cloud dialog testing

Part of: Test Coverage Q2 Overhaul

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-10545-test-infra-AssetHelper-with-builder-pattern-deterministic-fixtures-32f6d73d365081d3985ef079ff3dbede)
by [Unito](https://www.unito.io)

---------

Co-authored-by: GitHub Action <action@github.com>
2026-04-07 14:23:36 -07:00
..

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: comfyPageFixture navigates to the app during setup(), before the test body runs. Routes must be registered before navigation to intercept initial page-load requests. Set up routes in a custom fixture or test.beforeEach that runs before comfyPage.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

  1. Locate the generated type in packages/ingest-types or Zod schema in src/schemas/ for the endpoint you need.
  2. Create a new .ts file here that imports and satisfies the corresponding TypeScript type.
  3. Keep values realistic but stable — avoid dates, random IDs, or values that would cause test flakiness.