mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 14:30:41 +00:00
fix: remove section/HR comments and resolve duplicate assets property
Remove all section/HR comment dividers from assetFixtures.ts and AssetHelper.ts. Rename AssetHelper property to assetApi to avoid conflict with existing AssetsHelper. Wire clearMocks() into fixture teardown. Addresses review feedback: https://github.com/Comfy-Org/ComfyUI_frontend/pull/10545#discussion_r3005416403 https://github.com/Comfy-Org/ComfyUI_frontend/pull/10545#discussion_r3003581474
This commit is contained in:
@@ -1,7 +1,4 @@
|
||||
import type { Asset } from '@comfyorg/ingest-types'
|
||||
|
||||
// ─── Factory Helpers ───────────────────────────────────────────────────────────
|
||||
|
||||
function createModelAsset(overrides: Partial<Asset> = {}): Asset {
|
||||
return {
|
||||
id: 'test-model-001',
|
||||
@@ -50,9 +47,6 @@ function createOutputAsset(overrides: Partial<Asset> = {}): Asset {
|
||||
...overrides
|
||||
}
|
||||
}
|
||||
|
||||
// ─── Stable Fixtures (deterministic for screenshot tests) ──────────────────────
|
||||
|
||||
export const STABLE_CHECKPOINT: Asset = createModelAsset({
|
||||
id: 'test-checkpoint-001',
|
||||
name: 'sd_xl_base_1.0.safetensors',
|
||||
@@ -181,9 +175,6 @@ export const STABLE_OUTPUT_2: Asset = createOutputAsset({
|
||||
created_at: '2025-03-10T12:05:00Z',
|
||||
updated_at: '2025-03-10T12:05:00Z'
|
||||
})
|
||||
|
||||
// ─── Preset Collections ────────────────────────────────────────────────────────
|
||||
|
||||
export const ALL_MODEL_FIXTURES: Asset[] = [
|
||||
STABLE_CHECKPOINT,
|
||||
STABLE_CHECKPOINT_2,
|
||||
@@ -200,9 +191,6 @@ export const ALL_INPUT_FIXTURES: Asset[] = [
|
||||
]
|
||||
|
||||
export const ALL_OUTPUT_FIXTURES: Asset[] = [STABLE_OUTPUT, STABLE_OUTPUT_2]
|
||||
|
||||
// ─── Factories for generating N deterministic assets ───────────────────────────
|
||||
|
||||
const CHECKPOINT_NAMES = [
|
||||
'sd_xl_base_1.0.safetensors',
|
||||
'v1-5-pruned-emaonly.safetensors',
|
||||
|
||||
@@ -22,9 +22,6 @@ interface PaginationOptions {
|
||||
total: number
|
||||
hasMore: boolean
|
||||
}
|
||||
|
||||
// ─── Configuration ──────────────────────────────────────────────────────────
|
||||
|
||||
export interface AssetConfig {
|
||||
readonly assets: ReadonlyMap<string, Asset>
|
||||
readonly pagination: PaginationOptions | null
|
||||
@@ -47,9 +44,6 @@ function addAssets(
|
||||
}
|
||||
return { ...config, assets: merged }
|
||||
}
|
||||
|
||||
// ─── Operators ──────────────────────────────────────────────────────────────
|
||||
|
||||
export function withModels(
|
||||
countOrAssets: number | Asset[],
|
||||
category: 'checkpoints' | 'loras' | 'vae' | 'embeddings' = 'checkpoints'
|
||||
@@ -100,9 +94,6 @@ export function withUploadResponse(
|
||||
): AssetOperator {
|
||||
return (config) => ({ ...config, uploadResponse: response })
|
||||
}
|
||||
|
||||
// ─── Helper Class ───────────────────────────────────────────────────────────
|
||||
|
||||
export class AssetHelper {
|
||||
private store: Map<string, Asset>
|
||||
private paginationOptions: PaginationOptions | null
|
||||
@@ -121,9 +112,6 @@ export class AssetHelper {
|
||||
this.paginationOptions = config.pagination
|
||||
this.uploadResponse = config.uploadResponse
|
||||
}
|
||||
|
||||
// ─── Activation ─────────────────────────────────────────────────────────
|
||||
|
||||
async mock(): Promise<void> {
|
||||
const handler = async (route: Route) => {
|
||||
const url = new URL(route.request().url())
|
||||
@@ -249,9 +237,6 @@ export class AssetHelper {
|
||||
this.routeHandlers.push({ pattern, handler })
|
||||
await this.page.route(pattern, handler)
|
||||
}
|
||||
|
||||
// ─── Inspection ─────────────────────────────────────────────────────────
|
||||
|
||||
getMutations(): MutationRecord[] {
|
||||
return [...this.mutations]
|
||||
}
|
||||
@@ -267,9 +252,6 @@ export class AssetHelper {
|
||||
get assetCount(): number {
|
||||
return this.store.size
|
||||
}
|
||||
|
||||
// ─── Cleanup ────────────────────────────────────────────────────────────
|
||||
|
||||
async clearMocks(): Promise<void> {
|
||||
for (const { pattern, handler } of this.routeHandlers) {
|
||||
await this.page.unroute(pattern, handler)
|
||||
@@ -280,9 +262,6 @@ export class AssetHelper {
|
||||
this.paginationOptions = null
|
||||
this.uploadResponse = null
|
||||
}
|
||||
|
||||
// ─── Internal ───────────────────────────────────────────────────────────
|
||||
|
||||
private getFilteredAssets(tags: string[]): Asset[] {
|
||||
const assets = [...this.store.values()]
|
||||
if (tags.length === 0) return assets
|
||||
@@ -292,9 +271,6 @@ export class AssetHelper {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// ─── Factory ────────────────────────────────────────────────────────────────
|
||||
|
||||
export function createAssetHelper(
|
||||
page: Page,
|
||||
...operators: AssetOperator[]
|
||||
|
||||
Reference in New Issue
Block a user