From ff3b5c845f5b4a4d49d8116da710c20dcc005f89 Mon Sep 17 00:00:00 2001 From: shadowusr <nikhakerlab@gmail.com> Date: Thu, 28 Nov 2024 00:56:17 +0300 Subject: [PATCH] fix: add error as last step if no suitable step to attach it to was found --- .../suites/components/TestSteps/selectors.ts | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/lib/static/new-ui/features/suites/components/TestSteps/selectors.ts b/lib/static/new-ui/features/suites/components/TestSteps/selectors.ts index 618b4474..0a7d5e41 100644 --- a/lib/static/new-ui/features/suites/components/TestSteps/selectors.ts +++ b/lib/static/new-ui/features/suites/components/TestSteps/selectors.ts @@ -63,7 +63,7 @@ export const getTestSteps = createSelector( if (result.error && !isImageDiffError(result.error) && !isAssertViewError(result.error)) { const lastErroredStep = getLastErroredStep(steps); const error = mergeSnippetIntoErrorStack(result.error); - const errorAttachment: ListTreeItemType<ErrorInfo> = { + const errorInfo: ListTreeItemType<ErrorInfo> = { id: `${lastErroredStep?.id} error 0`, data: { type: StepType.ErrorInfo, @@ -71,19 +71,22 @@ export const getTestSteps = createSelector( stack: error.stack } }; + const errorAttachment: ListTreeItemType<Attachment | ErrorInfo> = { + id: `${lastErroredStep?.id} error`, + data: { + type: StepType.Attachment, + title: 'Error', + hasChildren: true + } satisfies Attachment, + children: [errorInfo] + }; if (lastErroredStep && lastErroredStep.children && lastErroredStep.children.length > 0) { - lastErroredStep.children.push({ - id: `${lastErroredStep.id} error`, - data: { - type: StepType.Attachment, - title: 'Error', - hasChildren: true - } satisfies Attachment, - children: [errorAttachment] - }); + lastErroredStep.children.push(errorAttachment); } else if (lastErroredStep) { - lastErroredStep.children = [errorAttachment]; + lastErroredStep.children = [errorInfo]; + } else { + steps.push(errorAttachment); } }