mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 17:05:18 +00:00
Add some tests; minor cleaning (#10582)
This commit is contained in:
parent
bbc16ef180
commit
def8fd1309
@ -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(<ActivityItem activity={activity} isPremiumTier />);
|
||||
|
||||
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(<ActivityItem activity={activity} isPremiumTier />);
|
||||
|
||||
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(<ActivityItem activity={activity} isPremiumTier />);
|
||||
|
||||
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(<ActivityItem activity={activity} isPremiumTier />);
|
||||
|
||||
expect(
|
||||
screen.getByText(
|
||||
"removed disk encryption enforcement for macOS hosts with no team.",
|
||||
{
|
||||
exact: false,
|
||||
}
|
||||
)
|
||||
).toBeInTheDocument();
|
||||
expect(screen.queryByText("assigned to the")).toBeNull();
|
||||
});
|
||||
});
|
||||
|
@ -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) =>
|
||||
|
@ -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(
|
||||
|
Loading…
Reference in New Issue
Block a user