Skip to content

feat: show update messages on workspace page #9705

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix tests
  • Loading branch information
aslilac committed Sep 15, 2023
commit ab2e2b3baca232a322d4689b1d3d97a06b1e5d4e
10 changes: 5 additions & 5 deletions site/src/pages/WorkspacePage/WorkspaceActions/Buttons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const UpdateButton: FC<WorkspaceAction> = ({
return (
<LoadingButton
loading={loading}
loadingIndicator="Updating..."
loadingIndicator={<>Updating&hellip;</>}
loadingPosition="start"
data-testid="workspace-update-button"
startIcon={<CloudQueueIcon />}
Expand All @@ -42,7 +42,7 @@ export const ActivateButton: FC<WorkspaceAction> = ({
return (
<LoadingButton
loading={loading}
loadingIndicator="Activating..."
loadingIndicator={<>Activating&hellip;</>}
loadingPosition="start"
startIcon={<PowerSettingsNewIcon />}
onClick={handleAction}
Expand Down Expand Up @@ -70,7 +70,7 @@ export const StartButton: FC<
>
<LoadingButton
loading={loading}
loadingIndicator="Starting..."
loadingIndicator={<>Starting&hellip;</>}
loadingPosition="start"
startIcon={<PlayCircleOutlineIcon />}
onClick={() => handleAction()}
Expand All @@ -90,7 +90,7 @@ export const StopButton: FC<WorkspaceAction> = ({ handleAction, loading }) => {
return (
<LoadingButton
loading={loading}
loadingIndicator="Stopping..."
loadingIndicator={<>Stopping&hellip;</>}
loadingPosition="start"
startIcon={<CropSquareIcon />}
onClick={handleAction}
Expand Down Expand Up @@ -119,7 +119,7 @@ export const RestartButton: FC<
>
<LoadingButton
loading={loading}
loadingIndicator="Restarting..."
loadingIndicator={<>Restarting&hellip;</>}
loadingPosition="start"
startIcon={<ReplayIcon />}
onClick={() => handleAction()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,10 @@ export const WorkspaceActions: FC<WorkspaceActionsProps> = ({
Change version&hellip;
</MenuItem>
)}
<MenuItem onClick={onMenuItemClick(handleDelete)}>
<MenuItem
onClick={onMenuItemClick(handleDelete)}
data-testid="delete-button"
>
<DeleteOutlined />
Delete&hellip;
</MenuItem>
Expand Down
72 changes: 5 additions & 67 deletions site/src/pages/WorkspacePage/WorkspacePage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ import {
MockEntitlementsWithScheduling,
MockDeploymentConfig,
} from "testHelpers/entities";
import * as api from "../../api/api";
import { Workspace } from "../../api/typesGenerated";
import * as api from "api/api";
import { Workspace } from "api/typesGenerated";
import {
renderWithAuth,
waitForLoaderToBeRemoved,
} from "../../testHelpers/renderHelpers";
import { server } from "../../testHelpers/server";
} from "testHelpers/renderHelpers";
import { server } from "testHelpers/server";
import { WorkspacePage } from "./WorkspacePage";

// It renders the workspace page and waits for it be loaded
Expand Down Expand Up @@ -113,7 +113,7 @@ describe("WorkspacePage", () => {
await user.click(trigger);

// Click on delete
const button = await screen.findByText("Delete");
const button = await screen.findByTestId("delete-button");
await user.click(button);

// Get dialog and confirm
Expand Down Expand Up @@ -172,28 +172,6 @@ describe("WorkspacePage", () => {
});
});

it("requests a stop without confirmation when the user presses Restart", async () => {
const stopWorkspaceMock = jest
.spyOn(api, "stopWorkspace")
.mockResolvedValueOnce(MockWorkspaceBuild);
window.localStorage.setItem(
`${MockUser.id}_ignoredWarnings`,
JSON.stringify({ restart: new Date().toISOString() }),
);

// Render
await renderWorkspacePage();

// Actions
const user = userEvent.setup();
await user.click(screen.getByTestId("workspace-restart-button"));

// Assertions
await waitFor(() => {
expect(stopWorkspaceMock).toBeCalled();
});
});

it("requests cancellation when the user presses Cancel", async () => {
server.use(
rest.get(
Expand Down Expand Up @@ -409,44 +387,4 @@ describe("WorkspacePage", () => {
});
});
});

it("restart the workspace with one time parameters without the confirmation dialog", async () => {
window.localStorage.setItem(
`${MockUser.id}_ignoredWarnings`,
JSON.stringify({
restart: new Date().toISOString(),
}),
);
jest.spyOn(api, "getWorkspaceParameters").mockResolvedValue({
templateVersionRichParameters: [
{
...MockTemplateVersionParameter1,
ephemeral: true,
name: "rebuild",
description: "Rebuild",
required: false,
},
],
buildParameters: [{ name: "rebuild", value: "false" }],
});
const restartWorkspaceSpy = jest.spyOn(api, "restartWorkspace");
const user = userEvent.setup();
await renderWorkspacePage();
await user.click(screen.getByTestId("build-parameters-button"));
const buildParametersForm = await screen.findByTestId(
"build-parameters-form",
);
const rebuildField = within(buildParametersForm).getByLabelText("Rebuild", {
exact: false,
});
await user.clear(rebuildField);
await user.type(rebuildField, "true");
await user.click(screen.getByTestId("build-parameters-submit"));
await waitFor(() => {
expect(restartWorkspaceSpy).toBeCalledWith({
workspace: MockWorkspace,
buildParameters: [{ name: "rebuild", value: "true" }],
});
});
});
});