Skip to content

Docs: Adjust Next.js snippets to include draftmode#33968

Merged
jonniebigodes merged 2 commits into
storybookjs:nextfrom
createhb21:docs/nextjs-draftmode-mock-example
Mar 2, 2026
Merged

Docs: Adjust Next.js snippets to include draftmode#33968
jonniebigodes merged 2 commits into
storybookjs:nextfrom
createhb21:docs/nextjs-draftmode-mock-example

Conversation

@createhb21
Copy link
Copy Markdown
Contributor

@createhb21 createhb21 commented Mar 2, 2026

What I changed

  • Added draftMode usage to docs/_snippets/nextjs-headers-mock.md for all snippet variants (CSF 3/Next, JS/TS).
  • Demonstrated how to mock draft mode state via draftMode.mockReturnValue(...).
  • Fixed an incorrect assertion in the same snippet (cookies().get('timezone') -> headers().get('timezone')).

Why

Closes #28851

Verification

  • yarn prettier --check docs/_snippets/nextjs-headers-mock.md

Summary by CodeRabbit

  • Documentation

    • Updated Next.js headers mocking documentation to include draft mode support alongside existing cookies and headers functionality.
  • Tests

    • Enhanced mock setup to verify draft mode handling with proper initialization and assertions.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 2, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b7355d8 and 109f76f.

📒 Files selected for processing (1)
  • docs/_snippets/nextjs-headers-mock.md

📝 Walkthrough

Walkthrough

A documentation snippet for Next.js headers mocking is updated to include draftMode alongside existing cookies and headers functionality, with corresponding mock setup and test assertions added across multiple code variants (CSF 3, TypeScript, and JavaScript versions).

Changes

Cohort / File(s) Summary
Next.js Headers Mock Documentation
docs/_snippets/nextjs-headers-mock.md
Added fn import from Storybook test utilities; extended headers import to include draftMode; introduced draftMode mock setup in beforeEach hook returning isEnabled, enable, and disable functions; updated test assertions to verify draftMode calls alongside timezone checks; revised documentation comments to reference draft mode handling; wired mock initialization across all code variants (CSF 3, TS, and Next.js TS/JS blocks).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • storybookjs/storybook#33380: Wires draftMode into headers mock exports and re-exports alongside the main PR's documentation updates.
  • storybookjs/storybook#33341: Changes runtime draftMode resolution in headers mock for v14 compatibility, complementing the mock setup patterns documented in this PR.

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@valentinpalkovic valentinpalkovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! @jonniebigodes Can you also please take a look?

@valentinpalkovic valentinpalkovic self-assigned this Mar 2, 2026
@valentinpalkovic valentinpalkovic added nextjs ci:normal ci:docs Run the CI jobs for documentation checks only. documentation bug and removed ci:docs Run the CI jobs for documentation checks only. labels Mar 2, 2026
@valentinpalkovic valentinpalkovic moved this to In Progress in Core Team Projects Mar 2, 2026
@jonniebigodes jonniebigodes self-assigned this Mar 2, 2026
@jonniebigodes jonniebigodes added ci:docs Run the CI jobs for documentation checks only. and removed ci:normal bug labels Mar 2, 2026
@jonniebigodes jonniebigodes changed the title Docs: add draftMode mock example to Next.js headers snippet Docs: Adjust Next.js snippets to include draftmode Mar 2, 2026
Copy link
Copy Markdown
Contributor

@jonniebigodes jonniebigodes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@createhb21 appreciate you taking the time to put together this pull request and help us improve the documentation 🙏 ! I've checked, and all is good on my end.

Will gladly merge this once the checklist clears.

Have a great day

Stay safe

@jonniebigodes jonniebigodes merged commit b4ba7cd into storybookjs:next Mar 2, 2026
7 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Core Team Projects Mar 2, 2026
@github-actions github-actions Bot mentioned this pull request Mar 3, 2026
15 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:docs Run the CI jobs for documentation checks only. documentation nextjs

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Documentation]: docs/get-started/frameworks/nextjs needs draftMode mock example

3 participants