Skip to content

Commit 527104b

Browse files
committed
chore: get first integration test working
1 parent 5ec7dac commit 527104b

File tree

1 file changed

+29
-18
lines changed

1 file changed

+29
-18
lines changed

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

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -112,17 +112,28 @@ describe("WorkspacesPage", () => {
112112
expect(stopWorkspace).toHaveBeenCalledWith(workspaces[1].id);
113113
});
114114

115-
describe("batch update", () => {
116-
it("ignores up-to-date workspaces", async () => {
117-
const workspaces = [
118-
{ ...MockWorkspace, id: "1" }, // running, not outdated. no warning.
119-
{ ...MockDormantWorkspace, id: "2" }, // dormant, not outdated. no warning.
115+
describe("batch updates", () => {
116+
it("skips up-to-date workspaces after confirming update", async () => {
117+
const workspaces: readonly Workspace[] = [
118+
// Not outdated but running; should have no warning
119+
{ ...MockWorkspace, id: "1" },
120+
// Dormant; no warning
121+
{ ...MockDormantWorkspace, id: "2" },
122+
// Out of date but not running; no warning
120123
{ ...MockOutdatedWorkspace, id: "3" },
121-
{ ...MockOutdatedWorkspace, id: "4" },
124+
// Out of date but running; should issue warning
125+
{
126+
...MockOutdatedWorkspace, id: "4",
127+
latest_build: {
128+
...MockOutdatedWorkspace.latest_build,
129+
status: "running"
130+
},
131+
},
122132
];
123133
jest
124134
.spyOn(API, "getWorkspaces")
125135
.mockResolvedValue({ workspaces, count: workspaces.length });
136+
126137
const updateWorkspace = jest.spyOn(API, "updateWorkspace");
127138
const user = userEvent.setup();
128139
renderWithAuth(<WorkspacesPage />);
@@ -133,22 +144,22 @@ describe("WorkspacesPage", () => {
133144
}
134145

135146
await user.click(screen.getByRole("button", { name: /bulk actions/i }));
136-
const updateButton = await screen.findByTestId("bulk-action-update");
137-
await user.click(updateButton);
147+
const dropdownItem = await screen.findByRole("menuitem", {
148+
name: /Update/,
149+
});
150+
await user.click(dropdownItem);
138151

139-
// One click: no running workspaces warning, no dormant workspaces warning.
140-
// There is a running workspace and a dormant workspace selected, but they
141-
// are not outdated.
142-
const confirmButton = await screen.findByTestId("confirm-button");
143-
const dialog = await screen.findByRole("dialog");
144-
expect(dialog).toHaveTextContent(/used by/i);
145-
await user.click(confirmButton);
152+
const modal = await screen.findByRole("dialog", { name: /Review Updates/i });
153+
const confirmCheckbox = within(modal).getByRole("checkbox", {
154+
name: /I acknowledge these consequences\./,
155+
});
156+
await user.click(confirmCheckbox);
157+
const updateModalButton = within(modal).getByRole("button", {name: /Update/});
158+
await user.click(updateModalButton);
146159

147160
// `workspaces[0]` was up-to-date, and running
148161
// `workspaces[1]` was dormant
149-
await waitFor(() => {
150-
expect(updateWorkspace).toHaveBeenCalledTimes(2);
151-
});
162+
await waitFor(() => expect(updateWorkspace).toHaveBeenCalledTimes(2));
152163
expect(updateWorkspace).toHaveBeenCalledWith(workspaces[2], [], false);
153164
expect(updateWorkspace).toHaveBeenCalledWith(workspaces[3], [], false);
154165
});

0 commit comments

Comments
 (0)