diff --git a/README.md b/README.md index 8da1212..5aa3264 100644 --- a/README.md +++ b/README.md @@ -132,4 +132,4 @@ BASE_URL=https://og.qurancdn.com yarn test ### Test Coverage - **OG Image Generation**: Validates that all endpoints return valid PNG images -- **Visual Regression**: Compares generated images against baseline snapshots for all 12 supported languages (ar, bn, en, es, fa, fr, id, ms, nl, sw, tr, ur) +- **Visual Regression**: Compares generated images against baseline snapshots for all 13 supported languages (ar, bn, en, es, fa, fr, id, ms, nl, sw, tr, ur, vi) diff --git a/public/premade/og-ar.png b/public/premade/og-ar.png index 05f1859..c73c938 100644 Binary files a/public/premade/og-ar.png and b/public/premade/og-ar.png differ diff --git a/public/premade/og-bn.png b/public/premade/og-bn.png index 28eb11d..8737bf2 100644 Binary files a/public/premade/og-bn.png and b/public/premade/og-bn.png differ diff --git a/public/premade/og-en.png b/public/premade/og-en.png index b8bbd7f..753ee5e 100644 Binary files a/public/premade/og-en.png and b/public/premade/og-en.png differ diff --git a/public/premade/og-es.png b/public/premade/og-es.png index daa90f7..69cb1cf 100644 Binary files a/public/premade/og-es.png and b/public/premade/og-es.png differ diff --git a/public/premade/og-fa.png b/public/premade/og-fa.png index 2dac240..18880b4 100644 Binary files a/public/premade/og-fa.png and b/public/premade/og-fa.png differ diff --git a/public/premade/og-fr.png b/public/premade/og-fr.png index f50151b..99b89b7 100644 Binary files a/public/premade/og-fr.png and b/public/premade/og-fr.png differ diff --git a/public/premade/og-id.png b/public/premade/og-id.png index 18b220d..bb07632 100644 Binary files a/public/premade/og-id.png and b/public/premade/og-id.png differ diff --git a/public/premade/og-ms.png b/public/premade/og-ms.png index a859196..42823ef 100644 Binary files a/public/premade/og-ms.png and b/public/premade/og-ms.png differ diff --git a/public/premade/og-nl.png b/public/premade/og-nl.png index f9cec20..7a72cc8 100644 Binary files a/public/premade/og-nl.png and b/public/premade/og-nl.png differ diff --git a/public/premade/og-quran-com.png b/public/premade/og-quran-com.png new file mode 100644 index 0000000..1b76b83 Binary files /dev/null and b/public/premade/og-quran-com.png differ diff --git a/public/premade/og-quran-foundation.png b/public/premade/og-quran-foundation.png new file mode 100644 index 0000000..ccb4419 Binary files /dev/null and b/public/premade/og-quran-foundation.png differ diff --git a/public/premade/og-quran-reflect.png b/public/premade/og-quran-reflect.png new file mode 100644 index 0000000..986f483 Binary files /dev/null and b/public/premade/og-quran-reflect.png differ diff --git a/public/premade/og-sw.png b/public/premade/og-sw.png index 0a3efee..4eb9d1d 100644 Binary files a/public/premade/og-sw.png and b/public/premade/og-sw.png differ diff --git a/public/premade/og-tr.png b/public/premade/og-tr.png index 935a541..9ca4343 100644 Binary files a/public/premade/og-tr.png and b/public/premade/og-tr.png differ diff --git a/public/premade/og-ur.png b/public/premade/og-ur.png index 53921ee..c25e295 100644 Binary files a/public/premade/og-ur.png and b/public/premade/og-ur.png differ diff --git a/public/premade/og-vi.png b/public/premade/og-vi.png index e484d9e..189fc1d 100644 Binary files a/public/premade/og-vi.png and b/public/premade/og-vi.png differ diff --git a/public/premade/og_daily.png b/public/premade/og_daily.png index 8a7ac85..517f7f9 100644 Binary files a/public/premade/og_daily.png and b/public/premade/og_daily.png differ diff --git a/public/premade/og_explore_answers.png b/public/premade/og_explore_answers.png index d6fc579..b77b591 100644 Binary files a/public/premade/og_explore_answers.png and b/public/premade/og_explore_answers.png differ diff --git a/public/premade/og_learning_plans.png b/public/premade/og_learning_plans.png index 1de74a4..2b8f47a 100644 Binary files a/public/premade/og_learning_plans.png and b/public/premade/og_learning_plans.png differ diff --git a/public/premade/og_media.png b/public/premade/og_media.png index 58371a9..f739ee5 100644 Binary files a/public/premade/og_media.png and b/public/premade/og_media.png differ diff --git a/public/premade/og_quran_reader_study_mode_hadith.png b/public/premade/og_quran_reader_study_mode_hadith.png index 166ac7a..e0d04f9 100644 Binary files a/public/premade/og_quran_reader_study_mode_hadith.png and b/public/premade/og_quran_reader_study_mode_hadith.png differ diff --git a/public/premade/og_quran_reader_study_mode_layers.png b/public/premade/og_quran_reader_study_mode_layers.png index ad59419..f430136 100644 Binary files a/public/premade/og_quran_reader_study_mode_layers.png and b/public/premade/og_quran_reader_study_mode_layers.png differ diff --git a/public/premade/og_quran_reader_study_mode_lessons.png b/public/premade/og_quran_reader_study_mode_lessons.png index 5bf6fc9..7f87d73 100644 Binary files a/public/premade/og_quran_reader_study_mode_lessons.png and b/public/premade/og_quran_reader_study_mode_lessons.png differ diff --git a/public/premade/og_quran_reader_study_mode_qiraat.png b/public/premade/og_quran_reader_study_mode_qiraat.png index 8959b4b..fe08fff 100644 Binary files a/public/premade/og_quran_reader_study_mode_qiraat.png and b/public/premade/og_quran_reader_study_mode_qiraat.png differ diff --git a/public/premade/og_quran_reader_study_mode_reflections.png b/public/premade/og_quran_reader_study_mode_reflections.png index cd48952..ec19676 100644 Binary files a/public/premade/og_quran_reader_study_mode_reflections.png and b/public/premade/og_quran_reader_study_mode_reflections.png differ diff --git a/public/premade/og_quran_reader_study_mode_related_verses.png b/public/premade/og_quran_reader_study_mode_related_verses.png index d381b89..9fd46b0 100644 Binary files a/public/premade/og_quran_reader_study_mode_related_verses.png and b/public/premade/og_quran_reader_study_mode_related_verses.png differ diff --git a/public/premade/og_quran_reader_study_mode_tafsir.png b/public/premade/og_quran_reader_study_mode_tafsir.png index e5bbf53..b5c1aaa 100644 Binary files a/public/premade/og_quran_reader_study_mode_tafsir.png and b/public/premade/og_quran_reader_study_mode_tafsir.png differ diff --git a/tests/approved-og-assets.spec.ts b/tests/approved-og-assets.spec.ts new file mode 100644 index 0000000..da28521 --- /dev/null +++ b/tests/approved-og-assets.spec.ts @@ -0,0 +1,51 @@ +import { expect, test } from '@playwright/test'; +import crypto from 'crypto'; +import fs from 'fs'; +import path from 'path'; + +const APPROVED_OG_SHA256: Record = { + 'og-ar.png': '3b25654966d43b2bd4e5986a3ab77281064dc04f391c65d371b9fcede996d25e', + 'og-bn.png': 'a8d4ab7bad7481c1035e86d20036c63657a2116000af953014168ac956518a3e', + 'og-en.png': '65fff042983e44102d4b739c9ef4402370853fbe248dae14a6b0be7673e7e106', + 'og-es.png': '00712bfccec5c7510e239dfb8989b0eb33b1434e7dfb7bad6f6715bd30823b14', + 'og-fa.png': 'be2d05430cdde9ad08f425e5f6b8a6777c4602599c81ef6567c4168220ff2270', + 'og-fr.png': 'cbb3007d598e3502f84c8b74a8acece708e1256710daeb8089f6dd0f5d5723c9', + 'og-id.png': 'd0cc81d34439f082d97f403ae6fdf8a4eb6fe452274b68f92d021fa1c39759a0', + 'og-ms.png': '5fb9d7bfb9e3dcb2fea3ec457941e1231e71dd3372a632d6cbc77f66f89ad47c', + 'og-nl.png': '9f6a8ffd1796de033ae620dd7e5ecbd1e65f3adce0e03bacbf1fbae73c627e68', + 'og-quran-com.png': 'b8f41856bf937e310b9bc4ab9b99879a989aede9f02b6a4f1a21f5b96d28ca37', + 'og-quran-foundation.png': '177cd472cdce941ceef07112b04372a92bcfbd456a95309129268d7cdd3a3a45', + 'og-quran-reflect.png': '367d5fa72615f12c09ef48af6e4834f98012f9d5206effcd7644a8ec61a98fab', + 'og-sw.png': 'f8d02c367dfd11396c7d039820578c1a895cb8370563142a040ed1e5ac7f5fbe', + 'og-tr.png': 'df959f79e7eb943d623314148ff41e88909f5d95ac3395ead7efef53c243b25a', + 'og-ur.png': 'dd8a75766c6ecc950c23cc11124726b14871195d3394e2ad0addc11ef792c7fd', + 'og-vi.png': '9730d97d6487ff60d944b6d2bc557703013ae57eb0fe6b399702c72d7a037115', + 'og_daily.png': '245a145ba80fa13077674d4565672a918ff7792aa7e25b9c32850b7de5ff113f', + 'og_explore_answers.png': '115c6c5847d976bc1272661df8443c0b9d25f42631e62f5e8019b6f047b42a80', + 'og_learning_plans.png': '4f119d4479ec52c2379a8fc82b62a035879d3368b243614c711f9d157272d99d', + 'og_media.png': 'da7127e67e9f1059611a69de8b9de1d5023f674ccb484a8012b811668585575b', + 'og_quran_reader_study_mode_hadith.png': + '9bec61c3107305c86953828081e6389c78918850dd1f08646df902398f355798', + 'og_quran_reader_study_mode_layers.png': + '350cfc92efdf035e02859d5d75cc5310436ed1a2b9f498614efd0b2cc2f02f44', + 'og_quran_reader_study_mode_lessons.png': + '237d2798c65e4e672f18c54289b037005ce71d266ee566f62ef6256e1ec17ef4', + 'og_quran_reader_study_mode_qiraat.png': + 'f1f9e880de60f4c46a7f6ad36676bfd15c737c28c0f1858aa34df957bea34f4f', + 'og_quran_reader_study_mode_reflections.png': + 'af90c5c52118587ced231a95c02caa84deaebd41457abd8af2b24c3fc063679f', + 'og_quran_reader_study_mode_related_verses.png': + 'fadbe14202b9befe6e36afa5e40cdbc83e2c73356991d299a23affcfd95cb047', + 'og_quran_reader_study_mode_tafsir.png': + '36b128db486ef24853137510494cf2192a1cdb89560155090e287445d003a324', +}; + +test('approved Open Graph assets retain their source dimensions and contents', () => { + Object.entries(APPROVED_OG_SHA256).forEach(([fileName, expectedHash]) => { + const image = fs.readFileSync(path.join(process.cwd(), 'public/premade', fileName)); + + expect(image.readUInt32BE(16), `${fileName} width`).toBe(1200); + expect(image.readUInt32BE(20), `${fileName} height`).toBe(630); + expect(crypto.createHash('sha256').update(image).digest('hex'), fileName).toBe(expectedHash); + }); +}); diff --git a/tests/og-images.spec.ts b/tests/og-images.spec.ts index 15445f6..6355e08 100644 --- a/tests/og-images.spec.ts +++ b/tests/og-images.spec.ts @@ -14,6 +14,7 @@ const LANGUAGES = [ "sw", "tr", "ur", + "vi", ]; // All static OG pages (endpoints without dynamic parameters)