Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Mocks for Storybook #1755

Open
5 tasks done
mscottford opened this issue Jun 4, 2024 · 0 comments
Open
5 tasks done

Add Mocks for Storybook #1755

mscottford opened this issue Jun 4, 2024 · 0 comments

Comments

@mscottford
Copy link

Checklist

  • I have looked into the Readme, Examples, and FAQ and have not found a suitable solution or answer.
  • I have looked into the API documentation and have not found a suitable solution or answer.
  • I have searched the issues and have not found a suitable solution or answer.
  • I have searched the Auth0 Community forums and have not found a suitable solution or answer.
  • I agree to the terms within the Auth0 Code of Conduct.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant