Add Tests for DEFAULT_FONTS_BASE64 Coverage in SVG Generator - #8326
Add Tests for DEFAULT_FONTS_BASE64 Coverage in SVG Generator#8326ChetanSenta wants to merge 1 commit into
Conversation
… unreachable in every test due to NODE_ENV=test override
|
This pull request addresses the lack of test coverage for the DEFAULT_FONTS_BASE64 constant in the SVG generator. It introduces tests that directly check the constant and also validate the font embedding functionality in a production-like environment. This aligns with our previous decisions to enhance testing practices, such as adding unit tests for timezone normalization and implementing visual regression testing for SVG generators. Thank you for your contribution, and I look forward to your updates! |
📦 Next.js Bundle Size Report (Gzipped Sizes)✨ No significant bundle size changes detected. 📊 Summary of Totals
|
Aamod007
left a comment
There was a problem hiding this comment.
Clean test additions for font coverage in the SVG generator. CI pending — once green, good to merge.
Labels: level:beginner (1 file), quality:clean, type:testing, mentor:Aamod007
Aamod007
left a comment
There was a problem hiding this comment.
Re-reviewing after noting the only CI failure is Vercel authorization (not code-related). All other checks (Format · Lint · Typecheck · Test, Production Build, CodeQL) pass. Approving — the Vercel deploy auth is a repo-level config issue, not a code problem.
Description
Fixes #8325
Pillar
Visual Preview
No visual change — pure test additions.
What this PR does
All 16 occurrences of
process.env.NODE_ENV === 'test' ? <google-fonts-url> : DEFAULT_FONTS_BASE64in
lib/svg/generator.tsmeanDEFAULT_FONTS_BASE64(the real,production font-embedding constant in
lib/svg/fonts.ts) is neveractually rendered by any existing test, since Vitest sets
NODE_ENV=test. Addedlib/svg/fonts.test.ts: direct structural checkson the constant itself (bypassing the branch entirely), plus one test
that temporarily overrides
NODE_ENVto confirm a real generatorfunction actually embeds the real font CSS in production.
Checklist before requesting a review:
CONTRIBUTING.mdfile.npm run formatandnpm run lintlocally and resolved all errors.