|
1 | 1 | import type { Preview } from '@storybook/react-webpack5'; |
2 | 2 | import '@patternfly/react-core/dist/styles/base.css'; |
3 | 3 | import React from 'react'; |
| 4 | +import { initialize, mswLoader } from 'msw-storybook-addon'; |
| 5 | + |
| 6 | +// Set up global chrome mock immediately |
| 7 | +if (typeof window !== 'undefined') { |
| 8 | + const defaultMockChrome = { |
| 9 | + auth: { |
| 10 | + getUser: async () => ({ |
| 11 | + identity: { |
| 12 | + account_number: '12345', |
| 13 | + org_id: '67890', |
| 14 | + user: { |
| 15 | + username: 'testuser', |
| 16 | + email: 'test@example.com', |
| 17 | + first_name: 'Test', |
| 18 | + last_name: 'User', |
| 19 | + is_active: true, |
| 20 | + is_org_admin: false, |
| 21 | + }, |
| 22 | + internal: { |
| 23 | + account_id: '12345', |
| 24 | + }, |
| 25 | + }, |
| 26 | + }), |
| 27 | + }, |
| 28 | + getBundleData: () => ({ bundleId: 'insights' }), |
| 29 | + getAvailableBundles: () => [ |
| 30 | + { id: 'insights', title: 'Red Hat Insights' }, |
| 31 | + { id: 'ansible', title: 'Ansible Automation Platform' }, |
| 32 | + { id: 'openshift', title: 'OpenShift' }, |
| 33 | + { id: 'settings', title: 'Settings' }, |
| 34 | + ], |
| 35 | + updateDocumentTitle: (title: string) => { |
| 36 | + document.title = title; |
| 37 | + }, |
| 38 | + hideGlobalFilter: () => {}, |
| 39 | + isBeta: () => false, |
| 40 | + isProd: () => false, |
| 41 | + getEnvironment: () => 'stage', |
| 42 | + }; |
| 43 | + |
| 44 | + // @ts-ignore |
| 45 | + window.insights = { chrome: defaultMockChrome }; |
| 46 | +} |
4 | 47 |
|
5 | 48 | const preview: Preview = { |
| 49 | + beforeAll: async () => { |
| 50 | + // Initialize MSW with error on unhandled requests to catch missing mocks |
| 51 | + initialize({ onUnhandledRequest: 'warn' }); |
| 52 | + }, |
| 53 | + loaders: [mswLoader], |
6 | 54 | parameters: { |
7 | 55 | options: { |
8 | 56 | storySort: { |
9 | 57 | method: 'alphabetical', |
10 | | - order: ['Documentation', '*'], |
| 58 | + order: ['Documentation', 'User Journeys', 'Components', '*'], |
11 | 59 | }, |
12 | 60 | }, |
13 | 61 | layout: 'fullscreen', |
|
0 commit comments