**Related issue:** Resolves #47717 # Checklist for submitter If some of the following don't apply, delete the relevant line. - [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. _Front end only_ ## 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 * **New Features** * Added Apple OS update targeting options for no enforcement, a custom minimum version, or the latest available version. * Added configurable whole-day deadlines for macOS, iOS, and iPadOS updates. * Added platform-specific target controls, validation, and automatic new-host updates for latest-version targeting. * Displayed minimum versions, pending status, and update deadlines in host details and activity feeds. * Clarified Windows deadlines as days after release. * **Style** * Improved layout and spacing for Apple and Windows update forms. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Jordan Montgomery <elijah.jordan.montgomery@gmail.com>
90 lines
3.0 KiB
TypeScript
90 lines
3.0 KiB
TypeScript
import React from "react";
|
|
import { screen } from "@testing-library/react";
|
|
import { noop } from "lodash";
|
|
|
|
import { createCustomRenderer } from "test/test-utils";
|
|
|
|
import PlatformTabs from "./PlatformTabs";
|
|
|
|
const render = createCustomRenderer({ withBackendMock: true });
|
|
|
|
const defaultProps = {
|
|
currentTeamId: 1,
|
|
defaultMacOSVersion: "11.0",
|
|
defaultMacOSDeadline: "2024-12-31",
|
|
defaultMacOSDeadlineDays: "",
|
|
defaultMacOSUpdateNewHosts: true,
|
|
defaultIOSVersion: "17.5",
|
|
defaultIOSDeadline: "2024-12-31",
|
|
defaultIOSDeadlineDays: "",
|
|
defaultIPadOSVersion: "18.5",
|
|
defaultIPadOSDeadline: "2024-12-31",
|
|
defaultIPadOSDeadlineDays: "",
|
|
defaultWindowsDeadlineDays: "5",
|
|
defaultWindowsGracePeriodDays: "2",
|
|
onSelectPlatform: noop,
|
|
refetchAppConfig: noop,
|
|
refetchTeamConfig: noop,
|
|
isWindowsMdmEnabled: true,
|
|
isAndroidMdmEnabled: true,
|
|
};
|
|
|
|
describe("PlatformTabs", () => {
|
|
// Only the Apple forms offer a target to choose; Windows is always deadline
|
|
// driven and Android isn't supported yet. The tabs decide which form each
|
|
// platform gets, so the dropdown must not leak into the other two.
|
|
it("renders the target dropdown on the macOS tab", () => {
|
|
render(<PlatformTabs {...defaultProps} selectedPlatform="darwin" />);
|
|
|
|
expect(screen.getByLabelText(/Target/i)).toBeInTheDocument();
|
|
expect(screen.getByLabelText(/Minimum version/i)).toBeInTheDocument();
|
|
});
|
|
|
|
it("renders the target dropdown on the iOS tab", () => {
|
|
render(<PlatformTabs {...defaultProps} selectedPlatform="ios" />);
|
|
|
|
expect(screen.getByLabelText(/Target/i)).toBeInTheDocument();
|
|
});
|
|
|
|
it("renders the target dropdown on the iPadOS tab", () => {
|
|
render(<PlatformTabs {...defaultProps} selectedPlatform="ipados" />);
|
|
|
|
expect(screen.getByLabelText(/Target/i)).toBeInTheDocument();
|
|
});
|
|
|
|
it("does not render the target dropdown on the Windows tab", () => {
|
|
render(<PlatformTabs {...defaultProps} selectedPlatform="windows" />);
|
|
|
|
expect(screen.queryByLabelText(/Target/i)).not.toBeInTheDocument();
|
|
// Windows fields don't associate their labels with the input, so match the
|
|
// label text rather than the control.
|
|
expect(screen.getByText(/Grace period/i)).toBeInTheDocument();
|
|
});
|
|
|
|
it("does not render the target dropdown on the Android tab", () => {
|
|
render(<PlatformTabs {...defaultProps} selectedPlatform="android" />);
|
|
|
|
expect(screen.queryByLabelText(/Target/i)).not.toBeInTheDocument();
|
|
expect(screen.getByText(/Android updates are coming soon/i)).toBeVisible();
|
|
});
|
|
|
|
it("hides the Windows and Android tabs when their MDM isn't enabled", () => {
|
|
render(
|
|
<PlatformTabs
|
|
{...defaultProps}
|
|
selectedPlatform="darwin"
|
|
isWindowsMdmEnabled={false}
|
|
isAndroidMdmEnabled={false}
|
|
/>
|
|
);
|
|
|
|
expect(screen.getByRole("tab", { name: /macOS/i })).toBeInTheDocument();
|
|
expect(
|
|
screen.queryByRole("tab", { name: /Windows/i })
|
|
).not.toBeInTheDocument();
|
|
expect(
|
|
screen.queryByRole("tab", { name: /Android/i })
|
|
).not.toBeInTheDocument();
|
|
});
|
|
});
|