Skip to content

Commit 85c3ab1

Browse files
authored
fix: filter deleted steps that failed when retrieving test execution (#872)
## Description - Filtered test execution steps is not being used when calling `getTestExecutionSteps`, resulting in an error ## How to recreate <img width="1082" alt="image" src="https://github.com/user-attachments/assets/470a59d2-eac6-4bdb-a3c2-d4b483d2ddc9" /> 1. Add step and make a failed test execution 2. Delete the step and refresh the page
1 parent 9f655fa commit 85c3ab1

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

packages/backend/src/helpers/get-test-execution-steps.ts

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export async function getTestExecutionSteps(
2929
/**
3030
* NOTE: filters out test execution steps for steps that have been deleted
3131
*/
32-
testExecutionSteps
32+
const filteredTestExecutionSteps = testExecutionSteps
3333
.filter((e) => e.step)
3434
.sort((a, b) => a.step.position - b.step.position)
3535

@@ -38,22 +38,25 @@ export async function getTestExecutionSteps(
3838
* If more than 1 exists, we return the latest one sorted by createdAt
3939
*/
4040
const stepIds = new Set<string>()
41-
const dedupedTestExecutionSteps = testExecutionSteps.reduce((acc, curr) => {
42-
if (stepIds.has(curr.stepId)) {
43-
const otherExecutionStep = acc[acc.length - 1]
44-
// possible bug in single step testing !! this should not happen
45-
console.warn(
46-
`Bug: More than 1 execution step found for step ${curr.stepId}`,
47-
)
48-
if (curr.createdAt > otherExecutionStep.createdAt) {
49-
acc[acc.length - 1] = curr
41+
const dedupedTestExecutionSteps = filteredTestExecutionSteps.reduce(
42+
(acc, curr) => {
43+
if (stepIds.has(curr.stepId)) {
44+
const otherExecutionStep = acc[acc.length - 1]
45+
// possible bug in single step testing !! this should not happen
46+
console.warn(
47+
`Bug: More than 1 execution step found for step ${curr.stepId}`,
48+
)
49+
if (curr.createdAt > otherExecutionStep.createdAt) {
50+
acc[acc.length - 1] = curr
51+
}
52+
} else {
53+
stepIds.add(curr.stepId)
54+
acc.push(curr)
5055
}
51-
} else {
52-
stepIds.add(curr.stepId)
53-
acc.push(curr)
54-
}
55-
return acc
56-
}, [] as ExecutionStep[])
56+
return acc
57+
},
58+
[] as ExecutionStep[],
59+
)
5760

5861
return dedupedTestExecutionSteps
5962
}

0 commit comments

Comments
 (0)