Skip to content

test(content-blog): regression-test trailingSlash on feed URLs (AI-assisted)#12022

Open
LeSingh1 wants to merge 1 commit into
facebook:mainfrom
LeSingh1:assert-trailing-slash-in-feed-urls
Open

test(content-blog): regression-test trailingSlash on feed URLs (AI-assisted)#12022
LeSingh1 wants to merge 1 commit into
facebook:mainfrom
LeSingh1:assert-trailing-slash-in-feed-urls

Conversation

@LeSingh1
Copy link
Copy Markdown

Pre-flight checklist

  • I have read the Contributing Guidelines on pull requests.
  • If this is a code change: I have written unit tests and/or added dogfooding pages to fully verify the new behavior.
  • If this is a new API or substantial change: the PR has an accompanying issue (closes #0000) and the maintainers have approved on my working plan.

Motivation

Adds an explicit regression test for the trailing-slash behavior of blog feed URLs. The existing feed.test.ts > with trailing slash snapshot already captures the URLs, but a regression in feed.ts would just nudge the snapshot and could pass review unnoticed. This adds a programmatic assertion that fails loudly with a descriptive message.

What this PR does

In packages/docusaurus-plugin-content-blog/src/__tests__/feed.test.ts, inside the existing describe.each(['atom', 'rss', 'json']) block, adds one new test that:

  • builds feeds with trailingSlash: true against the existing __fixtures__/website fixture,
  • extracts URLs only from feed-structural positions (<id>, <link>, <guid>, JSON id / url / home_page_url / feed_url) because CDATA bodies and content_html may legitimately contain author-written non-slashed links,
  • asserts every blog URL ends with /,
  • wraps assertions in try / finally with fsMock.mockClear() so a failure in one parameterized variant doesn't leak fsMock state into the next.

No production code is changed.

Test plan

  • yarn test packages/docusaurus-plugin-content-blog/src/__tests__/feed.test.ts — 24/24 pass.
  • yarn tsc --noEmit for the package — clean.
  • yarn lint:js — no new warnings.
  • Mutation check: removed applyTrailingSlash from feed.ts:130 and confirmed all 3 new parameterized variants fail with the descriptive message atom/rss/json feed URL should end with "/"; restored after.

Related issue

Adds explicit regression coverage for #7656.

The behavior is already correct on current main, so this PR does not change production code. It makes the feed URL trailing-slash behavior fail loudly if it regresses again.

Notes

AI-assisted, per AGENTS.md.

@meta-cla meta-cla Bot added the CLA Signed Signed Facebook CLA label May 15, 2026
@netlify
Copy link
Copy Markdown

netlify Bot commented May 15, 2026

[V2]

Built without sensitive environment variables

Name Link
🔨 Latest commit f6b59d6
🔍 Latest deploy log https://app.netlify.com/projects/docusaurus-2/deploys/6a06c09aa38bd60008e6129f
😎 Deploy Preview https://deploy-preview-12022--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

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

Labels

CLA Signed Signed Facebook CLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant