mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 09:28:54 +00:00
## Summary - Changed all modal "Done" dismiss/close button labels to "Close" across 48 frontend component files - Updated instructional text in `AutoEnrollMdmModal` that referenced the "Done" button to say "Close" instead - Updated 7 test files to assert "Close" instead of "Done" for modal button names ## Excluded (intentionally not changed) - `LiveResultsHeading.tsx` — "Done" button is a page-level navigation action, not a modal dismiss - `AddAbmModal.tsx` — Instructional text referencing Apple Business Manager's "Done" button - `Calendars.tsx` — Instructional text referencing Google Calendar's "Done" button - `ModalFooter.stories.tsx` — Storybook demo example Built for [Mel](https://fleetdm.slack.com/archives/D0AKX7DJFCN/p1773674157011109?thread_ts=1773673149.649299&cid=D0AKX7DJFCN) by [Kilo for Slack](https://kilo.ai/features/slack-integration) --------- Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com> Co-authored-by: melpike <mel@fleetdm.com> Co-authored-by: melpike <79950145+melpike@users.noreply.github.com>
163 lines
5.8 KiB
TypeScript
163 lines
5.8 KiB
TypeScript
import React from "react";
|
|
import { render, screen } from "@testing-library/react";
|
|
import { renderWithSetup } from "test/test-utils";
|
|
import { createMockSoftwareInstallResult } from "__mocks__/softwareMock";
|
|
import { ISoftwareScriptResult } from "interfaces/software";
|
|
import { StatusMessage, ModalButtons } from "./SoftwareScriptDetailsModal";
|
|
|
|
describe("SoftwareScriptDetailsModal - StatusMessage component", () => {
|
|
it("on software library page/pending activity, renders pending install message with host and package name", () => {
|
|
render(
|
|
<StatusMessage
|
|
installResult={
|
|
createMockSoftwareInstallResult({
|
|
status: "pending_install",
|
|
}) as ISoftwareScriptResult
|
|
}
|
|
isMyDevicePage={false}
|
|
/>
|
|
);
|
|
|
|
expect(screen.queryByTestId("pending-outline-icon")).toBeInTheDocument();
|
|
expect(screen.getByText(/is running or will run/)).toBeInTheDocument();
|
|
expect(screen.getByText(/\(com\.cool\.app\)/)).toBeInTheDocument();
|
|
expect(screen.getByText(/Test Host/)).toBeInTheDocument();
|
|
expect(screen.getByText(/when it comes online/)).toBeInTheDocument();
|
|
});
|
|
|
|
it("on device user page, renders failed run with rerun option with contact link", () => {
|
|
render(
|
|
<StatusMessage
|
|
installResult={
|
|
createMockSoftwareInstallResult({
|
|
status: "failed_install",
|
|
}) as ISoftwareScriptResult
|
|
}
|
|
isMyDevicePage
|
|
contactUrl="http://support"
|
|
/>
|
|
);
|
|
|
|
expect(screen.queryByTestId("error-icon")).toBeInTheDocument();
|
|
expect(screen.getByText(/failed to run/)).toBeInTheDocument();
|
|
expect(screen.getByText(/CoolApp/)).toBeInTheDocument();
|
|
// Host name should not be rendered for device user page
|
|
expect(screen.queryByText(/Test Host/)).not.toBeInTheDocument();
|
|
expect(screen.getByText(/You can rerun/)).toBeInTheDocument();
|
|
expect(
|
|
screen.getByRole("link", { name: /contact your IT admin/ })
|
|
).toHaveAttribute("href", "http://support");
|
|
});
|
|
|
|
it("on device user page, renders failed install with retry option without contact link", () => {
|
|
render(
|
|
<StatusMessage
|
|
installResult={
|
|
createMockSoftwareInstallResult({
|
|
status: "failed_install",
|
|
}) as ISoftwareScriptResult
|
|
}
|
|
isMyDevicePage
|
|
/>
|
|
);
|
|
|
|
expect(screen.queryByTestId("error-icon")).toBeInTheDocument();
|
|
expect(screen.getByText(/failed to run/)).toBeInTheDocument();
|
|
expect(screen.getByText(/CoolApp/)).toBeInTheDocument();
|
|
// Host name should not be rendered for device user page
|
|
expect(screen.queryByText(/Test Host/)).not.toBeInTheDocument();
|
|
expect(screen.getByText(/You can rerun/)).toBeInTheDocument();
|
|
// Don't show link of not provided
|
|
expect(
|
|
screen.queryByRole("link", { name: /contact your IT admin/ })
|
|
).not.toBeInTheDocument();
|
|
});
|
|
|
|
it("on host details page, renders failed script without rerun", () => {
|
|
render(
|
|
<StatusMessage
|
|
installResult={
|
|
createMockSoftwareInstallResult({
|
|
status: "failed_install",
|
|
}) as ISoftwareScriptResult
|
|
}
|
|
isMyDevicePage={false}
|
|
contactUrl="http://support"
|
|
/>
|
|
);
|
|
|
|
expect(screen.queryByTestId("error-icon")).toBeInTheDocument();
|
|
expect(screen.getByText(/failed to run/)).toBeInTheDocument();
|
|
expect(screen.getByText(/Test Host/)).toBeInTheDocument();
|
|
expect(screen.queryByText(/You can rerun/)).not.toBeInTheDocument();
|
|
});
|
|
|
|
it("on host details page/install activity, renders ran message with timestamp", () => {
|
|
render(
|
|
<StatusMessage
|
|
installResult={
|
|
createMockSoftwareInstallResult({
|
|
status: "installed",
|
|
}) as ISoftwareScriptResult
|
|
}
|
|
isMyDevicePage={false}
|
|
/>
|
|
);
|
|
|
|
expect(screen.queryByTestId("success-icon")).toBeInTheDocument();
|
|
expect(screen.getByText(/Fleet ran/)).toBeInTheDocument();
|
|
expect(screen.getByText(/CoolApp/)).toBeInTheDocument();
|
|
expect(screen.getByText(/Test Host/)).toBeInTheDocument();
|
|
expect(screen.getByText(/\(com\.cool\.app\)/)).toBeInTheDocument();
|
|
expect(screen.getByText(/\d+.*ago/)).toBeInTheDocument();
|
|
});
|
|
});
|
|
|
|
describe("SoftwareScriptDetailsModal - ModalButtons component", () => {
|
|
it("on device user page, shows Rerun/Cancel for failed install and triggers handlers", async () => {
|
|
const onCancel = jest.fn();
|
|
const onRerun = jest.fn();
|
|
|
|
const { user } = renderWithSetup(
|
|
<ModalButtons
|
|
deviceAuthToken="token123"
|
|
installResultStatus="failed_install"
|
|
hostSoftwareId={99}
|
|
onCancel={onCancel}
|
|
onRerun={onRerun}
|
|
/>
|
|
);
|
|
expect(screen.getByRole("button", { name: "Rerun" })).toBeInTheDocument();
|
|
expect(screen.getByRole("button", { name: "Cancel" })).toBeInTheDocument();
|
|
|
|
await user.click(screen.getByRole("button", { name: "Rerun" }));
|
|
expect(onRerun).toHaveBeenCalledWith(99, true);
|
|
expect(onCancel).toHaveBeenCalled();
|
|
|
|
await user.click(screen.getByRole("button", { name: "Cancel" }));
|
|
expect(onCancel).toHaveBeenCalledTimes(2);
|
|
});
|
|
|
|
it("shows Close button for pending run", () => {
|
|
const onCancel = jest.fn();
|
|
render(
|
|
<ModalButtons installResultStatus="pending_script" onCancel={onCancel} />
|
|
);
|
|
expect(screen.getByRole("button", { name: "Close" })).toBeInTheDocument();
|
|
expect(
|
|
screen.queryByRole("button", { name: "Rerun" })
|
|
).not.toBeInTheDocument();
|
|
});
|
|
|
|
it("on device user page, shows Close button for ran script-only software script", () => {
|
|
const onCancel = jest.fn();
|
|
render(
|
|
<ModalButtons
|
|
deviceAuthToken="token123"
|
|
installResultStatus="installed"
|
|
onCancel={onCancel}
|
|
/>
|
|
);
|
|
expect(screen.getByRole("button", { name: "Close" })).toBeInTheDocument();
|
|
});
|
|
});
|