8000 Fix tests · coder/coder@1127a3d · GitHub
[go: up one dir, main page]

Skip to content

Commit 1127a3d

Browse files
committed
Fix tests
1 parent 9c50c40 commit 1127a3d

File tree

1 file changed

+26
-19
lines changed

1 file changed

+26
-19
lines changed

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

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
withProxyProvider,
1818
} from "testHelpers/storybook";
1919
import TasksPage, { data } from "./TasksPage";
20+
import { reactRouterParameters } from "storybook-addon-remix-react-router";
2021

2122
const meta: Meta<typeof TasksPage> = {
2223
title: "pages/TasksPage",
@@ -132,6 +133,23 @@ const newTaskData = {
132133

133134
export const CreateTaskSuccessfully: Story = {
134135
decorators: [withProxyProvider()],
136+
parameters: {
137+
reactRouter: reactRouterParameters({
138+
location: {
139+
path: "/tasks",
140+
},
141+
routing: [
142+
{
143+
path: "/tasks",
144+
useStoryElement: true,
145+
},
146+
{
147+
path: "/tasks/:ownerName/:workspaceName",
148+
element: <h1>Task page</h1>,
149+
},
150+
],
151+
}),
152+
},
135153
beforeEach: () => {
136154
spyOn(data, "fetchAITemplates").mockResolvedValue([MockTemplate]);
137155
spyOn(data, "fetchTasks")
@@ -150,10 +168,8 @@ export const CreateTaskSuccessfully: Story = {
150168
await userEvent.click(submitButton);
151169
});
152170

153-
await step("Verify task in the table", async () => {
154-
await canvas.findByRole("row", {
155-
name: new RegExp(newTaskData.prompt, "i"),
156-
});
171+
await step("Redirects to the task page", async () => {
172+
await canvas.findByText(/task page/i);
157173
});
158174
},
159175
};
@@ -187,7 +203,7 @@ export const CreateTaskError: Story = {
187203
},
188204
};
189205

190-
export const WithExternalAuth: Story = {
206+
export const WithAuthenticatedExternalAuth: Story = {
191207
decorators: [withProxyProvider()],
192208
beforeEach: () => {
193209
spyOn(data, "fetchTasks")
@@ -201,26 +217,17 @@ export const WithExternalAuth: Story = {
201217
play: async ({ canvasElement, step }) => {
202218
const canvas = within(canvasElement);
203219

204-
await step("Run task", async () => {
205-
const prompt = await canvas.findByLabelText(/prompt/i);
206-
await userEvent.type(prompt, newTaskData.prompt);
207-
const submitButton = canvas.getByRole("button", { name: /run task/i });
208-
await waitFor(() => expect(submitButton).toBeEnabled());
209-
await userEvent.click(submitButton);
210-
});
211-
212-
await step("Verify task in the table", async () => {
213-
await canvas.findByRole("row", {
214-
name: new RegExp(newTaskData.prompt, "i"),
215-
});
216-
});
217-
218220
await step("Does not render external auth", async () => {
219221
expect(
220222
canvas.queryByText(/external authentication/),
221223
).not.toBeInTheDocument();
222224
});
223225
},
226+
parameters: {
227+
chromatic: {
228+
disableSnapshot: true,
229+
},
230+
},
224231
};
225232

226233
export const MissingExternalAuth: Story = {

0 commit comments

Comments
 (0)
0