diff --git a/src/components/queue/job/useJobErrorReporting.ts b/src/components/queue/job/useJobErrorReporting.ts index 7464ada16..30eca078f 100644 --- a/src/components/queue/job/useJobErrorReporting.ts +++ b/src/components/queue/job/useJobErrorReporting.ts @@ -15,17 +15,6 @@ export type JobErrorDialogService = { ) => void } -/** - * Extracts error message from a task. - * Returns the simple error_message string from the jobs API. - * - * Note: Detailed execution errors (with traceback, node info, etc.) are only - * available via WebSocket during live execution. Historical job errors only - * have the simple error_message string. - */ -export const extractErrorMessage = (task: TaskItemImpl | null): string | null => - task?.errorMessage ?? null - type UseJobErrorReportingOptions = { taskForJob: ComputedRef copyToClipboard: CopyHandler @@ -37,9 +26,7 @@ export const useJobErrorReporting = ({ copyToClipboard, dialog }: UseJobErrorReportingOptions) => { - const errorMessageValue = computed( - () => extractErrorMessage(taskForJob.value) ?? '' - ) + const errorMessageValue = computed(() => taskForJob.value?.errorMessage ?? '') const copyErrorMessage = () => { if (errorMessageValue.value) { diff --git a/tests-ui/tests/components/queue/useJobErrorReporting.test.ts b/tests-ui/tests/components/queue/useJobErrorReporting.test.ts index 9b32d198e..17936b9cd 100644 --- a/tests-ui/tests/components/queue/useJobErrorReporting.test.ts +++ b/tests-ui/tests/components/queue/useJobErrorReporting.test.ts @@ -4,41 +4,18 @@ import type { ComputedRef } from 'vue' import type { TaskItemImpl } from '@/stores/queueStore' import type { JobErrorDialogService } from '@/components/queue/job/useJobErrorReporting' -import * as jobErrorReporting from '@/components/queue/job/useJobErrorReporting' +import { useJobErrorReporting } from '@/components/queue/job/useJobErrorReporting' -/** - * Creates a mock TaskItemImpl with an error message. - */ const createTaskWithError = (errorMessage?: string): TaskItemImpl => ({ errorMessage }) as unknown as TaskItemImpl -describe('extractErrorMessage', () => { - it('returns null when task is null', () => { - expect(jobErrorReporting.extractErrorMessage(null)).toBeNull() - }) - - it('returns null when errorMessage is undefined', () => { - expect( - jobErrorReporting.extractErrorMessage(createTaskWithError()) - ).toBeNull() - }) - - it('returns the error message when present', () => { - expect( - jobErrorReporting.extractErrorMessage( - createTaskWithError('Something failed') - ) - ).toBe('Something failed') - }) -}) - describe('useJobErrorReporting', () => { let taskState = ref(null) let taskForJob: ComputedRef let copyToClipboard: ReturnType let showErrorDialog: ReturnType let dialog: JobErrorDialogService - let composable: ReturnType + let composable: ReturnType beforeEach(() => { taskState = ref(null) @@ -46,7 +23,7 @@ describe('useJobErrorReporting', () => { copyToClipboard = vi.fn() showErrorDialog = vi.fn() dialog = { showErrorDialog } - composable = jobErrorReporting.useJobErrorReporting({ + composable = useJobErrorReporting({ taskForJob, copyToClipboard, dialog