Skip to content

Commit 8b5edf2

Browse files
docs(ui): add stories for Translation Status page (#2559)
1 parent 8117059 commit 8b5edf2

File tree

4 files changed

+388
-66
lines changed

4 files changed

+388
-66
lines changed

app/pages/settings.stories.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Settings from './settings.vue'
22
import type { Meta, StoryObj } from '@storybook-vue/nuxt'
33
import { userEvent, expect } from 'storybook/test'
44
import { pageDecorator } from '../../.storybook/decorators'
5-
import { i18nStatusHandler } from '../storybook/mocks/handlers'
5+
import { i18nStatusHandler } from '../storybook/mocks/handlers/lunaria-status'
66

77
const meta = {
88
component: Settings,
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import TranslationStatus from './translation-status.vue'
2+
import type { Meta, StoryObj } from '@storybook-vue/nuxt'
3+
import { pageDecorator } from '../../.storybook/decorators'
4+
import { i18nStatusHandler } from '../storybook/mocks/handlers/lunaria-status'
5+
6+
const meta = {
7+
component: TranslationStatus,
8+
parameters: {
9+
layout: 'fullscreen',
10+
msw: {
11+
handlers: [i18nStatusHandler],
12+
},
13+
},
14+
decorators: [pageDecorator],
15+
} satisfies Meta<typeof TranslationStatus>
16+
17+
export default meta
18+
type Story = StoryObj<typeof meta>
19+
20+
/** `/lunaria/status.json` is intercepted by MSW. Showing a variety of completion level translation statuses for a subset of locales. */
21+
export const Default: Story = {}
22+
23+
/** 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. */
24+
export const WithoutTranslationData: Story = {
25+
parameters: {
26+
msw: {
27+
handlers: [],
28+
},
29+
},
30+
}

app/storybook/mocks/handlers.ts

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -91,68 +91,3 @@ export const pdsUsersHandler = http.get('/api/atproto/pds-users', () => {
9191
},
9292
])
9393
})
94-
95-
export const i18nStatusHandler = http.get('/lunaria/status.json', () => {
96-
return HttpResponse.json({
97-
generatedAt: '2026-01-22T10:07:07.000Z',
98-
sourceLocale: {
99-
lang: 'en',
100-
label: 'English',
101-
totalKeys: 500,
102-
},
103-
locales: [
104-
{
105-
lang: 'en-GB',
106-
label: 'English (UK)',
107-
dir: 'ltr',
108-
totalKeys: 500,
109-
completedKeys: 423,
110-
percentComplete: 84,
111-
missingKeys: [
112-
'settings.background_themes.label',
113-
'settings.enable_graph_pulse_loop',
114-
'settings.enable_graph_pulse_loop_description',
115-
'settings.data_source.algolia_description',
116-
'settings.data_source.npm_description',
117-
'i18n.contribute_hint',
118-
'i18n.copy_keys',
119-
],
120-
githubEditUrl: 'https://github.com/npmx-dev/npmx.dev/edit/main/i18n/locales/en-GB.json',
121-
githubHistoryUrl:
122-
'https://github.com/npmx-dev/npmx.dev/commits/main/i18n/locales/en-GB.json',
123-
},
124-
{
125-
lang: 'fr-FR',
126-
label: 'Français',
127-
dir: 'ltr',
128-
totalKeys: 500,
129-
completedKeys: 423,
130-
percentComplete: 84,
131-
missingKeys: [
132-
'settings.background_themes.label',
133-
'settings.enable_graph_pulse_loop',
134-
'settings.enable_graph_pulse_loop_description',
135-
'settings.data_source.algolia_description',
136-
'settings.data_source.npm_description',
137-
'i18n.contribute_hint',
138-
'i18n.copy_keys',
139-
],
140-
githubEditUrl: 'https://github.com/npmx-dev/npmx.dev/edit/main/i18n/locales/fr-FR.json',
141-
githubHistoryUrl:
142-
'https://github.com/npmx-dev/npmx.dev/commits/main/i18n/locales/fr-FR.json',
143-
},
144-
{
145-
lang: 'de-DE',
146-
label: 'Deutsch',
147-
dir: 'ltr',
148-
totalKeys: 500,
149-
completedKeys: 500,
150-
percentComplete: 100,
151-
missingKeys: [],
152-
githubEditUrl: 'https://github.com/npmx-dev/npmx.dev/edit/main/i18n/locales/de-DE.json',
153-
githubHistoryUrl:
154-
'https://github.com/npmx-dev/npmx.dev/commits/main/i18n/locales/de-DE.json',
155-
},
156-
],
157-
})
158-
})

0 commit comments

Comments
 (0)