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