Skip to content

Commit a16c72f

Browse files
committed
fix tests
1 parent 7d4c853 commit a16c72f

4 files changed

Lines changed: 41 additions & 11 deletions

File tree

packages/allure-cypress/src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const DEFAULT_RUNTIME_CONFIG = {
1313
* @returns An array of popped items. The first popped item becomes the first element of this array.
1414
*/
1515
export const popUntilFindIncluded = <T>(items: T[], pred: (value: T) => boolean) => {
16-
const index = items.findIndex(pred);
16+
const index = items.findLastIndex(pred);
1717
return index !== -1 ? toReversed(items.splice(index)) : [];
1818
};
1919

packages/allure-cypress/test/spec/runtime/modern/steps.test.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,42 @@ it("nested steps", async () => {
8080
expect(tests[0].steps[0].steps[0].steps).toContainEqual(expect.objectContaining({ name: "baz" }));
8181
});
8282

83+
it("keeps the parent step active for later runtime siblings", async () => {
84+
const { tests } = await runCypressInlineTest({
85+
"cypress/e2e/sample.cy.js": ({ allureCommonsModulePath }) => `
86+
import { logStep, step } from "${allureCommonsModulePath}";
87+
88+
it("step", () => {
89+
step("outer", () => {
90+
logStep("inner");
91+
logStep("sibling");
92+
});
93+
});
94+
`,
95+
});
96+
97+
expect(tests).toHaveLength(1);
98+
expect(tests[0].steps).toMatchObject([
99+
{
100+
name: "outer",
101+
status: Status.PASSED,
102+
stage: Stage.FINISHED,
103+
steps: [
104+
{
105+
name: "inner",
106+
status: Status.PASSED,
107+
stage: Stage.FINISHED,
108+
},
109+
{
110+
name: "sibling",
111+
status: Status.PASSED,
112+
stage: Stage.FINISHED,
113+
},
114+
],
115+
},
116+
]);
117+
});
118+
83119
it("stage runtime api", async () => {
84120
const { tests } = await runCypressInlineTest({
85121
"cypress/e2e/sample.cy.js": ({ allureCommonsModulePath }) => `

packages/allure-js-commons/src/sdk/reporter/ReporterRuntime.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,7 @@ import type {
4040
TestScope,
4141
Writer,
4242
} from "./types.js";
43-
import {
44-
deepClone,
45-
formatLinks,
46-
getTestResultHistoryId,
47-
getTestResultTestCaseId,
48-
randomUuid,
49-
} from "./utils.js";
43+
import { deepClone, formatLinks, getTestResultHistoryId, getTestResultTestCaseId, randomUuid } from "./utils.js";
5044
import { buildAttachmentFileName } from "./utils/attachments.js";
5145
import { resolveWriter } from "./writer/loader.js";
5246

packages/allure-playwright/test/spec/runtime/modern/steps.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,12 @@ it("handles runtime stages", async () => {
114114
const runtimeSteps = tests[0].steps.filter((step) => step.name === "stage 1" || step.name === "stage 2");
115115
expect(runtimeSteps).toHaveLength(2);
116116

117-
const collectStepNames = (steps: typeof runtimeSteps[number]["steps"]): string[] =>
117+
const collectStepNames = (steps: (typeof runtimeSteps)[number]["steps"]): string[] =>
118118
steps.flatMap((step) => [step.name, ...collectStepNames(step.steps)]);
119119
const findStepByName = (
120-
steps: typeof tests[0]["steps"],
120+
steps: (typeof tests)[0]["steps"],
121121
name: string,
122-
): (typeof tests[0]["steps"])[number] | undefined => {
122+
): (typeof tests)[0]["steps"][number] | undefined => {
123123
for (const step of steps) {
124124
if (step.name === name) {
125125
return step;

0 commit comments

Comments
 (0)