fleet/frontend/pages/hosts/details/OSSettingsModal/OSSettingsTable/OSSettingsResendCell/OSSettingsResendCell.tests.tsx
Magnus Jensen 90f75f1644
simplify OS modal (#43252)
<!-- 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 -->
2026-04-09 16:30:15 -05:00

112 lines
3.3 KiB
TypeScript

import React from "react";
import { render, screen } from "@testing-library/react";
import { createMockHostMdmProfile } from "__mocks__/hostMock";
import { REC_LOCK_SYNTHETIC_PROFILE_UUID } from "pages/hosts/details/helpers";
import OSSettingsResendCell from "./OSSettingsResendCell";
const noop = () => Promise.resolve();
describe("OSSettingsResendCell", () => {
it("renders a resend button when canResendProfiles is true and profile is failed", () => {
render(
<OSSettingsResendCell
canResendProfiles
canRotateRecoveryLockPassword={false}
profile={createMockHostMdmProfile({ status: "failed" })}
resendRequest={noop}
rotateRecoveryLockPassword={noop}
/>
);
expect(screen.getByRole("button", { name: "Resend" })).toBeInTheDocument();
});
it("renders a resend button when canResendProfiles is true and profile is verified", () => {
render(
<OSSettingsResendCell
canResendProfiles
canRotateRecoveryLockPassword={false}
profile={createMockHostMdmProfile({ status: "verified" })}
resendRequest={noop}
rotateRecoveryLockPassword={noop}
/>
);
expect(screen.getByRole("button", { name: "Resend" })).toBeInTheDocument();
});
it("renders a rotate button when canRotateRecoveryLockPassword is true and password status is verified", () => {
render(
<OSSettingsResendCell
canResendProfiles={false}
canRotateRecoveryLockPassword
profile={createMockHostMdmProfile({
profile_uuid: REC_LOCK_SYNTHETIC_PROFILE_UUID,
status: "verified",
})}
resendRequest={noop}
rotateRecoveryLockPassword={noop}
/>
);
expect(screen.getByRole("button", { name: "Rotate" })).toBeInTheDocument();
});
it("renders a rotate button when canRotateRecoveryLockPassword is true and password status is failed", () => {
render(
<OSSettingsResendCell
canResendProfiles={false}
canRotateRecoveryLockPassword
profile={createMockHostMdmProfile({
profile_uuid: REC_LOCK_SYNTHETIC_PROFILE_UUID,
status: "failed",
})}
resendRequest={noop}
rotateRecoveryLockPassword={noop}
/>
);
expect(screen.getByRole("button", { name: "Rotate" })).toBeInTheDocument();
});
it("does not render a rotate button when canRotateRecoveryLockPassword is false", () => {
render(
<OSSettingsResendCell
canResendProfiles={false}
canRotateRecoveryLockPassword={false}
profile={createMockHostMdmProfile({
profile_uuid: REC_LOCK_SYNTHETIC_PROFILE_UUID,
status: "verified",
})}
resendRequest={noop}
rotateRecoveryLockPassword={noop}
/>
);
expect(
screen.queryByRole("button", { name: "Rotate" })
).not.toBeInTheDocument();
});
it("does not render a rotate button when password status is pending", () => {
render(
<OSSettingsResendCell
canResendProfiles={false}
canRotateRecoveryLockPassword
profile={createMockHostMdmProfile({
profile_uuid: REC_LOCK_SYNTHETIC_PROFILE_UUID,
status: "pending",
})}
resendRequest={noop}
rotateRecoveryLockPassword={noop}
/>
);
expect(
screen.queryByRole("button", { name: "Rotate" })
).not.toBeInTheDocument();
});
});