mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-23 06:10:32 +00:00
test: address asset scenario review feedback
This commit is contained in:
BIN
browser_tests/assets/example.jpg
Normal file
BIN
browser_tests/assets/example.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 516 B |
@@ -22,6 +22,9 @@ const inputFilesRoutePattern = /\/internal\/files\/input(?:\?.*)?$/
|
||||
const viewRoutePattern = /\/api\/view(?:\?.*)?$/
|
||||
const DEFAULT_FIXTURE_CREATE_TIME = Date.UTC(2024, 0, 1, 0, 0, 0)
|
||||
|
||||
type InputFilesResponse = string[]
|
||||
type ViewErrorResponse = { error: string }
|
||||
|
||||
type MockPreviewOutput = NonNullable<JobEntry['preview_output']> & {
|
||||
filename?: string
|
||||
subfolder?: string
|
||||
@@ -214,10 +217,14 @@ export class AssetScenarioHelper {
|
||||
}
|
||||
|
||||
this.inputFilesRouteHandler = async (route: Route) => {
|
||||
const response = this.importedFiles.map(
|
||||
(asset) => asset.name
|
||||
) satisfies InputFilesResponse
|
||||
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
body: JSON.stringify(this.importedFiles.map((asset) => asset.name))
|
||||
body: JSON.stringify(response)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -236,10 +243,14 @@ export class AssetScenarioHelper {
|
||||
const subfolder = url.searchParams.get('subfolder') ?? ''
|
||||
|
||||
if (!filename) {
|
||||
const response = {
|
||||
error: 'Missing filename'
|
||||
} satisfies ViewErrorResponse
|
||||
|
||||
await route.fulfill({
|
||||
status: 400,
|
||||
contentType: 'application/json',
|
||||
body: JSON.stringify({ error: 'Missing filename' })
|
||||
body: JSON.stringify(response)
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -55,6 +55,13 @@ export function defaultFileFor(filename: string): MockAssetFile {
|
||||
}
|
||||
}
|
||||
|
||||
if (normalized.endsWith('.jpg') || normalized.endsWith('.jpeg')) {
|
||||
return {
|
||||
filePath: getFixturePath('example.jpg'),
|
||||
contentType: 'image/jpeg'
|
||||
}
|
||||
}
|
||||
|
||||
if (normalized.endsWith('.webm')) {
|
||||
return {
|
||||
filePath: getFixturePath('workflowInMedia/workflow.webm'),
|
||||
|
||||
Reference in New Issue
Block a user