mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-22 15:54:09 +00:00
fix optional/nullable fields
This commit is contained in:
@@ -41,12 +41,16 @@ function makeTask(
|
||||
id: string,
|
||||
priority: number,
|
||||
overrides: Omit<Partial<JobListItem>, 'id' | 'priority'> &
|
||||
Pick<JobListItem, 'status' | 'create_time' | 'update_time'>
|
||||
Pick<JobListItem, 'status' | 'create_time'>
|
||||
): TaskItemImpl {
|
||||
const job: JobListItem = {
|
||||
id,
|
||||
priority,
|
||||
last_state_update: null,
|
||||
execution_start_time: null,
|
||||
execution_end_time: null,
|
||||
preview_output: null,
|
||||
outputs_count: null,
|
||||
workflow_id: null,
|
||||
...overrides
|
||||
}
|
||||
return new TaskItemImpl(job)
|
||||
@@ -59,8 +63,7 @@ function makePendingTask(
|
||||
): TaskItemImpl {
|
||||
return makeTask(id, priority, {
|
||||
status: 'pending',
|
||||
create_time: createTimeMs,
|
||||
update_time: createTimeMs
|
||||
create_time: createTimeMs
|
||||
})
|
||||
}
|
||||
|
||||
@@ -71,8 +74,7 @@ function makeRunningTask(
|
||||
): TaskItemImpl {
|
||||
return makeTask(id, priority, {
|
||||
status: 'in_progress',
|
||||
create_time: createTimeMs,
|
||||
update_time: createTimeMs
|
||||
create_time: createTimeMs
|
||||
})
|
||||
}
|
||||
|
||||
@@ -85,7 +87,7 @@ function makeRunningTaskWithStart(
|
||||
return makeTask(id, priority, {
|
||||
status: 'in_progress',
|
||||
create_time: start - 5000,
|
||||
update_time: start
|
||||
execution_start_time: start
|
||||
})
|
||||
}
|
||||
|
||||
@@ -102,22 +104,21 @@ function makeHistoryTask(
|
||||
return makeTask(id, priority, {
|
||||
status: ok ? 'completed' : 'failed',
|
||||
create_time: executionStartTime - 5000,
|
||||
update_time: now,
|
||||
execution_start_time: executionStartTime,
|
||||
execution_end_time: executionEndTime,
|
||||
execution_error: errorMessage
|
||||
? {
|
||||
prompt_id: id,
|
||||
timestamp: now,
|
||||
node_id: '1',
|
||||
node_type: 'ExampleNode',
|
||||
exception_message: errorMessage,
|
||||
exception_type: 'RuntimeError',
|
||||
traceback: [],
|
||||
current_inputs: {},
|
||||
current_outputs: {}
|
||||
}
|
||||
: undefined
|
||||
...(errorMessage && {
|
||||
execution_error: {
|
||||
prompt_id: id,
|
||||
timestamp: now,
|
||||
node_id: '1',
|
||||
node_type: 'ExampleNode',
|
||||
exception_message: errorMessage,
|
||||
exception_type: 'RuntimeError',
|
||||
traceback: [],
|
||||
current_inputs: {},
|
||||
current_outputs: {}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -53,12 +53,12 @@ const zRawJobListItem = z
|
||||
id: z.string(),
|
||||
status: zJobStatus,
|
||||
create_time: z.number(),
|
||||
execution_start_time: z.number().nullable().optional(),
|
||||
execution_end_time: z.number().nullable().optional(),
|
||||
preview_output: zPreviewOutput.nullable().optional(),
|
||||
outputs_count: z.number().nullable().optional(),
|
||||
execution_error: zExecutionError.nullable().optional(),
|
||||
workflow_id: z.string().nullable().optional(),
|
||||
execution_start_time: z.number().nullable(),
|
||||
execution_end_time: z.number().nullable(),
|
||||
preview_output: zPreviewOutput.nullable(),
|
||||
outputs_count: z.number().nullable(),
|
||||
execution_error: zExecutionError.optional(),
|
||||
workflow_id: z.string().nullable(),
|
||||
priority: z.number().optional()
|
||||
})
|
||||
.passthrough()
|
||||
|
||||
@@ -26,8 +26,11 @@ const createMockJob = (id: string, outputsCount = 1): JobListItem => ({
|
||||
id,
|
||||
status: 'completed',
|
||||
create_time: Date.now(),
|
||||
execution_start_time: null,
|
||||
execution_end_time: null,
|
||||
preview_output: null,
|
||||
outputs_count: outputsCount,
|
||||
workflow_id: null,
|
||||
priority: 0
|
||||
})
|
||||
|
||||
|
||||
@@ -11,6 +11,11 @@ function createJob(id: string, createTime = 0, priority?: number): JobListItem {
|
||||
id,
|
||||
status: 'completed',
|
||||
create_time: createTime,
|
||||
execution_start_time: null,
|
||||
execution_end_time: null,
|
||||
preview_output: null,
|
||||
outputs_count: null,
|
||||
workflow_id: null,
|
||||
priority: priority ?? createTime
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ function createMockJob(
|
||||
execution_end_time: null,
|
||||
preview_output: null,
|
||||
outputs_count: 0,
|
||||
workflow_id: null,
|
||||
...overrides
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,14 +95,16 @@ describe('assetsStore - Refactored (Option A)', () => {
|
||||
id: `prompt_${index}`,
|
||||
status: 'completed',
|
||||
create_time: 1000 + index,
|
||||
update_time: 1000 + index,
|
||||
last_state_update: 1000 + index,
|
||||
priority: 1000 + index,
|
||||
execution_start_time: null,
|
||||
execution_end_time: null,
|
||||
preview_output: {
|
||||
filename: `output_${index}.png`,
|
||||
subfolder: '',
|
||||
type: 'output'
|
||||
}
|
||||
},
|
||||
outputs_count: null,
|
||||
workflow_id: null,
|
||||
priority: 1000 + index
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -17,8 +17,11 @@ function createJob(
|
||||
id,
|
||||
status,
|
||||
create_time: createTime,
|
||||
update_time: createTime,
|
||||
last_state_update: createTime,
|
||||
execution_start_time: null,
|
||||
execution_end_time: null,
|
||||
preview_output: null,
|
||||
outputs_count: null,
|
||||
workflow_id: null,
|
||||
priority: priority ?? createTime
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,11 @@ const mockJobDetail = {
|
||||
id: 'test-prompt-id',
|
||||
status: 'completed' as const,
|
||||
create_time: Date.now(),
|
||||
update_time: Date.now(),
|
||||
execution_start_time: null,
|
||||
execution_end_time: null,
|
||||
preview_output: null,
|
||||
outputs_count: null,
|
||||
workflow_id: null,
|
||||
workflow: {
|
||||
extra_data: {
|
||||
extra_pnginfo: {
|
||||
@@ -54,6 +58,11 @@ function createHistoryJob(id: string): JobListItem {
|
||||
id,
|
||||
status: 'completed',
|
||||
create_time: now,
|
||||
execution_start_time: null,
|
||||
execution_end_time: null,
|
||||
preview_output: null,
|
||||
outputs_count: null,
|
||||
workflow_id: null,
|
||||
priority: now
|
||||
}
|
||||
}
|
||||
@@ -64,6 +73,11 @@ function createRunningJob(id: string): JobListItem {
|
||||
id,
|
||||
status: 'in_progress',
|
||||
create_time: now,
|
||||
execution_start_time: null,
|
||||
execution_end_time: null,
|
||||
preview_output: null,
|
||||
outputs_count: null,
|
||||
workflow_id: null,
|
||||
priority: now
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user