mirror of
https://github.com/fleetdm/fleet
synced 2026-05-22 16:39:01 +00:00
fix issue with windows mdm manual enrollment setting (#36418)
<!-- Add the related story/sub-task/bug number, like Resolves #123, or remove if NA --> **Related issue:** Resolves #36303 Fixes an issue where a user could not update window mdm in fleet UI when they had automatic enrollment with auto migrate enabled and then select manual mdm enrollment - [x] QA'd all new/changed functionality manually
This commit is contained in:
parent
c8ae78eac3
commit
6bf488ca0c
2 changed files with 75 additions and 0 deletions
|
|
@ -0,0 +1,74 @@
|
|||
import React from "react";
|
||||
|
||||
import { screen } from "@testing-library/react";
|
||||
|
||||
import { createMockRouter, createCustomRenderer } from "test/test-utils";
|
||||
import { createMockConfig, createMockMdmConfig } from "__mocks__/configMock";
|
||||
import WindowsMdmPage from "./WindowsMdmPage";
|
||||
|
||||
describe("WindowsMdmPage", () => {
|
||||
it("renders only the windows mdm slider and description when on free tier", () => {
|
||||
const render = createCustomRenderer({
|
||||
context: {
|
||||
app: {
|
||||
isPremiumTier: false,
|
||||
config: createMockConfig(),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
render(<WindowsMdmPage router={createMockRouter()} />);
|
||||
|
||||
// switch and description only shown
|
||||
expect(screen.getByRole("switch")).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByText(
|
||||
"Turns on MDM for Windows hosts that enroll to Fleet (excluding servers)."
|
||||
)
|
||||
).toBeInTheDocument();
|
||||
|
||||
// no end user experience form
|
||||
expect(screen.queryByLabelText("Automatic")).not.toBeInTheDocument();
|
||||
expect(screen.queryByLabelText("Manual")).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("renders the end user experience form as disabled when MDM is off", () => {
|
||||
const render = createCustomRenderer({
|
||||
context: {
|
||||
app: {
|
||||
isPremiumTier: true,
|
||||
config: createMockConfig({
|
||||
mdm: createMockMdmConfig({ windows_enabled_and_configured: false }),
|
||||
}),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
render(<WindowsMdmPage router={createMockRouter()} />);
|
||||
|
||||
expect(screen.getByLabelText("Automatic")).toBeDisabled();
|
||||
expect(screen.getByLabelText("Manual")).toBeDisabled();
|
||||
});
|
||||
|
||||
it("renders the automatically migrate checkbox if automatic mdm enrollment is selected", () => {
|
||||
const render = createCustomRenderer({
|
||||
context: {
|
||||
app: {
|
||||
isPremiumTier: true,
|
||||
config: createMockConfig({
|
||||
mdm: createMockMdmConfig({
|
||||
enable_turn_on_windows_mdm_manually: false,
|
||||
windows_enabled_and_configured: true,
|
||||
}),
|
||||
}),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
render(<WindowsMdmPage router={createMockRouter()} />);
|
||||
|
||||
// automatic is selected and the checkbox is visible
|
||||
expect(screen.getByLabelText("Automatic")).toBeChecked();
|
||||
expect(screen.getByRole("checkbox")).toBeVisible();
|
||||
});
|
||||
});
|
||||
|
|
@ -103,6 +103,7 @@ const WindowsMdmPage = ({ router }: IWindowsMdmPageProps) => {
|
|||
};
|
||||
|
||||
const onChangeEnrollmentType = (value: string) => {
|
||||
setAutoMigration(false);
|
||||
setEnrollmentType(value === "automaticEnrollment" ? "automatic" : "manual");
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue