Skip to content

Commit

Permalink
fix: add error as last step if no suitable step to attach it to was f…
Browse files Browse the repository at this point in the history
…ound
  • Loading branch information
shadowusr committed Nov 27, 2024
1 parent 9598789 commit ff3b5c8
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions lib/static/new-ui/features/suites/components/TestSteps/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,27 +63,30 @@ 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,
name: error.name,
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);
}
}

Expand Down

0 comments on commit ff3b5c8

Please sign in to comment.