|
1 | 1 | import type { Meta, StoryObj } from "@storybook/react";
|
2 | 2 | import { expect, spyOn, userEvent, within } from "@storybook/test";
|
3 |
| -import { ProxyContext, getPreferredProxy } from "contexts/ProxyContext"; |
4 | 3 | import {
|
5 |
| - MockProxyLatencies, |
6 | 4 | MockTemplate,
|
7 | 5 | MockUserOwner,
|
8 | 6 | MockWorkspace,
|
9 | 7 | MockWorkspaceAppStatus,
|
10 | 8 | mockApiError,
|
11 | 9 | } from "testHelpers/entities";
|
12 |
| -import { withAuthProvider, withGlobalSnackbar } from "testHelpers/storybook"; |
| 10 | +import { |
| 11 | + withAuthProvider, |
| 12 | + withGlobalSnackbar, |
| 13 | + withProxyProvider, |
| 14 | +} from "testHelpers/storybook"; |
13 | 15 | import TasksPage, { data } from "./TasksPage";
|
14 | 16 |
|
15 | 17 | const meta: Meta<typeof TasksPage> = {
|
@@ -85,61 +87,15 @@ export const EmptyTasks: Story = {
|
85 | 87 | };
|
86 | 88 |
|
87 | 89 | 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()], |
112 | 91 | beforeEach: () => {
|
113 | 92 | spyOn(data, "fetchAITemplates").mockResolvedValue([MockTemplate]);
|
114 | 93 | spyOn(data, "fetchTasks").mockResolvedValue(MockTasks);
|
115 | 94 | },
|
116 | 95 | };
|
117 | 96 |
|
118 | 97 | 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()], |
143 | 99 | beforeEach: () => {
|
144 | 100 | spyOn(data, "fetchAITemplates").mockResolvedValue([MockTemplate]);
|
145 | 101 | spyOn(data, "fetchTasks").mockResolvedValue(MockTasks);
|
@@ -175,31 +131,7 @@ export const CreateTaskSuccessfully: Story = {
|
175 | 131 | };
|
176 | 132 |
|
177 | 133 | 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], |
203 | 135 | beforeEach: () => {
|
204 | 136 | spyOn(data, "fetchAITemplates").mockResolvedValue([MockTemplate]);
|
205 | 137 | spyOn(data, "fetchTasks").mockResolvedValue(MockTasks);
|
|
0 commit comments