You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After the Storybook 8.1 release announcement, I was intrigued by the idea of write Storybook stories for my page components that are written with the Next.js App Router. So I started digging into the example repository that's mentioned in the blog post, and I've been digging into the code that powers the Next.js mocks that Storybook has published.
The page component that I'm attempting to write story for is wrapped with a call withPageAuthRequired function, and I don't see any published resources for how to use or craft mocks for this library.
Describe the ideal solution
I'd ideally like to see official mocks published with this package or published in a sibling package.
Alternatives and current workarounds
I've attempted to dig into the session handling logic to see if there's a way that I can simulate a valid session by mocking the cookie access, since there is already a published mock for doing so (see example usage). However, it looks like I would need to duplicate the logic that is used to encrypt the contents of the cookie. I would rather just be able to mock whether or not someone is logged in along with the profile information that would be provided by useUser.
Additional context
There is an additional blog post that Storybook has published which outlines the module mocking approach that they are following. All of the mocks that Storybook ships for Next can be found in that project's export-mocks folder. I suspect that it's going to be a good resource to learn from.
The text was updated successfully, but these errors were encountered:
Checklist
Describe the problem you'd like to have solved
After the Storybook 8.1 release announcement, I was intrigued by the idea of write Storybook stories for my page components that are written with the Next.js App Router. So I started digging into the example repository that's mentioned in the blog post, and I've been digging into the code that powers the Next.js mocks that Storybook has published.
The page component that I'm attempting to write story for is wrapped with a call
withPageAuthRequired
function, and I don't see any published resources for how to use or craft mocks for this library.Describe the ideal solution
I'd ideally like to see official mocks published with this package or published in a sibling package.
Alternatives and current workarounds
I've attempted to dig into the session handling logic to see if there's a way that I can simulate a valid session by mocking the cookie access, since there is already a published mock for doing so (see example usage). However, it looks like I would need to duplicate the logic that is used to encrypt the contents of the cookie. I would rather just be able to mock whether or not someone is logged in along with the profile information that would be provided by
useUser
.Additional context
There is an additional blog post that Storybook has published which outlines the module mocking approach that they are following. All of the mocks that Storybook ships for Next can be found in that project's
export-mocks
folder. I suspect that it's going to be a good resource to learn from.The text was updated successfully, but these errors were encountered: