mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 21:47:20 +00:00
<!-- Add the related story/sub-task/bug number, like Resolves #123, or remove if NA --> **Related issue:** Resolves #40702 New look: <img width="812" height="350" alt="image" src="https://github.com/user-attachments/assets/83e82480-b756-4c51-be3f-09a72e736770" /> # Checklist for submitter If some of the following don't apply, delete the relevant line. - [x] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files) for more information. - [x] Input data is properly validated, `SELECT *` is avoided, SQL injection is prevented (using placeholders for values in statements), JS inline code is prevented especially for url redirects, and untrusted data interpolated into shell scripts/commands is validated against shell metacharacters. - [x] Timeouts are implemented and retries are limited to avoid infinite loops - [x] If paths of existing endpoints are modified without backwards compatibility, checked the frontend/CLI for any necessary changes ## Testing - [x] Added/updated automated tests - [x] QA'd all new/changed functionality manually <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Simplified pending status labels in OS Settings modal by removing "(pending)" suffix from states like "Enforcing" and "Removing enforcement" * Improved OS Settings modal table layout and styling * **New Features** * Added dedicated action buttons to resend MDM profiles and rotate Recovery Lock password * Enhanced error tooltip handling for failed profile states <!-- end of auto-generated comment: release notes by coderabbit.ai -->
164 lines
4.7 KiB
TypeScript
164 lines
4.7 KiB
TypeScript
import React from "react";
|
|
import { render, screen, waitFor } 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);
|
|
await waitFor(() => {
|
|
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");
|
|
expect(statusText).toBeInTheDocument();
|
|
|
|
await user.hover(statusText);
|
|
await waitFor(() => {
|
|
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");
|
|
expect(statusText).toBeInTheDocument();
|
|
|
|
await user.hover(statusText);
|
|
await waitFor(() => {
|
|
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");
|
|
expect(statusText).toBeInTheDocument();
|
|
|
|
await user.hover(statusText);
|
|
await waitFor(() => {
|
|
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");
|
|
expect(statusText).toBeInTheDocument();
|
|
|
|
await user.hover(statusText);
|
|
await waitFor(() => {
|
|
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");
|
|
expect(statusText).toBeInTheDocument();
|
|
|
|
await user.hover(statusText);
|
|
await waitFor(() => {
|
|
expect(
|
|
screen.getByText(/The host is running the command/)
|
|
).toBeInTheDocument();
|
|
});
|
|
});
|
|
});
|