Skip to content

Commit d41fdc8

Browse files
authored
fix(core): step attachments can't be accessed from the test body area (#173)
1 parent b28b43a commit d41fdc8

File tree

3 files changed

+39
-4
lines changed

3 files changed

+39
-4
lines changed

packages/core/src/store/convert.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ const convertStep = (
277277
stepId: md5(`${step.name}${step.start}`),
278278
name: step.name ?? __unknown,
279279
status: step.status ?? defaultStatus,
280-
steps: convertSteps(stateData, step.steps),
280+
steps: subSteps,
281281
parameters: convertParameters(step.parameters),
282282
...processTimings(step),
283283
type: "step",

packages/core/test/store/convert.test.ts

+28-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { md5 } from "@allurereport/plugin-api";
2-
import { attachment, step } from "allure-js-commons";
3-
import { beforeEach, describe, expect, it } from "vitest";
2+
import { attachment, issue, step } from "allure-js-commons";
3+
import { beforeEach, describe, expect, it, vi } from "vitest";
44
import type { StateData } from "../../src/store/convert.js";
55
import { testResultRawToState } from "../../src/store/convert.js";
66

@@ -180,4 +180,30 @@ describe("testResultRawToState", () => {
180180
},
181181
});
182182
});
183+
184+
describe("a converted step attachment", () => {
185+
it("should match a visited link", async () => {
186+
await issue("171");
187+
const visitAttachmentLink = vi.fn<StateData["visitAttachmentLink"]>();
188+
189+
const result = await functionUnderTest(
190+
{ ...emptyStateData, visitAttachmentLink },
191+
{ steps: [{ type: "step", steps: [{ type: "attachment", originalFileName: "some-file.txt" }] }] },
192+
{ readerId },
193+
);
194+
195+
const { id } = visitAttachmentLink.mock.calls[0][0];
196+
expect(result.steps).toMatchObject([
197+
{
198+
type: "step",
199+
steps: [
200+
{
201+
type: "attachment",
202+
link: { id },
203+
},
204+
],
205+
},
206+
]);
207+
});
208+
});
183209
});

packages/core/vitest.config.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,16 @@ export default defineConfig({
1111
"default",
1212
[
1313
"allure-vitest/reporter",
14-
{ resultsDir: "./out/allure-results", globalLabels: [{ name: "module", value: "core" }] },
14+
{
15+
resultsDir: "./out/allure-results",
16+
globalLabels: [{ name: "module", value: "core" }],
17+
links: {
18+
issue: {
19+
urlTemplate: "https://github.com/allure-framework/allure3/issues/%s",
20+
nameTemplate: "Issue %s",
21+
},
22+
},
23+
},
1524
],
1625
],
1726
},

0 commit comments

Comments
 (0)