fleet/frontend/pages/hosts/details/OSSettingsModal/OSSettingsTable/OSSettingStatusCell/OSSettingStatusCell.tests.tsx
jacobshandling 35a5138ea5
UI expect "delivering" and "delivered" statuses when removing Android certs (#37514)
<!-- Add the related story/sub-task/bug number, like Resolves #123, or
remove if NA -->
**Related issue:** Resolves
https://github.com/fleetdm/fleet/issues/36683#issuecomment-3671505923

- [x] Added/updated automated tests
- [x] QA'd all new/changed functionality manually
2025-12-18 14:59:14 -08:00

153 lines
4.5 KiB
TypeScript

import React from "react";
import { render, screen } from "@testing-library/react";
import { createCustomRenderer } from "test/test-utils";
import {
FLEET_ANDROID_CERTIFICATE_TEMPLATE_PROFILE_ID,
ProfileOperationType,
} from "interfaces/mdm";
import OSSettingStatusCell from "./OSSettingStatusCell";
describe("OS setting status cell", () => {
it("Correctly displays the status text of a profile", () => {
const status = "verifying";
const operationType: ProfileOperationType = "install";
render(
<OSSettingStatusCell
profileName="Test Profile"
status={status}
operationType={operationType}
/>
);
expect(screen.getByText("Verifying")).toBeInTheDocument();
});
it("Correctly displays the tooltip text for a profile", async () => {
const status = "verifying";
const operationType: ProfileOperationType = "install";
const customRender = createCustomRenderer();
const { user } = customRender(
<OSSettingStatusCell
profileName="Test Profile"
status={status}
operationType={operationType}
/>
);
const statusText = screen.getByText("Verifying");
await user.hover(statusText);
expect(screen.getByText(/verifying/)).toBeInTheDocument();
});
// Android cert statuses
it("Displays Pending UI for 'pending' status with optype 'install'", async () => {
const customRender = createCustomRenderer();
const { user } = customRender(
<OSSettingStatusCell
profileName="Test cert"
status="pending"
operationType="install"
hostPlatform="android"
profileUUID={FLEET_ANDROID_CERTIFICATE_TEMPLATE_PROFILE_ID}
/>
);
const statusText = screen.getByText("Enforcing (pending)");
expect(statusText).toBeInTheDocument();
await user.hover(statusText);
expect(
screen.getByText(/The host is running the command/)
).toBeInTheDocument();
});
it("Displays Pending UI for 'delivering' status with optype 'install'", async () => {
const customRender = createCustomRenderer();
const { user } = customRender(
<OSSettingStatusCell
profileName="Test cert"
status="delivering"
operationType="install"
hostPlatform="android"
profileUUID={FLEET_ANDROID_CERTIFICATE_TEMPLATE_PROFILE_ID}
/>
);
const statusText = screen.getByText("Enforcing (pending)");
expect(statusText).toBeInTheDocument();
await user.hover(statusText);
expect(
screen.getByText(/The host is running the command/)
).toBeInTheDocument();
});
it("Displays Pending UI for 'delivered' status with optype 'install'", async () => {
const customRender = createCustomRenderer();
const { user } = customRender(
<OSSettingStatusCell
profileName="Test cert"
status="delivered"
operationType="install"
hostPlatform="android"
profileUUID={FLEET_ANDROID_CERTIFICATE_TEMPLATE_PROFILE_ID}
/>
);
const statusText = screen.getByText("Enforcing (pending)");
expect(statusText).toBeInTheDocument();
await user.hover(statusText);
expect(
screen.getByText(/The host is running the command/)
).toBeInTheDocument();
});
it("Displays Pending UI for 'delivering' status with optype 'remove'", async () => {
const customRender = createCustomRenderer();
const { user } = customRender(
<OSSettingStatusCell
profileName="Test cert"
status="delivering"
operationType="remove"
hostPlatform="android"
profileUUID={FLEET_ANDROID_CERTIFICATE_TEMPLATE_PROFILE_ID}
/>
);
const statusText = screen.getByText("Removing enforcement (pending)");
expect(statusText).toBeInTheDocument();
await user.hover(statusText);
expect(
screen.getByText(/The host is running the command/)
).toBeInTheDocument();
});
it("Displays Pending UI for 'delivered' status with optype 'remove'", async () => {
const customRender = createCustomRenderer();
const { user } = customRender(
<OSSettingStatusCell
profileName="Test cert"
status="delivered"
operationType="remove"
hostPlatform="android"
profileUUID={FLEET_ANDROID_CERTIFICATE_TEMPLATE_PROFILE_ID}
/>
);
const statusText = screen.getByText("Removing enforcement (pending)");
expect(statusText).toBeInTheDocument();
await user.hover(statusText);
expect(
screen.getByText(/The host is running the command/)
).toBeInTheDocument();
});
});