From 8d39c82ed83fc3bb698492b8838b3513385cce5d Mon Sep 17 00:00:00 2001 From: Anton Aftakhov Date: Wed, 15 Jan 2025 15:23:17 +0500 Subject: [PATCH 1/4] Support allure metadata in playwright test and group annotations (closes #1188) --- packages/allure-playwright/src/index.ts | 10 ++ .../test/spec/annotations.spec.ts | 104 ++++++++++++++++++ .../test/spec/runtime/legacy/tags.spec.ts | 2 +- .../test/spec/runtime/modern/tags.spec.ts | 2 +- 4 files changed, 116 insertions(+), 2 deletions(-) diff --git a/packages/allure-playwright/src/index.ts b/packages/allure-playwright/src/index.ts index a618c88a5..212b77106 100644 --- a/packages/allure-playwright/src/index.ts +++ b/packages/allure-playwright/src/index.ts @@ -197,6 +197,16 @@ export class AllureReporter implements ReporterV2 { result.labels!.push(...tags); } + if ("annotations" in test) { + const annotations: Label[] = test.annotations?.filter( + (annotation) => annotation.type !== "skip" && annotation.type !== "fixme", + ).map((annotation) => ({ + name: annotation.type, + value: annotation.description!, + })); + result.labels!.push(...annotations); + } + if (project?.name) { result.parameters!.push({ name: "Project", value: project.name }); } diff --git a/packages/allure-playwright/test/spec/annotations.spec.ts b/packages/allure-playwright/test/spec/annotations.spec.ts index a202879be..eafc385a4 100644 --- a/packages/allure-playwright/test/spec/annotations.spec.ts +++ b/packages/allure-playwright/test/spec/annotations.spec.ts @@ -1,4 +1,5 @@ import { expect, it } from "vitest"; +import { LabelName } from "allure-js-commons"; import { runPlaywrightInlineTest } from "../utils.js"; it("should support skip annotation", async () => { @@ -56,3 +57,106 @@ it("should support fixme annotation", async () => { ]), ); }); + + +it("should support allure metadata in playwright annotation", async () => { + const { tests } = await runPlaywrightInlineTest({ + "sample.test.js": ` + import { test } from '@playwright/test'; + import { LabelName } from 'allure-js-commons'; + test('test full report', { + annotation: [ + { type: "skip", description: "skipped via skip annotation" }, + { type: "fixme", description: "skipped via fixme annotation" }, + { type: "foo", description: "bar" }, + { type: LabelName.ALLURE_ID, description: "foo" }, + { type: LabelName.EPIC, description: "foo" }, + { type: LabelName.FEATURE, description: "foo" }, + { type: LabelName.LAYER, description: "foo" }, + { type: LabelName.OWNER, description: "foo" }, + { type: LabelName.PARENT_SUITE, description: "foo" }, + { type: LabelName.SUB_SUITE, description: "foo" }, + { type: LabelName.SUITE, description: "foo" }, + { type: LabelName.SEVERITY, description: "foo" }, + { type: LabelName.STORY, description: "foo" }, + { type: LabelName.TAG, description: "foo" }, + ], + }, async () => { + }); + `, + }); + + expect(tests).toHaveLength(1); + expect(tests[0].labels).not.toContainEqual({ name: "fixme", value: "skipped via fixme annotation" }); + expect(tests[0].labels).not.toContainEqual({ name: "skip", value: "skipped via skip annotation" }); + expect(tests[0].labels).toContainEqual({ name: "foo", value: "bar" }); + expect(tests[0].labels).toContainEqual({ name: LabelName.ALLURE_ID, value: "foo" }); + expect(tests[0].labels).toContainEqual({ name: LabelName.EPIC, value: "foo" }); + expect(tests[0].labels).toContainEqual({ name: LabelName.FEATURE, value: "foo" }); + expect(tests[0].labels).toContainEqual({ name: LabelName.LAYER, value: "foo" }); + expect(tests[0].labels).toContainEqual({ name: LabelName.OWNER, value: "foo" }); + expect(tests[0].labels).toContainEqual({ name: LabelName.PARENT_SUITE, value: "foo" }); + expect(tests[0].labels).toContainEqual({ name: LabelName.SUB_SUITE, value: "foo" }); + expect(tests[0].labels).toContainEqual({ name: LabelName.SUITE, value: "foo" }); + expect(tests[0].labels).toContainEqual({ name: LabelName.SEVERITY, value: "foo" }); + expect(tests[0].labels).toContainEqual({ name: LabelName.STORY, value: "foo" }); + expect(tests[0].labels).toContainEqual({ name: LabelName.TAG, value: "foo" }); +}); + +it("should support allure metadata in playwright group annotation", async () => { + const { tests } = await runPlaywrightInlineTest({ + "sample.test.js": ` + import { test } from '@playwright/test'; + import { LabelName } from 'allure-js-commons'; + test.describe( + 'nested', + { + annotation: [ + { type: "foo", description: "bar" }, + { type: LabelName.EPIC, description: "foo" }, + { type: LabelName.FEATURE, description: "foo" }, + { type: LabelName.LAYER, description: "foo" }, + { type: LabelName.OWNER, description: "foo" }, + { type: LabelName.PARENT_SUITE, description: "foo" }, + { type: LabelName.SUB_SUITE, description: "foo" }, + { type: LabelName.SUITE, description: "foo" }, + { type: LabelName.SEVERITY, description: "foo" }, + { type: LabelName.STORY, description: "foo" }, + { type: LabelName.TAG, description: "foo" }, + ], + }, + () => { + test('test full report 1', async () => { + }); + test('test full report 2', async () => { + }); + }, + ); + `, + }); + + expect(tests).toHaveLength(2); + expect(tests[0].labels).toContainEqual({ name: "foo", value: "bar" }); + expect(tests[0].labels).toContainEqual({ name: LabelName.EPIC, value: "foo" }); + expect(tests[0].labels).toContainEqual({ name: LabelName.FEATURE, value: "foo" }); + expect(tests[0].labels).toContainEqual({ name: LabelName.LAYER, value: "foo" }); + expect(tests[0].labels).toContainEqual({ name: LabelName.OWNER, value: "foo" }); + expect(tests[0].labels).toContainEqual({ name: LabelName.PARENT_SUITE, value: "foo" }); + expect(tests[0].labels).toContainEqual({ name: LabelName.SUB_SUITE, value: "foo" }); + expect(tests[0].labels).toContainEqual({ name: LabelName.SUITE, value: "foo" }); + expect(tests[0].labels).toContainEqual({ name: LabelName.SEVERITY, value: "foo" }); + expect(tests[0].labels).toContainEqual({ name: LabelName.STORY, value: "foo" }); + expect(tests[0].labels).toContainEqual({ name: LabelName.TAG, value: "foo" }); + + expect(tests[1].labels).toContainEqual({ name: "foo", value: "bar" }); + expect(tests[1].labels).toContainEqual({ name: LabelName.EPIC, value: "foo" }); + expect(tests[1].labels).toContainEqual({ name: LabelName.FEATURE, value: "foo" }); + expect(tests[1].labels).toContainEqual({ name: LabelName.LAYER, value: "foo" }); + expect(tests[1].labels).toContainEqual({ name: LabelName.OWNER, value: "foo" }); + expect(tests[1].labels).toContainEqual({ name: LabelName.PARENT_SUITE, value: "foo" }); + expect(tests[1].labels).toContainEqual({ name: LabelName.SUB_SUITE, value: "foo" }); + expect(tests[1].labels).toContainEqual({ name: LabelName.SUITE, value: "foo" }); + expect(tests[1].labels).toContainEqual({ name: LabelName.SEVERITY, value: "foo" }); + expect(tests[1].labels).toContainEqual({ name: LabelName.STORY, value: "foo" }); + expect(tests[1].labels).toContainEqual({ name: LabelName.TAG, value: "foo" }); +}); diff --git a/packages/allure-playwright/test/spec/runtime/legacy/tags.spec.ts b/packages/allure-playwright/test/spec/runtime/legacy/tags.spec.ts index facced14b..de4640e00 100644 --- a/packages/allure-playwright/test/spec/runtime/legacy/tags.spec.ts +++ b/packages/allure-playwright/test/spec/runtime/legacy/tags.spec.ts @@ -24,7 +24,7 @@ it("sets multiply tags", async () => { { name: LabelName.TAG, value: "TestInfo" }, { name: LabelName.TAG, value: "some" }, { name: LabelName.TAG, value: "other" }, - { name: LabelName.TAG, value: "other" }, + { name: LabelName.TAG, value: "tags" }, ]), }), ]); diff --git a/packages/allure-playwright/test/spec/runtime/modern/tags.spec.ts b/packages/allure-playwright/test/spec/runtime/modern/tags.spec.ts index 0e9f114cf..2e1b84dd3 100644 --- a/packages/allure-playwright/test/spec/runtime/modern/tags.spec.ts +++ b/packages/allure-playwright/test/spec/runtime/modern/tags.spec.ts @@ -25,7 +25,7 @@ it("sets multiply tags", async () => { { name: LabelName.TAG, value: "TestInfo" }, { name: LabelName.TAG, value: "some" }, { name: LabelName.TAG, value: "other" }, - { name: LabelName.TAG, value: "other" }, + { name: LabelName.TAG, value: "tags" }, ]), }), ]); From 8e68fc5f740c95f03d686ebb63d697b47f379f53 Mon Sep 17 00:00:00 2001 From: Anton Aftakhov Date: Wed, 15 Jan 2025 21:46:18 +0500 Subject: [PATCH 2/4] prettier:format --- packages/allure-playwright/src/index.ts | 12 ++++++------ .../allure-playwright/test/spec/annotations.spec.ts | 1 - 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/allure-playwright/src/index.ts b/packages/allure-playwright/src/index.ts index 212b77106..3c9c38a3f 100644 --- a/packages/allure-playwright/src/index.ts +++ b/packages/allure-playwright/src/index.ts @@ -198,12 +198,12 @@ export class AllureReporter implements ReporterV2 { } if ("annotations" in test) { - const annotations: Label[] = test.annotations?.filter( - (annotation) => annotation.type !== "skip" && annotation.type !== "fixme", - ).map((annotation) => ({ - name: annotation.type, - value: annotation.description!, - })); + const annotations: Label[] = test.annotations + ?.filter((annotation) => annotation.type !== "skip" && annotation.type !== "fixme") + .map((annotation) => ({ + name: annotation.type, + value: annotation.description!, + })); result.labels!.push(...annotations); } diff --git a/packages/allure-playwright/test/spec/annotations.spec.ts b/packages/allure-playwright/test/spec/annotations.spec.ts index eafc385a4..c1c501c54 100644 --- a/packages/allure-playwright/test/spec/annotations.spec.ts +++ b/packages/allure-playwright/test/spec/annotations.spec.ts @@ -58,7 +58,6 @@ it("should support fixme annotation", async () => { ); }); - it("should support allure metadata in playwright annotation", async () => { const { tests } = await runPlaywrightInlineTest({ "sample.test.js": ` From 4afc0e3b574dc257762bf2ded7e11acce66099b0 Mon Sep 17 00:00:00 2001 From: epszaw Date: Tue, 28 Jan 2025 18:13:30 +0100 Subject: [PATCH 3/4] improve playwright annotations processing logic --- packages/allure-js-commons/src/sdk/index.ts | 1 + packages/allure-js-commons/src/sdk/utils.ts | 19 ++- packages/allure-playwright/src/index.ts | 54 ++++++- .../test/spec/annotations.spec.ts | 150 +++++++++++------- packages/allure-playwright/vitest.config.ts | 3 +- 5 files changed, 161 insertions(+), 66 deletions(-) diff --git a/packages/allure-js-commons/src/sdk/index.ts b/packages/allure-js-commons/src/sdk/index.ts index 991a68fea..8491418ef 100644 --- a/packages/allure-js-commons/src/sdk/index.ts +++ b/packages/allure-js-commons/src/sdk/index.ts @@ -17,6 +17,7 @@ export { getStatusFromError, getMessageAndTraceFromError, isMetadataTag, + getMetadataLabel, extractMetadataFromString, isAllStepsEnded, isAnyStepFailed, diff --git a/packages/allure-js-commons/src/sdk/utils.ts b/packages/allure-js-commons/src/sdk/utils.ts index 15754f741..d9fcd8660 100644 --- a/packages/allure-js-commons/src/sdk/utils.ts +++ b/packages/allure-js-commons/src/sdk/utils.ts @@ -73,6 +73,7 @@ type AllureTitleMetadataMatch = RegExpMatchArray & { }; }; +export const allureMetadataRegexp = /(?:^|\s)@?allure\.(?\S+)$/; export const allureTitleMetadataRegexp = /(?:^|\s)@?allure\.(?\S+)[:=]("[^"]+"|'[^']+'|`[^`]+`|\S+)/; export const allureTitleMetadataRegexpGlobal = new RegExp(allureTitleMetadataRegexp, "g"); export const allureIdRegexp = /(?:^|\s)@?allure\.id[:=](?\S+)/; @@ -96,7 +97,23 @@ export const getValueFromAllureTitleMetadataMatch = (match: AllureTitleMetadataM }; export const isMetadataTag = (tag: string) => { - return allureTitleMetadataRegexp.test(tag); + return allureMetadataRegexp.test(tag); +}; + +export const getMetadataLabel = (tag: string, value?: string): Label | undefined => { + const match = tag.match(allureMetadataRegexp); + const type = match?.groups?.type; + + if (!type) { + return undefined; + } + + const [subtype, name] = type.split("."); + + return { + name: subtype === "id" ? LabelName.ALLURE_ID : name, + value: value ?? "", + }; }; export const extractMetadataFromString = ( diff --git a/packages/allure-playwright/src/index.ts b/packages/allure-playwright/src/index.ts index 3c9c38a3f..1dee6f0be 100644 --- a/packages/allure-playwright/src/index.ts +++ b/packages/allure-playwright/src/index.ts @@ -15,12 +15,19 @@ import { type ImageDiffAttachment, type Label, LabelName, + LinkType, Stage, Status, type TestResult, } from "allure-js-commons"; import type { RuntimeMessage, TestPlanV1Test } from "allure-js-commons/sdk"; -import { extractMetadataFromString, getMessageAndTraceFromError, hasLabel, stripAnsi } from "allure-js-commons/sdk"; +import { + extractMetadataFromString, + getMessageAndTraceFromError, + getMetadataLabel, + hasLabel, + stripAnsi, +} from "allure-js-commons/sdk"; import { ALLURE_RUNTIME_MESSAGE_CONTENT_TYPE, ReporterRuntime, @@ -179,6 +186,7 @@ export class AllureReporter implements ReporterV2 { labels: [...titleMetadata.labels, ...getEnvironmentLabels()], links: [], parameters: [], + steps: [], testCaseId: md5(testCaseIdBase), fullName: `${relativeFile}:${test.location.line}:${test.location.column}`, }; @@ -198,13 +206,43 @@ export class AllureReporter implements ReporterV2 { } if ("annotations" in test) { - const annotations: Label[] = test.annotations - ?.filter((annotation) => annotation.type !== "skip" && annotation.type !== "fixme") - .map((annotation) => ({ - name: annotation.type, - value: annotation.description!, - })); - result.labels!.push(...annotations); + for (const annotation of test.annotations) { + if (annotation.type === "skip" || annotation.type === "fixme") { + continue; + } + + if (annotation.type === "issue") { + result.links!.push({ type: LinkType.ISSUE, url: annotation.description! }); + continue; + } + + if (annotation.type === "tms" || annotation.type === "test_key") { + result.links!.push({ type: LinkType.TMS, url: annotation.description! }); + continue; + } + + if (annotation.type === "description") { + result.description = annotation.description; + continue; + } + + const annotationLabel = getMetadataLabel(annotation.type, annotation.description); + + if (annotationLabel) { + result.labels!.push(annotationLabel); + continue; + } + + result.steps!.push({ + name: `${annotation.type}: ${annotation.description!}`, + status: Status.PASSED, + stage: Stage.FINISHED, + parameters: [], + steps: [], + attachments: [], + statusDetails: {}, + }); + } } if (project?.name) { diff --git a/packages/allure-playwright/test/spec/annotations.spec.ts b/packages/allure-playwright/test/spec/annotations.spec.ts index c1c501c54..404c65e66 100644 --- a/packages/allure-playwright/test/spec/annotations.spec.ts +++ b/packages/allure-playwright/test/spec/annotations.spec.ts @@ -1,5 +1,5 @@ import { expect, it } from "vitest"; -import { LabelName } from "allure-js-commons"; +import { LabelName, LinkType } from "allure-js-commons"; import { runPlaywrightInlineTest } from "../utils.js"; it("should support skip annotation", async () => { @@ -67,18 +67,13 @@ it("should support allure metadata in playwright annotation", async () => { annotation: [ { type: "skip", description: "skipped via skip annotation" }, { type: "fixme", description: "skipped via fixme annotation" }, - { type: "foo", description: "bar" }, - { type: LabelName.ALLURE_ID, description: "foo" }, - { type: LabelName.EPIC, description: "foo" }, - { type: LabelName.FEATURE, description: "foo" }, - { type: LabelName.LAYER, description: "foo" }, - { type: LabelName.OWNER, description: "foo" }, - { type: LabelName.PARENT_SUITE, description: "foo" }, - { type: LabelName.SUB_SUITE, description: "foo" }, - { type: LabelName.SUITE, description: "foo" }, - { type: LabelName.SEVERITY, description: "foo" }, - { type: LabelName.STORY, description: "foo" }, - { type: LabelName.TAG, description: "foo" }, + { type: "@allure.id", description: "foo" }, + { type: "@allure.label.foo", description: "bar" }, + { type: "allure.label.epic", description: "baz" }, + { type: "issue", description: "anything 2" }, + { type: "tms", description: "anything 3" }, + { type: "test_key", description: "anything 4" }, + { type: "description", description: "new test description" }, ], }, async () => { }); @@ -86,20 +81,59 @@ it("should support allure metadata in playwright annotation", async () => { }); expect(tests).toHaveLength(1); - expect(tests[0].labels).not.toContainEqual({ name: "fixme", value: "skipped via fixme annotation" }); + expect(tests[0].description).toBe("new test description"); + expect(tests[0].labels).not.toContainEqual({ name: "description", value: "new test description" }); expect(tests[0].labels).not.toContainEqual({ name: "skip", value: "skipped via skip annotation" }); + expect(tests[0].labels).not.toContainEqual({ + name: "fixme", + value: "skipped via fixme annotation", + }); + expect(tests[0].labels).toContainEqual({ name: LabelName.ALLURE_ID, value: "foo" }); + expect(tests[0].labels).toContainEqual({ name: LabelName.EPIC, value: "baz" }); expect(tests[0].labels).toContainEqual({ name: "foo", value: "bar" }); + expect(tests[0].links).toContainEqual({ type: LinkType.ISSUE, url: "anything 2" }); + expect(tests[0].links).toContainEqual({ type: LinkType.TMS, url: "anything 3" }); + expect(tests[0].links).toContainEqual({ type: LinkType.TMS, url: "anything 4" }); +}); + +it("should append unknown playwright annotation to the test description", async () => { + const { tests } = await runPlaywrightInlineTest({ + "sample.test.js": ` + import { test } from '@playwright/test'; + import { LabelName } from 'allure-js-commons'; + test('test full report', { + annotation: [ + { type: "skip", description: "skipped via skip annotation" }, + { type: "fixme", description: "skipped via fixme annotation" }, + { type: "@allure.id", description: "foo" }, + { type: "@allure.label.foo", description: "bar" }, + { type: "allure.label.epic", description: "baz" }, + { type: "issue", description: "anything 2" }, + { type: "tms", description: "anything 3" }, + { type: "test_key", description: "anything 4" }, + { type: "description", description: "new test description" }, + { type: "unknown", description: "unknown annotation" }, + ], + }, async () => { + }); + `, + }); + + expect(tests).toHaveLength(1); + expect(tests[0].description).toBe("new test description"); + expect(tests[0].labels).not.toContainEqual({ name: "description", value: "new test description" }); + expect(tests[0].labels).not.toContainEqual({ name: "skip", value: "skipped via skip annotation" }); + expect(tests[0].labels).not.toContainEqual({ + name: "fixme", + value: "skipped via fixme annotation", + }); expect(tests[0].labels).toContainEqual({ name: LabelName.ALLURE_ID, value: "foo" }); - expect(tests[0].labels).toContainEqual({ name: LabelName.EPIC, value: "foo" }); - expect(tests[0].labels).toContainEqual({ name: LabelName.FEATURE, value: "foo" }); - expect(tests[0].labels).toContainEqual({ name: LabelName.LAYER, value: "foo" }); - expect(tests[0].labels).toContainEqual({ name: LabelName.OWNER, value: "foo" }); - expect(tests[0].labels).toContainEqual({ name: LabelName.PARENT_SUITE, value: "foo" }); - expect(tests[0].labels).toContainEqual({ name: LabelName.SUB_SUITE, value: "foo" }); - expect(tests[0].labels).toContainEqual({ name: LabelName.SUITE, value: "foo" }); - expect(tests[0].labels).toContainEqual({ name: LabelName.SEVERITY, value: "foo" }); - expect(tests[0].labels).toContainEqual({ name: LabelName.STORY, value: "foo" }); - expect(tests[0].labels).toContainEqual({ name: LabelName.TAG, value: "foo" }); + expect(tests[0].labels).toContainEqual({ name: LabelName.EPIC, value: "baz" }); + expect(tests[0].labels).toContainEqual({ name: "foo", value: "bar" }); + expect(tests[0].links).toContainEqual({ type: LinkType.ISSUE, url: "anything 2" }); + expect(tests[0].links).toContainEqual({ type: LinkType.TMS, url: "anything 3" }); + expect(tests[0].links).toContainEqual({ type: LinkType.TMS, url: "anything 4" }); + expect(tests[0].steps).toContainEqual(expect.objectContaining({ name: "unknown: unknown annotation" })); }); it("should support allure metadata in playwright group annotation", async () => { @@ -111,17 +145,16 @@ it("should support allure metadata in playwright group annotation", async () => 'nested', { annotation: [ - { type: "foo", description: "bar" }, - { type: LabelName.EPIC, description: "foo" }, - { type: LabelName.FEATURE, description: "foo" }, - { type: LabelName.LAYER, description: "foo" }, - { type: LabelName.OWNER, description: "foo" }, - { type: LabelName.PARENT_SUITE, description: "foo" }, - { type: LabelName.SUB_SUITE, description: "foo" }, - { type: LabelName.SUITE, description: "foo" }, - { type: LabelName.SEVERITY, description: "foo" }, - { type: LabelName.STORY, description: "foo" }, - { type: LabelName.TAG, description: "foo" }, + { type: "skip", description: "skipped via skip annotation" }, + { type: "fixme", description: "skipped via fixme annotation" }, + { type: "@allure.id", description: "foo" }, + { type: "@allure.label.foo", description: "bar" }, + { type: "allure.label.epic", description: "baz" }, + { type: "issue", description: "anything 2" }, + { type: "tms", description: "anything 3" }, + { type: "test_key", description: "anything 4" }, + { type: "description", description: "new test description" }, + { type: "unknown", description: "unknown annotation" }, ], }, () => { @@ -135,27 +168,32 @@ it("should support allure metadata in playwright group annotation", async () => }); expect(tests).toHaveLength(2); + expect(tests[0].description).toBe("new test description"); + expect(tests[0].labels).not.toContainEqual({ name: "description", value: "new test description" }); + expect(tests[0].labels).not.toContainEqual({ name: "skip", value: "skipped via skip annotation" }); + expect(tests[0].labels).not.toContainEqual({ + name: "fixme", + value: "skipped via fixme annotation", + }); + expect(tests[0].labels).toContainEqual({ name: LabelName.ALLURE_ID, value: "foo" }); + expect(tests[0].labels).toContainEqual({ name: LabelName.EPIC, value: "baz" }); expect(tests[0].labels).toContainEqual({ name: "foo", value: "bar" }); - expect(tests[0].labels).toContainEqual({ name: LabelName.EPIC, value: "foo" }); - expect(tests[0].labels).toContainEqual({ name: LabelName.FEATURE, value: "foo" }); - expect(tests[0].labels).toContainEqual({ name: LabelName.LAYER, value: "foo" }); - expect(tests[0].labels).toContainEqual({ name: LabelName.OWNER, value: "foo" }); - expect(tests[0].labels).toContainEqual({ name: LabelName.PARENT_SUITE, value: "foo" }); - expect(tests[0].labels).toContainEqual({ name: LabelName.SUB_SUITE, value: "foo" }); - expect(tests[0].labels).toContainEqual({ name: LabelName.SUITE, value: "foo" }); - expect(tests[0].labels).toContainEqual({ name: LabelName.SEVERITY, value: "foo" }); - expect(tests[0].labels).toContainEqual({ name: LabelName.STORY, value: "foo" }); - expect(tests[0].labels).toContainEqual({ name: LabelName.TAG, value: "foo" }); - + expect(tests[0].links).toContainEqual({ type: LinkType.ISSUE, url: "anything 2" }); + expect(tests[0].links).toContainEqual({ type: LinkType.TMS, url: "anything 3" }); + expect(tests[0].links).toContainEqual({ type: LinkType.TMS, url: "anything 4" }); + expect(tests[0].steps).toContainEqual(expect.objectContaining({ name: "unknown: unknown annotation" })); + expect(tests[1].description).toBe("new test description"); + expect(tests[1].labels).not.toContainEqual({ name: "description", value: "new test description" }); + expect(tests[1].labels).not.toContainEqual({ name: "skip", value: "skipped via skip annotation" }); + expect(tests[1].labels).not.toContainEqual({ + name: "fixme", + value: "skipped via fixme annotation", + }); + expect(tests[1].labels).toContainEqual({ name: LabelName.ALLURE_ID, value: "foo" }); + expect(tests[1].labels).toContainEqual({ name: LabelName.EPIC, value: "baz" }); expect(tests[1].labels).toContainEqual({ name: "foo", value: "bar" }); - expect(tests[1].labels).toContainEqual({ name: LabelName.EPIC, value: "foo" }); - expect(tests[1].labels).toContainEqual({ name: LabelName.FEATURE, value: "foo" }); - expect(tests[1].labels).toContainEqual({ name: LabelName.LAYER, value: "foo" }); - expect(tests[1].labels).toContainEqual({ name: LabelName.OWNER, value: "foo" }); - expect(tests[1].labels).toContainEqual({ name: LabelName.PARENT_SUITE, value: "foo" }); - expect(tests[1].labels).toContainEqual({ name: LabelName.SUB_SUITE, value: "foo" }); - expect(tests[1].labels).toContainEqual({ name: LabelName.SUITE, value: "foo" }); - expect(tests[1].labels).toContainEqual({ name: LabelName.SEVERITY, value: "foo" }); - expect(tests[1].labels).toContainEqual({ name: LabelName.STORY, value: "foo" }); - expect(tests[1].labels).toContainEqual({ name: LabelName.TAG, value: "foo" }); + expect(tests[1].links).toContainEqual({ type: LinkType.ISSUE, url: "anything 2" }); + expect(tests[1].links).toContainEqual({ type: LinkType.TMS, url: "anything 3" }); + expect(tests[1].links).toContainEqual({ type: LinkType.TMS, url: "anything 4" }); + expect(tests[1].steps).toContainEqual(expect.objectContaining({ name: "unknown: unknown annotation" })); }); diff --git a/packages/allure-playwright/vitest.config.ts b/packages/allure-playwright/vitest.config.ts index c0472c4b2..6ca0c0dd4 100644 --- a/packages/allure-playwright/vitest.config.ts +++ b/packages/allure-playwright/vitest.config.ts @@ -4,7 +4,8 @@ export default defineConfig({ test: { dir: "./test/spec", fileParallelism: false, - testTimeout: 25000, + // testTimeout: 25000, + testTimeout: Infinity, setupFiles: ["./vitest-setup.ts"], reporters: ["verbose", ["allure-vitest/reporter", { resultsDir: "./out/allure-results" }]], typecheck: { From f64446dece44b5d72abc6c879c8c0a019a2eef06 Mon Sep 17 00:00:00 2001 From: epszaw Date: Tue, 28 Jan 2025 18:28:37 +0100 Subject: [PATCH 4/4] review fixes --- packages/allure-playwright/src/index.ts | 15 +++++++++++++-- packages/allure-playwright/vitest.config.ts | 3 +-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/allure-playwright/src/index.ts b/packages/allure-playwright/src/index.ts index 1dee6f0be..87ff34639 100644 --- a/packages/allure-playwright/src/index.ts +++ b/packages/allure-playwright/src/index.ts @@ -33,6 +33,7 @@ import { ReporterRuntime, createDefaultWriter, escapeRegExp, + formatLink, getEnvironmentLabels, getFrameworkLabel, getHostLabel, @@ -212,12 +213,22 @@ export class AllureReporter implements ReporterV2 { } if (annotation.type === "issue") { - result.links!.push({ type: LinkType.ISSUE, url: annotation.description! }); + result.links!.push( + formatLink(this.options.links ?? {}, { + type: LinkType.ISSUE, + url: annotation.description!, + }), + ); continue; } if (annotation.type === "tms" || annotation.type === "test_key") { - result.links!.push({ type: LinkType.TMS, url: annotation.description! }); + result.links!.push( + formatLink(this.options.links ?? {}, { + type: LinkType.TMS, + url: annotation.description!, + }), + ); continue; } diff --git a/packages/allure-playwright/vitest.config.ts b/packages/allure-playwright/vitest.config.ts index 6ca0c0dd4..c0472c4b2 100644 --- a/packages/allure-playwright/vitest.config.ts +++ b/packages/allure-playwright/vitest.config.ts @@ -4,8 +4,7 @@ export default defineConfig({ test: { dir: "./test/spec", fileParallelism: false, - // testTimeout: 25000, - testTimeout: Infinity, + testTimeout: 25000, setupFiles: ["./vitest-setup.ts"], reporters: ["verbose", ["allure-vitest/reporter", { resultsDir: "./out/allure-results" }]], typecheck: {