diff --git a/packages/reader-api/src/detect.ts b/packages/reader-api/src/detect.ts index 9d00c89fbfa..7cc17d2a580 100644 --- a/packages/reader-api/src/detect.ts +++ b/packages/reader-api/src/detect.ts @@ -83,6 +83,28 @@ const rawMagics: RawMagic[] = [ }, extensions: [".png"], }, + { + name: "image/webp", + priority: 50, + clause: { + clause: "and", + nested: [ + { + clause: "match", + value: "RIFF", + type: "string", + offset: "0", + }, + { + clause: "match", + value: "WEBP", + type: "string", + offset: "8", + }, + ], + }, + extensions: [".webp"], + }, { name: "application/x-gtar", priority: 50, diff --git a/packages/reader-api/test/resources/sample.webp b/packages/reader-api/test/resources/sample.webp new file mode 100644 index 00000000000..c2d1e287429 Binary files /dev/null and b/packages/reader-api/test/resources/sample.webp differ diff --git a/packages/reader-api/test/utils.ts b/packages/reader-api/test/utils.ts index c294b2a5b6b..c5723a4b909 100644 --- a/packages/reader-api/test/utils.ts +++ b/packages/reader-api/test/utils.ts @@ -8,9 +8,10 @@ export const readResource = async (path: string) => readFile(buildResourcePath(p export const resources = [ ["sample.png", "image/png"], ["sample.gif", "image/gif"], - ["sample.png", "image/png"], + ["sample.bmp", "image/bmp"], ["sample.tiff", "image/tiff"], ["sample.jpeg", "image/jpeg"], + ["sample.webp", "image/webp"], ["sample.svg", "image/svg+xml"], ["short.svg", "image/svg+xml"], ]; diff --git a/packages/reader/src/xcresult/utils.ts b/packages/reader/src/xcresult/utils.ts index f3dc8756a45..1f21b274764 100644 --- a/packages/reader/src/xcresult/utils.ts +++ b/packages/reader/src/xcresult/utils.ts @@ -83,6 +83,8 @@ export const utiToMediaType: Record = { "public.tiff": "image/tiff", "com.apple.pict": "image/x-pict", "public.png": "image/png", + "public.webp": "image/webp", + "org.webmproject.webp": "image/webp", "public.xbitmap-image": "image/x-quicktime", "com.apple.quicktime-image": "image/x-quicktime", "com.apple.quicktime-movie": "video/quicktime", diff --git a/packages/web-awesome/src/components/TestResult/TrSteps/TrAttachment.tsx b/packages/web-awesome/src/components/TestResult/TrSteps/TrAttachment.tsx index 2469eb9d361..1b307f9e6b8 100644 --- a/packages/web-awesome/src/components/TestResult/TrSteps/TrAttachment.tsx +++ b/packages/web-awesome/src/components/TestResult/TrSteps/TrAttachment.tsx @@ -46,6 +46,7 @@ const iconMap: Record = { "text/uri-list": lineFilesFileAttachment2, "image/svg+xml": lineImagesImage, "image/png": lineImagesImage, + "image/webp": lineImagesImage, "application/json": lineFilesFileAttachment2, "application/zip": lineFilesFileAttachment2, "video/webm": lineImagesImage, diff --git a/packages/web-classic/src/components/TestResult/TestResultSteps/testResultAttachment.tsx b/packages/web-classic/src/components/TestResult/TestResultSteps/testResultAttachment.tsx index 3eaabcd0ca3..e1146aa3087 100644 --- a/packages/web-classic/src/components/TestResult/TestResultSteps/testResultAttachment.tsx +++ b/packages/web-classic/src/components/TestResult/TestResultSteps/testResultAttachment.tsx @@ -22,6 +22,7 @@ const iconMap: Record = { "text/uri-list": lineFilesFileAttachment2, "image/svg+xml": lineImagesImage, "image/png": lineImagesImage, + "image/webp": lineImagesImage, "application/json": lineFilesFileAttachment2, "application/zip": lineFilesFileAttachment2, "video/webm": lineImagesImage, diff --git a/packages/web-classic/src/utils/attachments.ts b/packages/web-classic/src/utils/attachments.ts index a9ef223d654..ae03fd3f2f1 100644 --- a/packages/web-classic/src/utils/attachments.ts +++ b/packages/web-classic/src/utils/attachments.ts @@ -84,6 +84,7 @@ export const attachmentType = (type: string) => { case "image/jpeg": case "image/jpg": case "image/png": + case "image/webp": case "image/*": return { type: "image", diff --git a/packages/web-classic/test/utils/attachments.test.ts b/packages/web-classic/test/utils/attachments.test.ts index 21663c11b3a..1db5821e2ec 100644 --- a/packages/web-classic/test/utils/attachments.test.ts +++ b/packages/web-classic/test/utils/attachments.test.ts @@ -15,4 +15,8 @@ describe("utils > attachments", () => { expect(attachmentType("text/csv; charset=utf-8")).toEqual({ type: "table", icon: "csv" }); expect(attachmentType("text/tab-separated-values; charset=utf-8")).toEqual({ type: "table", icon: "table" }); }); + + it("detects image attachments including webp", () => { + expect(attachmentType("image/webp")).toEqual({ type: "image", icon: "file" }); + }); }); diff --git a/packages/web-commons/src/attachments.ts b/packages/web-commons/src/attachments.ts index 13147f6b0fc..710a97a08b7 100644 --- a/packages/web-commons/src/attachments.ts +++ b/packages/web-commons/src/attachments.ts @@ -284,6 +284,7 @@ export const attachmentType = (type?: string): AttachmentType | null => { case "image/jpeg": case "image/jpg": case "image/png": + case "image/webp": case "image/*": return "image"; case "text/xml": diff --git a/packages/web-commons/test/attachments.test.ts b/packages/web-commons/test/attachments.test.ts index 75c621db280..b16e72de280 100644 --- a/packages/web-commons/test/attachments.test.ts +++ b/packages/web-commons/test/attachments.test.ts @@ -23,6 +23,10 @@ describe("attachmentType", () => { it("recognizes Playwright trace attachments as archives", () => { expect(attachmentType("application/vnd.allure.playwright-trace")).toBe("archive"); }); + + it("recognizes image attachments including webp", () => { + expect(attachmentType("image/webp")).toBe("image"); + }); }); describe("blobAttachment", () => {