-
Notifications
You must be signed in to change notification settings - Fork 0
Implement cohesive Storybook for staff + community UI portal application package Fixes #266 #283
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
base: main
Are you sure you want to change the base?
Changes from all commits
99e0148
7124050
daac62c
cdcdab1
be5783e
d01e0fc
49f66f8
37ad0c1
e6c5e31
78d2ac3
280a381
7a40958
47c125e
c204df3
fedc557
29cdc6f
ba59183
a67eb06
b4a3b77
13b4897
93df96e
7767f71
8912120
27cb61e
54d2f83
ac69b4e
440c022
3bfe580
f1e381a
6396cd4
8bbf225
08f44c3
a87bbfa
bf378d6
085ed0f
f51991e
8f64ac2
d1b3d25
a6f530f
56755b5
9ce1e95
063dda5
ff79094
b2f97f7
28ec3b6
17f83e1
6a053ba
fceac8e
56324cb
7a81701
9bcf52b
be4b476
825c79a
b9d03cc
c0091c0
fd13793
a18025d
53cdd3e
2c6ff5e
7af12a2
227fe04
4ad2821
564144a
c37714e
9128a02
2134ac4
5a492a6
6202fd1
c04be87
ef09d6d
5b4b7e3
3741499
850330a
7c8cac6
01559d7
daf83d3
f0307ed
0aca918
3994cc7
c6457e5
cb05fc9
5d0a3d1
1583df2
6973a3b
de9ecf9
8ec3195
9cc7d56
a287666
ce38a55
e2161c4
7c69013
0960b11
7ddca09
58a06ef
25a16ea
fef6d15
67fe8f8
065fbb8
f7481c4
5938260
ebfe6c5
eb52cd2
a2968d8
96913bd
1a46208
21a74d1
0462af0
9b45e4e
397b659
45331f6
ea14967
78fe27f
3d405d9
23da639
c14eb9c
3689105
1e4ae8b
1e5ae34
c42d0d4
454044a
44d60f6
473c344
116ab44
05b5cb6
fc44a4e
2c4caf4
5f9313a
b0dee5f
c59fd50
d193099
8600271
9a81820
a375abb
4a581c8
89340a8
364664c
23b4378
69cd123
ec6e140
23854af
8116629
bea9109
3fda574
d7408d9
77e7fd2
d2907fc
7fd630f
d5fe680
a7a6e17
8d28c53
2b824df
28937f6
57e60fb
755a380
7aaac0a
abcc9c4
7d0297c
59417e0
a99d8fa
2211756
a92cb88
e6981ca
324297e
0990777
60e635d
bddd30e
27485f1
794c257
198aac1
249c642
6ff316b
5f84489
7b9401c
d859109
782e728
0f8197a
45816c4
020d9de
05aec2e
a28ce9d
fd042fc
b709533
6ba61b1
0cbe760
88bb4ee
304595a
9d15431
66c7274
6b004d3
dc0a553
1927a7b
08c49fe
b4f9612
b089e88
f7265e7
d9a49de
a187a92
fe11746
82656eb
151f0c8
e33855a
c3d1fd8
841eac0
6184666
8221b72
9b88982
a65ed1f
3046390
e3440a9
7df5ff6
9e45099
183c09d
4e2ca62
e469d9f
a1125da
1055743
e3fb546
866850a
a18e1bc
ba141cf
9268639
93f7558
55ee7f7
ab8a297
777ce54
6269695
5e9a9ed
5833861
0863b98
530eafe
43c9ea7
01d3f37
d7346fd
53c32e6
d049d55
5410d86
33a2c74
8920a67
8b89a5b
c3ec803
660dc10
a133ad6
03b856b
ff11920
cc7baeb
98f1fab
7ecd11d
9960d26
996b545
46d559f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ lerna-debug.log* | |
| node_modules | ||
| dist | ||
| dist-ssr | ||
| storybook-static | ||
| *.local | ||
| tsconfig.tsbuildinfo | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| // Staff Storybook - Apollo Client global fallback mocks. | ||
| // Individual stories supply their own mocks via story-level decorators. | ||
| export const apolloMocks: never[] = []; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,40 +1,49 @@ | ||
| // Global preview for Storybook in @apps/ui-staff | ||
| // Import Ant Design base styles so components render correctly | ||
| import { MockedProvider } from '@apollo/client/testing'; | ||
| import { HelmetProvider } from '@dr.pogodin/react-helmet'; | ||
| import type { Decorator, Parameters, Preview } from '@storybook/react'; | ||
| import type { Decorator, Parameters } from '@storybook/react'; | ||
| import 'antd/dist/reset.css'; | ||
| import { AuthProvider } from 'react-oidc-context'; | ||
| import { ThemeProvider } from '../src/contexts/theme-context.tsx'; | ||
| import { apolloMocks } from './apollo-mocks.ts'; | ||
|
|
||
| // Mock OIDC configuration for stories | ||
| const mockOidcConfig = { | ||
| authority: 'https://mock-authority.com', | ||
| client_id: 'mock-client-id', | ||
| redirect_uri: 'http://localhost:6006/auth-redirect', | ||
| redirect_uri: 'http://localhost:6009/auth-redirect', | ||
| code_verifier: false, | ||
| nonce: false, | ||
| response_type: 'code', | ||
| scope: 'openid profile', | ||
| onSigninCallback: () => {}, | ||
| onSigninCallback: () => { | ||
| console.log('Mock signin callback'); | ||
| }, | ||
| }; | ||
|
|
||
| export const decorators: Decorator[] = [ | ||
| (Story, context) => { | ||
| const apolloParams = context.parameters?.apolloClient ?? {}; | ||
| const mocks = apolloParams.mocks ?? []; | ||
| const mocks = apolloParams.mocks ?? apolloMocks; | ||
| const { defaultOptions } = apolloParams; | ||
|
|
||
| return ( | ||
| <HelmetProvider> | ||
| <AuthProvider {...mockOidcConfig}> | ||
| <MockedProvider | ||
| key={context.id} | ||
| mocks={mocks} | ||
| defaultOptions={{ | ||
| ...defaultOptions, | ||
| watchQuery: { fetchPolicy: 'network-only' }, | ||
| query: { fetchPolicy: 'network-only' }, | ||
| }} | ||
| > | ||
| <Story /> | ||
| </MockedProvider> | ||
| <ThemeProvider> | ||
| <MockedProvider | ||
| key={context.id} | ||
| mocks={mocks} | ||
| defaultOptions={{ | ||
| ...defaultOptions, | ||
| watchQuery: { fetchPolicy: 'network-only' }, | ||
| query: { fetchPolicy: 'network-only' }, | ||
| }} | ||
| > | ||
| <Story /> | ||
| </MockedProvider> | ||
| </ThemeProvider> | ||
| </AuthProvider> | ||
| </HelmetProvider> | ||
| ); | ||
|
|
@@ -56,17 +65,16 @@ export const parameters: Parameters = { | |
| MockedProvider, | ||
| }, | ||
|
|
||
| options: { | ||
| storySort: { | ||
| order: ['Pages', 'Components'], | ||
| }, | ||
| }, | ||
|
|
||
| a11y: { | ||
| // 'todo' - show a11y violations in the test UI only | ||
| // 'error' - fail CI on a11y violations | ||
| // 'off' - skip a11y checks entirely | ||
| test: 'todo', | ||
|
Comment on lines
+74
to
+78
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question (bug_risk): Use of The |
||
| }, | ||
| }; | ||
|
|
||
| const preview: Preview = { | ||
| decorators, | ||
| parameters, | ||
| }; | ||
|
|
||
| export default preview; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (bug_risk): Merging Apollo
defaultOptionsoverwrites any existingwatchQuery/queryoptions from stories.In
MockedProvider, the current spread:overwrites any
watchQuery/queryoptions fromparameters.apolloClient.defaultOptions(e.g.errorPolicy,pollInterval). To preserve those while enforcing the fetch policy, deep-merge the sub-objects instead: