diff --git a/frontend/pages/hosts/details/modals/MDMStatusModal/MDMStatusModal.tests.tsx b/frontend/pages/hosts/details/modals/MDMStatusModal/MDMStatusModal.tests.tsx index c53a14e9c3..a36084fa0f 100644 --- a/frontend/pages/hosts/details/modals/MDMStatusModal/MDMStatusModal.tests.tsx +++ b/frontend/pages/hosts/details/modals/MDMStatusModal/MDMStatusModal.tests.tsx @@ -293,6 +293,34 @@ describe("MDMStatusModal - component", () => { }); }); + it("renders 'Never' for zero-value profile timestamps", async () => { + (hostAPI.getDepAssignment as jest.Mock).mockResolvedValue({ + ...mockDepAssignmentResponse, + dep_device: { + ...mockDepAssignmentResponse.dep_device, + profile_assign_time: "0001-01-01T00:00:00Z", + profile_push_time: "0001-01-01T00:00:00Z", + }, + }); + + render( + + ); + + await screen.findByText("Profile assigned"); + + const neverTexts = screen.getAllByText("Never"); + // Both profile_assign_time and profile_push_time should show "Never" + expect(neverTexts.length).toBeGreaterThanOrEqual(2); + }); + it("calls onExit when Close is clicked", async () => { (hostAPI.getDepAssignment as jest.Mock).mockResolvedValue( mockDepAssignmentResponse diff --git a/frontend/pages/hosts/details/modals/MDMStatusModal/MDMStatusModal.tsx b/frontend/pages/hosts/details/modals/MDMStatusModal/MDMStatusModal.tsx index 026f084329..fb0958039e 100644 --- a/frontend/pages/hosts/details/modals/MDMStatusModal/MDMStatusModal.tsx +++ b/frontend/pages/hosts/details/modals/MDMStatusModal/MDMStatusModal.tsx @@ -7,6 +7,7 @@ import { addHours, differenceInMinutes } from "date-fns"; import { internationalTimeFormat } from "utilities/helpers"; import { DEFAULT_EMPTY_CELL_VALUE, + INITIAL_FLEET_DATE, LEARN_MORE_ABOUT_BASE_LINK, MDM_STATUS_TOOLTIP, } from "utilities/constants"; @@ -371,9 +372,13 @@ const MDMStatusModal = ({ ), // Follow current pattern of international time format for dates in UI - status: internationalTimeFormat( - new Date(depAssignmentData.dep_device?.profile_assign_time) - ), + status: + !depAssignmentData.dep_device?.profile_assign_time || + depAssignmentData.dep_device.profile_assign_time < INITIAL_FLEET_DATE + ? "Never" + : internationalTimeFormat( + new Date(depAssignmentData.dep_device.profile_assign_time) + ), }, { id: "profile-pushed", @@ -387,8 +392,9 @@ const MDMStatusModal = ({ ), // Follow current pattern of international time format for dates in UI status: - depAssignmentData.dep_device.profile_push_time === "" - ? DEFAULT_EMPTY_CELL_VALUE + !depAssignmentData.dep_device.profile_push_time || + depAssignmentData.dep_device.profile_push_time < INITIAL_FLEET_DATE + ? "Never" : internationalTimeFormat( new Date(depAssignmentData.dep_device.profile_push_time) ),