Skip to content

Commit f47b2a8

Browse files
authored
Merge pull request #2755 from headlamp-k8s/fix-storybook-crash
storybook: Add workaround for the circular dependecy crash
2 parents 7c13419 + 415d00f commit f47b2a8

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

frontend/.storybook/preview.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ import '../src/index.css';
55
import { Title, Subtitle, Description, Primary, Controls } from '@storybook/blocks';
66
import { baseMocks } from './baseMocks';
77
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
8+
import App from '../src/App';
9+
10+
// App import will load the whole app dependency tree
11+
// And assigning it to a value will make sure it's not tree-shaken and removed
12+
const DontDeleteMe = App;
813

914
// https://github.com/mswjs/msw-storybook-addon
1015
initialize({

frontend/src/components/gateway/ClassDetails.stories.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ export default {
2929
'http://localhost:4466/apis/gateway.networking.k8s.io/v1beta1/gatewayclasses',
3030
() => HttpResponse.error()
3131
),
32+
http.get(
33+
'http://localhost:4466/apis/gateway.networking.k8s.io/v1beta1/gatewayclasses',
34+
() => HttpResponse.error()
35+
),
3236
http.get('http://localhost:4466/api/v1/namespaces/default/events', () =>
3337
HttpResponse.json({
3438
kind: 'EventList',

frontend/src/storybook.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const options = {
4949
vi.mock('@iconify/react', () => ({
5050
Icon: () => null,
5151
InlineIcon: () => null,
52+
addCollection: () => {},
5253
}));
5354

5455
vi.mock('@monaco-editor/react', () => ({

0 commit comments

Comments
 (0)