Skip to content

Commit 007efc1

Browse files
committed
fix: move test to shrink diff
1 parent 1555627 commit 007efc1

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

site/src/pages/WorkspacesPage/WorkspacesPage.test.tsx

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -85,33 +85,6 @@ describe("WorkspacesPage", () => {
8585
expect(deleteWorkspace).toHaveBeenCalledWith(workspaces[1].id);
8686
});
8787

88-
it("stops only the running and selected workspaces", async () => {
89-
const workspaces = [
90-
{ ...MockWorkspace, id: "1" },
91-
{ ...MockWorkspace, id: "2" },
92-
{ ...MockWorkspace, id: "3" },
93-
];
94-
jest
95-
.spyOn(API, "getWorkspaces")
96-
.mockResolvedValue({ workspaces, count: workspaces.length });
97-
const stopWorkspace = jest.spyOn(API, "stopWorkspace");
98-
const user = userEvent.setup();
99-
renderWithAuth(<WorkspacesPage />);
100-
await waitForLoaderToBeRemoved();
101-
102-
await user.click(getWorkspaceCheckbox(workspaces[0]));
103-
await user.click(getWorkspaceCheckbox(workspaces[1]));
104-
await user.click(screen.getByRole("button", { name: /bulk actions/i }));
105-
const stopButton = await screen.findByRole("menuitem", { name: /stop/i });
106-
await user.click(stopButton);
107-
108-
await waitFor(() => {
109-
expect(stopWorkspace).toHaveBeenCalledTimes(2);
110-
});
111-
expect(stopWorkspace).toHaveBeenCalledWith(workspaces[0].id);
112-
expect(stopWorkspace).toHaveBeenCalledWith(workspaces[1].id);
113-
});
114-
11588
describe("batch updates", () => {
11689
it("skips up-to-date workspaces after confirming update", async () => {
11790
const workspaces: readonly Workspace[] = [
@@ -251,6 +224,33 @@ describe("WorkspacesPage", () => {
251224
});
252225
});
253226

227+
it("stops only the running and selected workspaces", async () => {
228+
const workspaces = [
229+
{ ...MockWorkspace, id: "1" },
230+
{ ...MockWorkspace, id: "2" },
231+
{ ...MockWorkspace, id: "3" },
232+
];
233+
jest
234+
.spyOn(API, "getWorkspaces")
235+
.mockResolvedValue({ workspaces, count: workspaces.length });
236+
const stopWorkspace = jest.spyOn(API, "stopWorkspace");
237+
const user = userEvent.setup();
238+
renderWithAuth(<WorkspacesPage />);
239+
await waitForLoaderToBeRemoved();
240+
241+
await user.click(getWorkspaceCheckbox(workspaces[0]));
242+
await user.click(getWorkspaceCheckbox(workspaces[1]));
243+
await user.click(screen.getByRole("button", { name: /bulk actions/i }));
244+
const stopButton = await screen.findByRole("menuitem", { name: /stop/i });
245+
await user.click(stopButton);
246+
247+
await waitFor(() => {
248+
expect(stopWorkspace).toHaveBeenCalledTimes(2);
249+
});
250+
expect(stopWorkspace).toHaveBeenCalledWith(workspaces[0].id);
251+
expect(stopWorkspace).toHaveBeenCalledWith(workspaces[1].id);
252+
});
253+
254254
it("starts only the stopped and selected workspaces", async () => {
255255
const workspaces = [
256256
{ ...MockStoppedWorkspace, id: "1" },

0 commit comments

Comments
 (0)