Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 57 additions & 1 deletion 58 site/src/pages/WorkspacesPage/WorkspacesPage.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ import {
templateVersionsQueryKey,
} from "#/api/queries/templates";
import { workspacesKey } from "#/api/queries/workspaces";
import type { Workspace, WorkspaceAppHealth } from "#/api/typesGenerated";
import type {
Workspace,
WorkspaceAppHealth,
WorkspaceBuild,
} from "#/api/typesGenerated";
import { workspaceChecks } from "#/modules/workspaces/permissions";
import {
MockDefaultOrganization,
Expand Down Expand Up @@ -373,6 +377,58 @@ export const BatchUpdateRunningWorkspace: Story = {
},
};

export const BatchUpdateShowsSubmittingState: Story = {
beforeEach: () => {
spyOn(API, "getWorkspaces").mockResolvedValue({
workspaces: updateRunningWorkspaces,
count: updateRunningWorkspaces.length,
});
spyOn(API, "getTemplateVersion").mockResolvedValue(MockTemplateVersion);
},
play: async ({ canvasElement, step }) => {
const canvas = within(canvasElement);
const body = within(document.body);
const user = userEvent.setup();

// Hold the mutation pending so the button's submitting state stays
// observable until the story explicitly resolves it.
let resolveUpdate!: () => void;
const pendingUpdate = new Promise<WorkspaceBuild>((resolve) => {
resolveUpdate = () => resolve(MockWorkspaceBuild);
});
spyOn(API, "updateWorkspace").mockReturnValue(pendingUpdate);

await selectWorkspaces(canvas, user, ["1", "2", "3"]);
await openBulkActions(canvas, user);
await user.click(await body.findByRole("menuitem", { name: /Update/ }));

const modal = await body.findByRole("dialog", { name: /Review Updates/i });
await user.click(
within(modal).getByRole("checkbox", {
name: /I acknowledge these risks\./,
}),
);
const updateButton = within(modal).getByRole("button", { name: /Update/ });
await user.click(updateButton);

await step("Button reflects the submitting state", async () => {
await waitFor(() => expect(updateButton).toBeDisabled());
await within(modal).findByText(
"Waiting for workspaces to finish processing",
);
});

await step("Resolving the update clears the submitting state", async () => {
resolveUpdate();
await waitFor(() =>
expect(
body.queryByText("Waiting for workspaces to finish processing"),
).not.toBeInTheDocument(),
);
});
},
};

const ignoreDormantWorkspaces: Workspace[] = [
{ ...MockDormantOutdatedWorkspace, id: "1" },
{ ...MockOutdatedWorkspace, id: "2" },
Expand Down
3 changes: 2 additions & 1 deletion 3 site/src/pages/WorkspacesPage/batchActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export function useBatchActions(
unfavoriteAllMutation.isPending ||
startAllMutation.isPending ||
stopAllMutation.isPending ||
deleteAllMutation.isPending,
deleteAllMutation.isPending ||
updateAllMutation.isPending,
Comment thread
jakehwll marked this conversation as resolved.
};
}
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.