Skip to content

Commit 0a1b4d6

Browse files
committed
Use helper to proxy provider
1 parent 1f109fe commit 0a1b4d6

File tree

1 file changed

+8
-76
lines changed

1 file changed

+8
-76
lines changed

site/src/pages/TasksPage/TasksPage.stories.tsx

Lines changed: 8 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
import type { Meta, StoryObj } from "@storybook/react";
22
import { expect, spyOn, userEvent, within } from "@storybook/test";
3-
import { ProxyContext, getPreferredProxy } from "contexts/ProxyContext";
43
import {
5-
MockProxyLatencies,
64
MockTemplate,
75
MockUserOwner,
86
MockWorkspace,
97
MockWorkspaceAppStatus,
108
mockApiError,
119
} from "testHelpers/entities";
12-
import { withAuthProvider, withGlobalSnackbar } from "testHelpers/storybook";
10+
import {
11+
withAuthProvider,
12+
withGlobalSnackbar,
13+
withProxyProvider,
14+
} from "testHelpers/storybook";
1315
import TasksPage, { data } from "./TasksPage";
1416

1517
const meta: Meta<typeof TasksPage> = {
@@ -85,61 +87,15 @@ export const EmptyTasks: Story = {
8587
};
8688

8789
export const LoadedTasks: Story = {
88-
decorators: [
89-
(Story) => (
90-
<ProxyContext.Provider
91-
value={{
92-
proxyLatencies: MockProxyLatencies,
93-
proxy: getPreferredProxy([], undefined),
94-
proxies: [],
95-
isLoading: false,
96-
isFetched: true,
97-
clearProxy: () => {
98-
return;
99-
},
100-
setProxy: () => {
101-
return;
102-
},
103-
refetchProxyLatencies: (): Date => {
104-
return new Date();
105-
},
106-
}}
107-
>
108-
<Story />
109-
</ProxyContext.Provider>
110-
),
111-
],
90+
decorators: [withProxyProvider()],
11291
beforeEach: () => {
11392
spyOn(data, "fetchAITemplates").mockResolvedValue([MockTemplate]);
11493
spyOn(data, "fetchTasks").mockResolvedValue(MockTasks);
11594
},
11695
};
11796

11897
export const CreateTaskSuccessfully: Story = {
119-
decorators: [
120-
(Story) => (
121-
<ProxyContext.Provider
122-
value={{
123-
proxyLatencies: MockProxyLatencies,
124-
proxy: getPreferredProxy([], undefined),
125-
proxies: [],
126-
isLoading: false,
127-
isFetched: true,
128-
clearProxy: () => {
129-
return;
130-
},
131-
setProxy: () => {
132-
return;
133-
},
134-
refetchProxyLatencies: (): Date => {
135-
return new Date();
136-
},
137-
}}
138-
>
139-
<Story />
140-
</ProxyContext.Provider>
141-
),
142-
],
98+
decorators: [withProxyProvider()],
14399
beforeEach: () => {
144100
spyOn(data, "fetchAITemplates").mockResolvedValue([MockTemplate]);
145101
spyOn(data, "fetchTasks").mockResolvedValue(MockTasks);
@@ -175,31 +131,7 @@ export const CreateTaskSuccessfully: Story = {
175131
};
176132

177133
export const CreateTaskError: Story = {
178-
decorators: [
179-
(Story) => (
180-
<ProxyContext.Provider
181-
value={{
182-
proxyLatencies: MockProxyLatencies,
183-
proxy: getPreferredProxy([], undefined),
184-
proxies: [],
185-
isLoading: false,
186-
isFetched: true,
187-
clearProxy: () => {
188-
return;
189-
},
190-
setProxy: () => {
191-
return;
192-
},
193-
refetchProxyLatencies: (): Date => {
194-
return new Date();
195-
},
196-
}}
197-
>
198-
<Story />
199-
</ProxyContext.Provider>
200-
),
201-
withGlobalSnackbar,
202-
],
134+
decorators: [withProxyProvider(), withGlobalSnackbar],
203135
beforeEach: () => {
204136
spyOn(data, "fetchAITemplates").mockResolvedValue([MockTemplate]);
205137
spyOn(data, "fetchTasks").mockResolvedValue(MockTasks);

0 commit comments

Comments
 (0)