Skip to content

Add test coverage for fetch-post-data.ts using a vendored real-content fixture #211

Description

@bbornino

packages/post-images/src/fetch-post-data.ts currently has no test coverage at all — it's the function that fetches a post's raw markdown, extracts

 blocks via remark-parse/remark-rehype, joins them, and appends the stringified source of fetchPostData itself as filler (capped at 40 lines). None of that logic is exercised by any test today; banner.test.ts/link-preview.test.ts only cover layout rendering using a hand-written code string from mockPostData().

content/fennifith/posts/example/index.md (slug example, author fennifith) already exists as the team's deliberate edge-case post — nested blockquotes with code, lists with code blocks, footnotes, emoji, HTML embeds — and is referenced elsewhere in this repo as example data (post-images.ts's route schema). It's a natural fixture for this.

Scope:

Vendor a static local copy of content/fennifith/posts/example/index.md into packages/post-images/tests/fixtures/ (not fetched live over the network — fetching from the frontend repo at test time makes coverage flaky and coupled to content changes over there).
Add fetch-post-data.test.ts (or a scoped extraction-only test if fetchPostData's network/db calls need mocking) exercising the real extraction pipeline against that fixture.
While building this, confirmed the findAllAfter(tree, 0, { tagName: "pre" }) call doesn't descend into

 elements nested inside blockquotes or list items — it only picks up top-level ones. Worth confirming whether that's intentional (only top-level code blocks are meant to feed the banner) or a real gap, and covering whichever behavior is correct with a test.

Out of scope: the satori/#125 rendering question — that's tracked separately in #125 and PR #209 and shouldn't block this.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions