From 80df59acdb21a63b8e3788994aaa1ac57d686fe8 Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Fri, 11 Apr 2025 11:21:31 -0600 Subject: [PATCH] mock router for my components --- web/.storybook/main.ts | 11 ++++++++++- web/.storybook/mocks/next-navigation.ts | 11 +++++++++++ web/src/components/ui/buttons/Button.stories.tsx | 7 ------- 3 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 web/.storybook/mocks/next-navigation.ts diff --git a/web/.storybook/main.ts b/web/.storybook/main.ts index a494a8fa6..7fd7646c5 100644 --- a/web/.storybook/main.ts +++ b/web/.storybook/main.ts @@ -1,4 +1,5 @@ import type { StorybookConfig } from '@storybook/nextjs'; +import path from 'path'; const config: StorybookConfig = { stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'], @@ -11,6 +12,14 @@ const config: StorybookConfig = { name: '@storybook/nextjs', options: {} }, - staticDirs: ['../public'] + staticDirs: ['../public'], + webpackFinal: async (config) => { + config.resolve = config.resolve || {}; + config.resolve.alias = { + ...(config.resolve.alias || {}), + 'next/navigation': path.resolve(__dirname, './mocks/next-navigation.ts') + }; + return config; + } }; export default config; diff --git a/web/.storybook/mocks/next-navigation.ts b/web/.storybook/mocks/next-navigation.ts new file mode 100644 index 000000000..82363f0b5 --- /dev/null +++ b/web/.storybook/mocks/next-navigation.ts @@ -0,0 +1,11 @@ +// mocks/next-navigation.ts +export const useRouter = () => ({ + push: () => {}, + replace: () => {}, + refresh: () => {}, + back: () => {} +}); + +export const usePathname = () => '/'; +export const useSearchParams = () => new URLSearchParams(); +export const useParams = () => ({}); diff --git a/web/src/components/ui/buttons/Button.stories.tsx b/web/src/components/ui/buttons/Button.stories.tsx index c53841029..849339f30 100644 --- a/web/src/components/ui/buttons/Button.stories.tsx +++ b/web/src/components/ui/buttons/Button.stories.tsx @@ -102,13 +102,6 @@ export const Disabled: Story = { } }; -export const AsChild: Story = { - args: { - asChild: true, - children: Link Button - } -}; - export const Loading: Story = { args: { variant: 'default',