diff --git a/frontend/pages/DashboardPage/cards/ActivityFeed/ActivityItem/ActivityItem.tests.tsx b/frontend/pages/DashboardPage/cards/ActivityFeed/ActivityItem/ActivityItem.tests.tsx index 0547be584..6c85d04a5 100644 --- a/frontend/pages/DashboardPage/cards/ActivityFeed/ActivityItem/ActivityItem.tests.tsx +++ b/frontend/pages/DashboardPage/cards/ActivityFeed/ActivityItem/ActivityItem.tests.tsx @@ -347,4 +347,77 @@ describe("Activity Feed", () => { const forAllTeams = screen.queryByText("for all teams."); expect(forAllTeams).toBeNull(); }); + + it("renders an 'enabled_macos_disk_encryption' type activity for a team", () => { + const activity = createMockActivity({ + type: ActivityType.EnabledMacDiskEncryption, + details: { team_name: "Alphas" }, + }); + render(); + + expect( + screen.getByText( + "enforced disk encryption for macOS hosts assigned to the", + { + exact: false, + } + ) + ).toBeInTheDocument(); + expect(screen.getByText("Alphas")).toBeInTheDocument(); + expect(screen.getByText(" team.", { exact: false })).toBeInTheDocument(); + const withNoTeams = screen.queryByText("with no team"); + expect(withNoTeams).toBeNull(); + }); + + it("renders a 'disabled_macos_disk_encryption' type activity for a team", () => { + const activity = createMockActivity({ + type: ActivityType.DisabledMacDiskEncryption, + details: { team_name: "Alphas" }, + }); + render(); + + expect( + screen.getByText( + "removed disk encryption enforcement for macOS hosts assigned to the", + { + exact: false, + } + ) + ).toBeInTheDocument(); + expect(screen.getByText("Alphas")).toBeInTheDocument(); + expect(screen.getByText(" team.", { exact: false })).toBeInTheDocument(); + const withNoTeams = screen.queryByText("with no team"); + expect(withNoTeams).toBeNull(); + }); + + it("renders an 'enabled_macos_disk_encryption' type activity for hosts with no team.", () => { + const activity = createMockActivity({ + type: ActivityType.EnabledMacDiskEncryption, + details: {}, + }); + render(); + + expect( + screen.getByText("enforced disk encryption for macOS hosts with no team.") + ).toBeInTheDocument(); + expect(screen.queryByText("assigned to the")).toBeNull(); + }); + + it("renders a 'disabled_macos_disk_encryption' type activity for hosts with no team.", () => { + const activity = createMockActivity({ + type: ActivityType.DisabledMacDiskEncryption, + details: {}, + }); + render(); + + expect( + screen.getByText( + "removed disk encryption enforcement for macOS hosts with no team.", + { + exact: false, + } + ) + ).toBeInTheDocument(); + expect(screen.queryByText("assigned to the")).toBeNull(); + }); }); diff --git a/frontend/pages/DashboardPage/cards/ActivityFeed/ActivityItem/ActivityItem.tsx b/frontend/pages/DashboardPage/cards/ActivityFeed/ActivityItem/ActivityItem.tsx index c36c1fcd4..9595b2613 100644 --- a/frontend/pages/DashboardPage/cards/ActivityFeed/ActivityItem/ActivityItem.tsx +++ b/frontend/pages/DashboardPage/cards/ActivityFeed/ActivityItem/ActivityItem.tsx @@ -286,22 +286,12 @@ const TAGGED_TEMPLATES = { ); }, enableMacDiskEncryption: (activity: IActivity) => { - return ( - <> - {" "} - enforced disk encryption for macOS hosts{" "} - {getDiskEncryptionMessageSuffix(activity.details?.team_name)}. - - ); + const suffix = getDiskEncryptionMessageSuffix(activity.details?.team_name); + return <> enforced disk encryption for macOS hosts {suffix}.; }, disableMacDiskEncryption: (activity: IActivity) => { - return ( - <> - {" "} - removed disk encryption enforcement for macOS hosts{" "} - {getDiskEncryptionMessageSuffix(activity.details?.team_name)}. - - ); + const suffix = getDiskEncryptionMessageSuffix(activity.details?.team_name); + return <>removed disk encryption enforcement for macOS hosts {suffix}.; }, defaultActivityTemplate: (activity: IActivity) => { const entityName = find(activity.details, (_, key) => diff --git a/frontend/utilities/url/url.tests.ts b/frontend/utilities/url/url.tests.ts index ed0dd8738..f6b88c934 100644 --- a/frontend/utilities/url/url.tests.ts +++ b/frontend/utilities/url/url.tests.ts @@ -14,6 +14,19 @@ describe("url utilities > reconcileMutuallyInclusiveHostParams", () => { }); }); + it("leaves macSettingsStatus and teamId unchanged when both are present, teamId=0", () => { + const [macSettingsStatus, teamId] = ["pending" as const, 0]; + expect( + reconcileMutuallyInclusiveHostParams({ + macSettingsStatus, + teamId, + }) + ).toEqual({ + macos_settings: "pending", + team_id: 0, + }); + }); + it("adds team_id: 0 when macSettingsStatus is present and teamId is not", () => { const [macSettingsStatus, teamId] = ["pending" as const, undefined]; expect(