Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const config = {
'@storybook/addon-docs',
'@storybook/addon-themes',
'storybook-i18n',
'msw-storybook-addon',
],
framework: '@storybook-vue/nuxt',
staticDirs: ['./.public', { from: '../public', to: '/' }],
Expand Down
6 changes: 2 additions & 4 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ import { addons } from 'storybook/preview-api'
import { currentLocales } from '../config/i18n'
import { fn } from 'storybook/test'
import { ACCENT_COLORS } from '../shared/utils/constants'
import { initialize, mswLoader } from 'msw-storybook-addon'
import { mswLoader } from 'msw-storybook-addon/csf3'

import npmxDark from './theme'

initialize()

// @ts-expect-error - dynamic global name
globalThis.defineOgImage = fn()

Expand Down Expand Up @@ -95,7 +93,7 @@ const preview: Preview = {
}
},
],
loaders: [mswLoader],
loaders: [mswLoader()],
}

export default preview
17 changes: 7 additions & 10 deletions app/pages/about.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ import { contributorsHandler } from '../storybook/mocks/handlers'

const meta = {
component: About,

beforeEach({ msw }) {
msw.use(contributorsHandler)
},

parameters: {
layout: 'fullscreen',
msw: {
handlers: [contributorsHandler],
},
},

decorators: [pageDecorator],
} satisfies Meta<typeof About>

Expand All @@ -21,10 +24,4 @@ type Story = StoryObj<typeof meta>
export const Default: Story = {}

/** Contributors section is hidden with no API response. */
export const WithoutContributors: Story = {
parameters: {
msw: {
handlers: [],
},
},
}
export const WithoutContributors: Story = {}
31 changes: 13 additions & 18 deletions app/pages/leaderboard/likes.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ import {

const meta = {
component: LikesLeaderboard,

beforeEach({ msw }) {
msw.use(likesLeaderboardHandler)
},

parameters: {
layout: 'fullscreen',
msw: {
handlers: [likesLeaderboardHandler],
},
},

decorators: [pageDecorator],
} satisfies Meta<typeof LikesLeaderboard>

Expand All @@ -26,22 +29,14 @@ export const Default: Story = {}

/** Exactly three entries returned — only the podium section is rendered, no remaining list below. */
export const PodiumOnly: Story = {
parameters: {
msw: {
handlers: [
http.get('/api/leaderboard/likes', () =>
HttpResponse.json(likesLeaderboardEntries.slice(0, 3)),
),
],
},
beforeEach({ msw }) {
msw.use(
http.get('/api/leaderboard/likes', () =>
HttpResponse.json(likesLeaderboardEntries.slice(0, 3)),
),
)
},
}

/** Unavailable card is shown with no API response; `useFetch` falls back to its `default: () => []`. */
export const WithoutEntries: Story = {
parameters: {
msw: {
handlers: [],
},
},
}
export const WithoutEntries: Story = {}
17 changes: 7 additions & 10 deletions app/pages/pds.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ import { pdsUsersHandler } from '../storybook/mocks/handlers'

const meta = {
component: Pds,

beforeEach({ msw }) {
msw.use(pdsUsersHandler)
},

parameters: {
layout: 'fullscreen',
msw: {
handlers: [pdsUsersHandler],
},
},

decorators: [pageDecorator],
} satisfies Meta<typeof Pds>

Expand All @@ -21,10 +24,4 @@ type Story = StoryObj<typeof meta>
export const Default: Story = {}

/** Community section shows an empty/loading state with no API response. */
export const WithoutUsers: Story = {
parameters: {
msw: {
handlers: [],
},
},
}
export const WithoutUsers: Story = {}
17 changes: 7 additions & 10 deletions app/pages/recharging.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ import { repoStatsHandler } from '../storybook/mocks/handlers'

const meta = {
component: Recharging,

beforeEach({ msw }) {
msw.use(repoStatsHandler)
},

parameters: {
layout: 'fullscreen',
msw: {
handlers: [repoStatsHandler],
},
},

decorators: [pageDecorator],
} satisfies Meta<typeof Recharging>

Expand All @@ -21,10 +24,4 @@ type Story = StoryObj<typeof meta>
export const Default: Story = {}

/** Stats grid is hidden with no API response; the rest of the page renders normally. */
export const WithoutStats: Story = {
parameters: {
msw: {
handlers: [],
},
},
}
export const WithoutStats: Story = {}
13 changes: 4 additions & 9 deletions app/pages/settings.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ const meta = {
globals: {
locale: 'en-US',
},
beforeEach: () => localStorage.removeItem('npmx-settings'),
beforeEach({ msw }) {
localStorage.removeItem('npmx-settings')
msw.use(i18nStatusHandler)
},
parameters: {
layout: 'fullscreen',
msw: {
handlers: [i18nStatusHandler],
},
},
decorators: [pageDecorator],
} satisfies Meta<typeof Settings>
Expand Down Expand Up @@ -47,9 +47,4 @@ export const WithoutTranslationHelper: Story = {
globals: {
locale: 'fr-FR',
},
parameters: {
msw: {
handlers: [],
},
},
}
17 changes: 7 additions & 10 deletions app/pages/translation-status.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ import { i18nStatusHandler } from '../storybook/mocks/handlers/lunaria-status'

const meta = {
component: TranslationStatus,

beforeEach({ msw }) {
msw.use(i18nStatusHandler)
},

parameters: {
layout: 'fullscreen',
msw: {
handlers: [i18nStatusHandler],
},
},

decorators: [pageDecorator],
} satisfies Meta<typeof TranslationStatus>

Expand All @@ -21,10 +24,4 @@ type Story = StoryObj<typeof meta>
export const Default: Story = {}

/** No API response — the fetch never succeeds so `fetchStatus` stays as `'pending'`. Shows skeleton blocks in the locale list and skeleton inlines in body text. */
export const WithoutTranslationData: Story = {
parameters: {
msw: {
handlers: [],
},
},
}
export const WithoutTranslationData: Story = {}
18 changes: 10 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ catalogs:
'@storybook/addon-a11y': '^10.3.5'
'@storybook/addon-docs': '^10.3.5'
'@storybook/addon-themes': '^10.3.5'
'msw-storybook-addon': '^2.0.7'
'msw-storybook-addon': '^3.0.0'
'storybook': '^10.3.1'
'storybook-i18n': '^10.1.1'

Expand Down
Loading