mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 13:37:30 +00:00
parent
91160dedc2
commit
4df3012906
2 changed files with 39 additions and 5 deletions
|
|
@ -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(
|
||||
<MDMStatusModal
|
||||
hostId={3}
|
||||
enrollmentStatus="On (manual)"
|
||||
router={mockRouter}
|
||||
isPremiumTier
|
||||
isAppleDevice
|
||||
onExit={jest.fn()}
|
||||
/>
|
||||
);
|
||||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
),
|
||||
|
|
|
|||
Loading…
Reference in a new issue