Skip to content

Commit 1faf018

Browse files
authored
Fix broken setup stories (#3896)
1 parent 89140c5 commit 1faf018

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

webview/src/setup/components/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import {
3434
updateNeedsGitCommit
3535
} from '../state/experimentsSlice'
3636

37-
const feedStore = (
37+
export const feedStore = (
3838
data: MessageToWebview<SetupData>,
3939
dispatch: SetupDispatch
4040
) => {

webview/src/stories/Setup.stories.tsx

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import type { StoryFn, Meta } from '@storybook/react'
22
import React from 'react'
3+
import { Provider, useDispatch } from 'react-redux'
4+
import { configureStore } from '@reduxjs/toolkit'
35
import { MessageToWebviewType } from 'dvc/src/webview/contract'
46
import { SetupData, SetupSection } from 'dvc/src/setup/webview/contract'
57
import { DISABLE_CHROMATIC_SNAPSHOTS } from './util'
6-
import { App } from '../setup/components/App'
8+
import { App, feedStore } from '../setup/components/App'
9+
import { setupReducers } from '../setup/store'
710

811
const DEFAULT_DATA: SetupData = {
912
canGitInitialize: false,
@@ -34,6 +37,17 @@ const getUpdatedArgs = (data: Partial<SetupData>): { data: SetupData } => ({
3437
}
3538
})
3639

40+
const MockedState: React.FC<{ data: SetupData; children: React.ReactNode }> = ({
41+
children,
42+
data
43+
}) => {
44+
const dispatch = useDispatch()
45+
const message = { data, type: MessageToWebviewType.SET_DATA }
46+
feedStore(message, dispatch)
47+
48+
return <>{children}</>
49+
}
50+
3751
export default {
3852
args: {},
3953
component: App,
@@ -42,7 +56,13 @@ export default {
4256
} as Meta
4357

4458
const Template: StoryFn = ({ data }) => {
45-
const app = <App />
59+
const app = (
60+
<Provider store={configureStore({ reducer: setupReducers })}>
61+
<MockedState data={data}>
62+
<App />
63+
</MockedState>
64+
</Provider>
65+
)
4666
window.postMessage(
4767
{
4868
data,

0 commit comments

Comments
 (0)