Skip to content

test(share): guards share card rendering against package bumps - #3151

Merged
trakt-bot[bot] merged 1 commit into
mainfrom
test/satori
Aug 18, 2026
Merged

test(share): guards share card rendering against package bumps#3151
trakt-bot[bot] merged 1 commit into
mainfrom
test/satori

Conversation

@seferturan

@seferturan seferturan commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

🎶 Notes 🎶

  • Renders the real ShareCard through satori, so a package bump cannot silently break share images again
    • the satori 0.10 to 0.25 jump dropped every poster for six weeks and nothing caught it
    • drives the actual card through the same ImageResponse the endpoint uses, once per variant, with the existing Silo mapped mocks
    • renders to png rather than svg so resvg runs too, matching what the endpoint produces
  • Changing the card does not mean updating the test
    • that was the flaw in asserting on markup shape: it only encodes what we know satori accepts today
  • The assertion is that satori has nothing to complain about
    • satori reports rejected values on console.warn rather than throwing, so the spies require silence
    • failures are unwrapped to satori's own message, otherwise ImageResponse reports an unhelpful "Failed to generate SVG"
    • verified by reverting the poster size fix: it fails with Invalid value "265" for "height"
  • Runs on CI only, and the test job installs fontconfig
    • satori has no default font and refuses to lay out text without one, even with every string blanked
    • the alternatives were vendoring a font, maintaining a list of font paths, or making everyone install fontconfig locally
    • ⚠️ the gate is process.env.CI, not font availability, so a runner without fontconfig fails loudly instead of quietly skipping the one test meant to catch this
  • Dimensions are mocked at half scale, which takes rasterisation from 6.6s to 2.6s
    • shrinking only the canvas does not work, the card derives its own boxes from SHARE_TYPE_DIMENSIONS so the content overflows and resvg dies
    • a third scale only saves another 0.6s, fixed overhead dominates below half

🤔 Worth knowing 🤔

  • The test does not run locally, so a break shows up on push rather than before it
  • Renders client side and reassembles markup plus head styles, because resolve.conditions: ['browser'] stops ImageResponse taking the component directly. Closing that gap needs a separate vitest project with node conditions

@trakt-bot
trakt-bot Bot enabled auto-merge (rebase) August 18, 2026 15:37
@deepsource-io

deepsource-io Bot commented Aug 18, 2026

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in 010981c...ab4f1fa on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Coverage  

Code Review Summary

Analyzer Status Updated (UTC) Details
JavaScript Aug 18, 2026 3:47p.m. Review ↗
Code coverage Aug 18, 2026 3:47p.m. Review ↗

Code Coverage Summary

Language Line Coverage (Overall)
Aggregate
69.2%
[▲ up 0.3% from main]
Javascript
69.2%
[▲ up 0.3% from main]

➟ Additional coverage metrics may have been reported. See full coverage report ↗


Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

Drives the actual card, with the existing Silo mapped mocks, through the same
ImageResponse pipeline the endpoint uses, once per variant. Renders to png rather
than svg so resvg runs too, matching what the endpoint produces. Changing the
card does not require touching this test, which was the problem with asserting on
markup shape: that only encodes what we know satori accepts today.

The assertion is that a package bump cannot introduce complaints. Satori reports
rejected values on console.warn rather than throwing, so the spies require
silence. MSW lines are filtered out because yoga fetches its wasm as a data uri,
which MSW logs as an unhandled request. Failures are unwrapped to satori's own
message, otherwise ImageResponse reports an unhelpful "Failed to generate SVG".

Satori has no default font and refuses to lay out text without one, even when
every string is blank, so a face has to come from somewhere. Rather than vendor a
font, maintain a list of paths, or make every contributor install fontconfig, this
runs on CI only and the test job installs it. The gate is process.env.CI, not font
availability, so a CI runner without fontconfig fails loudly instead of quietly
skipping the one test that is supposed to catch this.

Dimensions are mocked at half scale, which cuts rasterisation from 6.6s to 2.6s.
Shrinking only the canvas is not an option: the card derives its own boxes from
SHARE_TYPE_DIMENSIONS, so the content would overflow and resvg dies on it.
Halving the whole set keeps the layout proportional. A third scale saves only
another 0.6s, since fixed overhead dominates below half.
@trakt-bot
trakt-bot Bot merged commit 4c8dac5 into main Aug 18, 2026
24 checks passed
@trakt-bot
trakt-bot Bot deleted the test/satori branch August 18, 2026 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants