Skip to content

Commit

Permalink
fix(#1703): fix storybook tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MSzalowski committed Aug 9, 2024
1 parent 542f381 commit 84f0c96
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 27 deletions.
51 changes: 27 additions & 24 deletions govtool/frontend/.storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { I18nextProvider } from "react-i18next";
import { QueryClient, QueryClientProvider } from "react-query";
import { MemoryRouter, Route, Routes } from "react-router-dom";

import { FeatureFlagProvider } from "../src/context/featureFlag";
import { AppContextProvider } from "../src/context/appContext";
import { ModalProvider } from "../src/context/modal";
import i18n from "../src/i18n";
Expand All @@ -26,30 +27,32 @@ const preview: Preview = {
(Story) => (
<QueryClientProvider client={queryClient}>
<AppContextProvider>
<ThemeProvider theme={theme}>
<ModalProvider>
<I18nextProvider i18n={i18n}>
<MemoryRouter>
<Routes>
<Route
path="/*"
element={
<div
style={{
margin: "0px",
padding: "0px",
position: "relative",
}}
>
<Story />
</div>
}
/>
</Routes>
</MemoryRouter>
</I18nextProvider>
</ModalProvider>
</ThemeProvider>
<FeatureFlagProvider>
<ThemeProvider theme={theme}>
<ModalProvider>
<I18nextProvider i18n={i18n}>
<MemoryRouter>
<Routes>
<Route
path="/*"
element={
<div
style={{
margin: "0px",
padding: "0px",
position: "relative",
}}
>
<Story />
</div>
}
/>
</Routes>
</MemoryRouter>
</I18nextProvider>
</ModalProvider>
</ThemeProvider>
</FeatureFlagProvider>
</AppContextProvider>
</QueryClientProvider>
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ type Story = StoryObj<typeof meta>;

const commonArgs = {
abstainVotes: 1000000,
createdDate: new Date().toLocaleDateString(),
expiryDate: new Date().toLocaleDateString(),
createdDate: new Date().toISOString(),
expiryDate: new Date().toISOString(),
noVotes: 1000000,
label: "Info Action",
type: GovernanceActionType.InfoAction,
Expand Down Expand Up @@ -52,7 +52,7 @@ async function assertGovActionDetails(
await expect(canvas.getAllByText(todayDate)).toHaveLength(2);
await expect(
canvas.getByTestId(`${getProposalTypeNoEmptySpaces(args.type)}-type`),
).toHaveTextContent(args.type);
).toHaveTextContent(args.label);
await expect(canvas.getByTestId(`${args.govActionId}-id`)).toHaveTextContent(
args.govActionId,
);
Expand Down

0 comments on commit 84f0c96

Please sign in to comment.