Skip to content

Commit 127d1ed

Browse files
committed
md5 checksum
1 parent dad9b2f commit 127d1ed

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

packages/tests-e2e/tests/appRouter/og.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1+
import { createHash } from "node:crypto";
12
import { expect, test } from "@playwright/test";
23

4+
const OG_MD5 = "6e5e794ac0c27598a331690f96f05d00";
5+
const API_OG_MD5 = "cac95fc3e2d4d52870c0536bb18ba85b";
6+
7+
function validateMd5(data: Buffer, expectedHash: string) {
8+
return createHash("md5").update(data).digest("hex") === expectedHash;
9+
}
10+
311
test("Open-graph image to be in metatags and present", async ({
412
page,
513
request,
@@ -37,6 +45,7 @@ test("Open-graph image to be in metatags and present", async ({
3745
expect(response.headers()["cache-control"]).toBe(
3846
"public, immutable, no-transform, max-age=31536000",
3947
);
48+
expect(validateMd5(await response.body(), OG_MD5)).toBe(true);
4049
});
4150

4251
test("next/og (vercel/og) to work in API route", async ({ request }) => {
@@ -46,4 +55,5 @@ test("next/og (vercel/og) to work in API route", async ({ request }) => {
4655
expect(response.headers()["cache-control"]).toBe(
4756
"public, immutable, no-transform, max-age=31536000",
4857
);
58+
expect(validateMd5(await response.body(), API_OG_MD5)).toBe(true);
4959
});

0 commit comments

Comments
 (0)