Add unit tests for the robots.txt, sitemap.xml and news getServerSideProps handlers - #270
Merged
Merged
Conversation
…Props handlers The crawler-document routes and the News page were the last three getServerSideProps handlers with no coverage. utils/sitemap.ts and utils/newsStorage.ts were already tested, but the route wiring around them - content type, written body, per-request NEXT_PUBLIC_BASE_URL reads, and feeding the plugin catalogue through guideSitemapPaths - was not. Characterization tests only; no production code changed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
ReturnType<typeof vi.fn> is Mock<any[], any>, which left the spy calls untyped and forced a String() coercion when reading the written body. Naming the argument tuples keeps the tests honest about the response surface the routes actually use. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Member
Author
Self-review rubricScored against the CI run on head SHA
Findings folded in from reading the diff
Verification noteLocal This comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
getServerSidePropshandlers that had none:pages/robots.txt.ts,pages/sitemap.xml.ts, andpages/news.tsx. The home page and the guide page were already covered.utils/sitemap.ts,utils/newsStorage.ts) were already tested; what was untested was the route wiring around them — theContent-Typeheader, the body actually written to the response,res.end()being called, and the{props: {}}return.NEXT_PUBLIC_BASE_URLper request rather than caching an origin at import time, which is the behaviour the comment inutils/seo.tsclaims for them.pages/data/plugins.json(read from the real catalogue, not a fixture), so a regression that stops feeding the catalogue throughguideSitemapPathsis caught.getNewsPosts()through unmodified — same list, same order, empty list preserved — with the storage layer mocked so the shareddata/news.jsonfixture is never touched.No tracking issue — gap found during triage. This cycle was run as a test-expansion cycle because every open issue in the backlog is feature-sized or blocked (see below).
Test plan
npm run lintnpm test— the three new files pass alongside the existing suitenpm run buildLocal verification is UNVERIFIED for this branch:
npmis unavailable andnode_modulesis absent in the environment this branch was authored in, so lint/test/build could not be executed locally. CI on this pull request's head SHA is the anchor, and this pull request is not to be merged until that run is green. Only test files andCHANGELOG.mdare touched, both of which CI'snpm test/npm run lintjobs execute directly.Issues deferred this cycle
Recorded here for auditability rather than as individual comments on each issue:
plugin.ymlwas considered, but outbound fetches to GitHub repository contents were unavailable in this environment, so the approach could not be verified before being coded against.dpc-api; depends on the ingestion in Pull discord server announcements into News page as posts #24 and needs safety-guard design mirroring the faction sync.plugins.json; feature-sized, with authentication and persistence decisions attached.compose.yml; a deployment-affecting infrastructure change that warrants human review rather than autonomous work.This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).