Skip to content

Commit 1277bef

Browse files
authored
fix: add error as last step if no suitable step to attach it to was found (#620)
1 parent 9598789 commit 1277bef

File tree

1 file changed

+14
-11
lines changed
  • lib/static/new-ui/features/suites/components/TestSteps

1 file changed

+14
-11
lines changed

lib/static/new-ui/features/suites/components/TestSteps/selectors.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,27 +63,30 @@ export const getTestSteps = createSelector(
6363
if (result.error && !isImageDiffError(result.error) && !isAssertViewError(result.error)) {
6464
const lastErroredStep = getLastErroredStep(steps);
6565
const error = mergeSnippetIntoErrorStack(result.error);
66-
const errorAttachment: ListTreeItemType<ErrorInfo> = {
66+
const errorInfo: ListTreeItemType<ErrorInfo> = {
6767
id: `${lastErroredStep?.id} error 0`,
6868
data: {
6969
type: StepType.ErrorInfo,
7070
name: error.name,
7171
stack: error.stack
7272
}
7373
};
74+
const errorAttachment: ListTreeItemType<Attachment | ErrorInfo> = {
75+
id: `${lastErroredStep?.id} error`,
76+
data: {
77+
type: StepType.Attachment,
78+
title: 'Error',
79+
hasChildren: true
80+
} satisfies Attachment,
81+
children: [errorInfo]
82+
};
7483

7584
if (lastErroredStep && lastErroredStep.children && lastErroredStep.children.length > 0) {
76-
lastErroredStep.children.push({
77-
id: `${lastErroredStep.id} error`,
78-
data: {
79-
type: StepType.Attachment,
80-
title: 'Error',
81-
hasChildren: true
82-
} satisfies Attachment,
83-
children: [errorAttachment]
84-
});
85+
lastErroredStep.children.push(errorAttachment);
8586
} else if (lastErroredStep) {
86-
lastErroredStep.children = [errorAttachment];
87+
lastErroredStep.children = [errorInfo];
88+
} else {
89+
steps.push(errorAttachment);
8790
}
8891
}
8992

0 commit comments

Comments
 (0)