From 0e414c33000cdfb47f322016053bc0f7bbf32aec Mon Sep 17 00:00:00 2001 From: Anton Filichkin Date: Thu, 13 Aug 2026 16:58:18 +0300 Subject: [PATCH] fix(playwright): use vnd.allure.playwright-trace content type for trace attachments AllurePlaywright.attachTrace() tagged Playwright trace archives with the generic application/zip content type, so the Allure report rendered them as a plain zip download instead of the embedded trace viewer. Add a shared AttachmentType.PLAYWRIGHT_TRACE constant (application/vnd.allure.playwright-trace, mapped to WellKnownFileExtensionsUtils' .zip extension) and switch attachTrace() to use it, keeping the .zip extension behavior unchanged. --- .../java/io/qameta/allure/model/AttachmentType.java | 5 +++++ .../io/qameta/allure/playwright/AllurePlaywright.java | 2 +- .../qameta/allure/playwright/AllurePlaywrightTest.java | 10 ++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/allure-model/src/main/java/io/qameta/allure/model/AttachmentType.java b/allure-model/src/main/java/io/qameta/allure/model/AttachmentType.java index 65f0eee20..07e430dd1 100644 --- a/allure-model/src/main/java/io/qameta/allure/model/AttachmentType.java +++ b/allure-model/src/main/java/io/qameta/allure/model/AttachmentType.java @@ -55,6 +55,11 @@ public final class AttachmentType { */ public static final AttachmentType OCTET_STREAM = new AttachmentType("application/octet-stream", ""); + /** + * Predefined attachment type for Playwright trace archives. + */ + public static final AttachmentType PLAYWRIGHT_TRACE = new AttachmentType("application/vnd.allure.playwright-trace", ZIP.getExtension()); + private final String mediaType; private final String extension; diff --git a/allure-playwright/src/main/java/io/qameta/allure/playwright/AllurePlaywright.java b/allure-playwright/src/main/java/io/qameta/allure/playwright/AllurePlaywright.java index 85baa4f7e..843c6776e 100644 --- a/allure-playwright/src/main/java/io/qameta/allure/playwright/AllurePlaywright.java +++ b/allure-playwright/src/main/java/io/qameta/allure/playwright/AllurePlaywright.java @@ -205,7 +205,7 @@ public static void attachPageErrors(final String name, final Page page) { * @param traceZip the path to the trace zip file. */ public static void attachTrace(final String name, final Path traceZip) { - attachPath(defaultName(name, TRACE), AttachmentType.ZIP, traceZip); + attachPath(defaultName(name, TRACE), AttachmentType.PLAYWRIGHT_TRACE, traceZip); } /** diff --git a/allure-playwright/src/test/java/io/qameta/allure/playwright/AllurePlaywrightTest.java b/allure-playwright/src/test/java/io/qameta/allure/playwright/AllurePlaywrightTest.java index 2bd0d3eef..4811472ac 100644 --- a/allure-playwright/src/test/java/io/qameta/allure/playwright/AllurePlaywrightTest.java +++ b/allure-playwright/src/test/java/io/qameta/allure/playwright/AllurePlaywrightTest.java @@ -28,6 +28,7 @@ import io.qameta.allure.Param; import io.qameta.allure.Step; import io.qameta.allure.model.Attachment; +import io.qameta.allure.model.AttachmentType; import io.qameta.allure.model.Status; import io.qameta.allure.model.StatusDetails; import io.qameta.allure.model.StepResult; @@ -361,6 +362,9 @@ void shouldAttachTraceWhenSessionIsClosed() { assertThat(results.getAttachments()) .hasSize(1); + assertThat(attachments(results)) + .extracting(Attachment::getType) + .containsExactly(AttachmentType.PLAYWRIGHT_TRACE.getMediaType()); assertAttachmentStartsWith(results, ZIP_HEADER); } @@ -385,6 +389,9 @@ void shouldAttachTraceWhenContextIsClosed() { assertThat(results.getAttachments()) .hasSize(1); + assertThat(attachments(results)) + .extracting(Attachment::getType) + .containsExactly(AttachmentType.PLAYWRIGHT_TRACE.getMediaType()); assertAttachmentStartsWith(results, ZIP_HEADER); } @@ -408,6 +415,9 @@ void shouldAttachTraceWhenAllureLifecycleStopsTest() { assertThat(results.getAttachments()) .hasSize(1); + assertThat(attachments(results)) + .extracting(Attachment::getType) + .containsExactly(AttachmentType.PLAYWRIGHT_TRACE.getMediaType()); assertAttachmentStartsWith(results, ZIP_HEADER); }