change TurnOnMDMMessage component to generic TurnOnMessage and use in end user auth page (#36477)
<!-- Add the related story/sub-task/bug number, like Resolves #123, or remove if NA --> **Related issue:** Resolves #35296 This makes the TurnOnMDMMessage component more generic and display a configurage "Turn on" message. We then are able to use this in the End user auth page on the controls page. - [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] QA'd all new/changed functionality manually
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
import React from "react";
|
||||
import { fireEvent, render, screen } from "@testing-library/react";
|
||||
import { createCustomRenderer, createMockRouter } from "test/test-utils";
|
||||
|
||||
import PATHS from "router/paths";
|
||||
|
||||
import GenericMsgWithNavButton from "./GenericMsgWithNavButton";
|
||||
|
||||
describe("GenericMsgWithNavButton", () => {
|
||||
it("renders with passed in header and info", () => {
|
||||
render(
|
||||
<GenericMsgWithNavButton
|
||||
header="Manage your hosts"
|
||||
info="MDM must be turned on to change settings on your hosts."
|
||||
path={PATHS.ADMIN_INTEGRATIONS_MDM}
|
||||
buttonText="Turn on"
|
||||
router={createMockRouter()}
|
||||
/>
|
||||
);
|
||||
|
||||
expect(screen.getByText("Manage your hosts")).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByText(
|
||||
"MDM must be turned on to change settings on your hosts."
|
||||
)
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders "Turn on" button for global admin pushes to /settings/integrration/mdm when "Turn on" button is clicked', () => {
|
||||
const customRender = createCustomRenderer({
|
||||
context: {
|
||||
app: {
|
||||
isGlobalAdmin: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
customRender(
|
||||
<GenericMsgWithNavButton
|
||||
header="test"
|
||||
info="test"
|
||||
buttonText="Turn on"
|
||||
path={PATHS.ADMIN_INTEGRATIONS_MDM}
|
||||
router={createMockRouter()}
|
||||
/>
|
||||
);
|
||||
|
||||
fireEvent.click(screen.getByRole("button", { name: "Turn on" }));
|
||||
|
||||
expect(createMockRouter().push).toHaveBeenCalledWith(
|
||||
PATHS.ADMIN_INTEGRATIONS_MDM
|
||||
);
|
||||
});
|
||||
|
||||
it("does not render the button for non-global admin", () => {
|
||||
const customRender = createCustomRenderer({
|
||||
context: {
|
||||
app: {
|
||||
isGlobalAdmin: false,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
customRender(
|
||||
<GenericMsgWithNavButton
|
||||
header="test"
|
||||
info="test"
|
||||
path={"test"}
|
||||
buttonText="Turn on"
|
||||
router={createMockRouter()}
|
||||
/>
|
||||
);
|
||||
|
||||
expect(screen.queryByText("Turn on")).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user