File tree Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Original file line number Diff line number Diff 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) => {
Original file line number Diff line number Diff line change 11import type { StoryFn , Meta } from '@storybook/react'
22import React from 'react'
3+ import { Provider , useDispatch } from 'react-redux'
4+ import { configureStore } from '@reduxjs/toolkit'
35import { MessageToWebviewType } from 'dvc/src/webview/contract'
46import { SetupData , SetupSection } from 'dvc/src/setup/webview/contract'
57import { 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
811const 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+
3751export default {
3852 args : { } ,
3953 component : App ,
@@ -42,7 +56,13 @@ export default {
4256} as Meta
4357
4458const 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,
You can’t perform that action at this time.
0 commit comments