This repository was archived by the owner on Sep 10, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +46
-28
lines changed Expand file tree Collapse file tree 6 files changed +46
-28
lines changed Original file line number Diff line number Diff line change 14
14
15
15
import { ArgTypes , Decorator , Parameters , Preview } from "@storybook/react" ;
16
16
import { useLayoutEffect } from "react" ;
17
+ import { TooltipProvider } from "@vector-im/compound-web" ;
17
18
18
19
import "../src/shared.css" ;
19
20
import i18n from "../src/i18n" ;
20
21
21
22
import localazyMetadata from "./locales" ;
23
+ import { DummyRouter } from "../src/test-utils/router" ;
22
24
23
25
export const parameters : Parameters = {
24
26
controls : {
@@ -75,7 +77,27 @@ const withThemeProvider: Decorator = (Story, context) => {
75
77
) ;
76
78
} ;
77
79
78
- export const decorators : Decorator [ ] = [ withThemeProvider ] ;
80
+ const withDummyRouter : Decorator = ( Story , context ) => {
81
+ return (
82
+ < DummyRouter >
83
+ < Story />
84
+ </ DummyRouter >
85
+ ) ;
86
+ } ;
87
+
88
+ const withTooltipProvider : Decorator = ( Story , context ) => {
89
+ return (
90
+ < TooltipProvider >
91
+ < Story />
92
+ </ TooltipProvider >
93
+ ) ;
94
+ } ;
95
+
96
+ export const decorators : Decorator [ ] = [
97
+ withThemeProvider ,
98
+ withDummyRouter ,
99
+ withTooltipProvider ,
100
+ ] ;
79
101
80
102
const locales = Object . fromEntries (
81
103
localazyMetadata . languages . map ( ( { language, name, localizedName } ) => [
Original file line number Diff line number Diff line change 14
14
15
15
import { Meta , StoryObj } from "@storybook/react" ;
16
16
17
- import { DummyRouter } from "../../test-utils/router" ;
18
-
19
17
import { Filter } from "./Filter" ;
20
18
21
19
const meta = {
@@ -28,11 +26,9 @@ const meta = {
28
26
} ,
29
27
decorators : [
30
28
( Story ) : React . ReactElement => (
31
- < DummyRouter >
32
- < div className = "flex gap-4" >
33
- < Story />
34
- </ div >
35
- </ DummyRouter >
29
+ < div className = "flex gap-4" >
30
+ < Story />
31
+ </ div >
36
32
) ,
37
33
] ,
38
34
} satisfies Meta < typeof Filter > ;
Original file line number Diff line number Diff line change 14
14
15
15
import type { Meta , StoryObj } from "@storybook/react" ;
16
16
17
- import { DummyRouter } from "../../test-utils/router" ;
18
17
import NavItem from "../NavItem" ;
19
18
20
19
import NavBar from "./NavBar" ;
@@ -24,12 +23,10 @@ const meta = {
24
23
component : NavBar ,
25
24
tags : [ "autodocs" ] ,
26
25
render : ( ) : React . ReactElement => (
27
- < DummyRouter >
28
- < NavBar >
29
- < NavItem to = "/" > Profile</ NavItem >
30
- < NavItem to = "/sessions" > Sessions</ NavItem >
31
- </ NavBar >
32
- </ DummyRouter >
26
+ < NavBar >
27
+ < NavItem to = "/" > Profile</ NavItem >
28
+ < NavItem to = "/sessions" > Sessions</ NavItem >
29
+ </ NavBar >
33
30
) ,
34
31
} satisfies Meta < typeof NavBar > ;
35
32
Original file line number Diff line number Diff line change 15
15
import type { Meta , StoryObj } from "@storybook/react" ;
16
16
import { PropsWithChildren } from "react" ;
17
17
18
- import { DummyRouter } from "../../test-utils/router" ;
19
-
20
18
import SessionHeader from "./SessionHeader" ;
21
19
22
20
type Props = PropsWithChildren ;
23
21
24
22
const Template : React . FC < Props > = ( { children } ) => {
25
- return (
26
- < DummyRouter >
27
- < SessionHeader to = "/" > { children } </ SessionHeader >
28
- </ DummyRouter >
29
- ) ;
23
+ return < SessionHeader to = "/" > { children } </ SessionHeader > ;
30
24
} ;
31
25
32
26
const meta = {
Original file line number Diff line number Diff line change @@ -18,13 +18,19 @@ import { composeStory } from "@storybook/react";
18
18
import { render , cleanup } from "@testing-library/react" ;
19
19
import { describe , it , expect , afterEach } from "vitest" ;
20
20
21
+ import { DummyRouter } from "../../test-utils/router" ;
22
+
21
23
import Meta , { Basic } from "./SessionHeader.stories" ;
22
24
23
25
describe ( "<SessionHeader />" , ( ) => {
24
26
afterEach ( cleanup ) ;
25
27
it ( "renders a session header" , ( ) => {
26
28
const Component = composeStory ( Basic , Meta ) ;
27
- const { container } = render ( < Component /> ) ;
29
+ const { container } = render (
30
+ < DummyRouter >
31
+ < Component />
32
+ </ DummyRouter > ,
33
+ ) ;
28
34
expect ( container ) . toMatchSnapshot ( ) ;
29
35
} ) ;
30
36
} ) ;
Original file line number Diff line number Diff line change 13
13
// limitations under the License.
14
14
15
15
import { RouterProvider , createRouter } from "@tanstack/react-router" ;
16
+ import { TooltipProvider } from "@vector-im/compound-web" ;
16
17
import { Suspense , StrictMode } from "react" ;
17
18
import { createRoot } from "react-dom/client" ;
18
19
import { I18nextProvider } from "react-i18next" ;
@@ -48,11 +49,13 @@ createRoot(document.getElementById("root") as HTMLElement).render(
48
49
< StrictMode >
49
50
< UrqlProvider value = { client } >
50
51
< ErrorBoundary >
51
- < Suspense fallback = { < LoadingScreen /> } >
52
- < I18nextProvider i18n = { i18n } >
53
- < RouterProvider router = { router } context = { { client } } />
54
- </ I18nextProvider >
55
- </ Suspense >
52
+ < TooltipProvider >
53
+ < Suspense fallback = { < LoadingScreen /> } >
54
+ < I18nextProvider i18n = { i18n } >
55
+ < RouterProvider router = { router } context = { { client } } />
56
+ </ I18nextProvider >
57
+ </ Suspense >
58
+ </ TooltipProvider >
56
59
</ ErrorBoundary >
57
60
</ UrqlProvider >
58
61
</ StrictMode > ,
You can’t perform that action at this time.
0 commit comments