fleet/frontend/pages/admin/IntegrationsPage/cards/Vpp/Vpp.tests.tsx
Gabriel Hernandez 845b524dcc
add/remove/disable vpp token in Fleet UI (#20127)
relates to #19866

> NOTE: API integration work still needs to be done, which will happen
in another PR.

This adds the ability to add, remove, or disable a VPP token in the
Fleet UI. This includes:

**Vpp integration page with VPP card:**


![image](https://github.com/fleetdm/fleet/assets/1153709/99b1ca9b-8872-447f-a085-b5385a2b7f7e)


![image](https://github.com/fleetdm/fleet/assets/1153709/1cdb80a2-1afe-4739-994c-fe7430449f13)


![image](https://github.com/fleetdm/fleet/assets/1153709/79ec7927-f905-48c4-b1b9-42d4d6b41028)

**VPP setup page with steps to set up VPP:**


![image](https://github.com/fleetdm/fleet/assets/1153709/dec203e4-01d3-4e1d-b493-be3772b72813)

**VPP setup page with VPP info:**


![image](https://github.com/fleetdm/fleet/assets/1153709/afccba29-e97b-4937-8235-4706e39d9333)

**Disable VPP modal:**


![image](https://github.com/fleetdm/fleet/assets/1153709/da4a2db3-7546-4f3b-8ec0-d77ad7bff19f)

**renew Vpp modal:**


![image](https://github.com/fleetdm/fleet/assets/1153709/8224f466-6aae-43bd-a120-3de5f0c90064)

- [x] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [x] Manual QA for all new/changed functionality
2024-07-10 17:05:09 +01:00

75 lines
2 KiB
TypeScript

import React from "react";
import { screen } from "@testing-library/react";
import { createCustomRenderer, createMockRouter } from "test/test-utils";
import mockServer from "test/mock-server";
import {
defaultVppInfoHandler,
errorNoVppInfoHandler,
} from "test/handlers/apple_mdm";
import createMockConfig, { createMockMdmConfig } from "__mocks__/configMock";
import Vpp from "./Vpp";
describe("Vpp Section", () => {
it("renders turn on apple mdm message when apple mdm is not turned on ", async () => {
mockServer.use(defaultVppInfoHandler);
const render = createCustomRenderer({
context: {
app: {
config: createMockConfig({
mdm: createMockMdmConfig({ enabled_and_configured: false }),
}),
},
},
withBackendMock: true,
});
render(<Vpp router={createMockRouter()} />);
expect(
await screen.findByRole("button", { name: "Turn on macOS MDM" })
).toBeInTheDocument();
});
it("renders enable vpp when vpp is disabled", async () => {
mockServer.use(errorNoVppInfoHandler);
const render = createCustomRenderer({
context: {
app: {
config: createMockConfig({
mdm: createMockMdmConfig({ enabled_and_configured: true }),
}),
},
},
withBackendMock: true,
});
render(<Vpp router={createMockRouter()} />);
expect(
await screen.findByRole("button", { name: "Enable" })
).toBeInTheDocument();
});
it("renders edit vpp when vpp is enabled", async () => {
mockServer.use(defaultVppInfoHandler);
const render = createCustomRenderer({
context: {
app: {
config: createMockConfig({
mdm: createMockMdmConfig({ enabled_and_configured: true }),
}),
},
},
withBackendMock: true,
});
render(<Vpp router={createMockRouter()} />);
expect(
await screen.findByRole("button", { name: "Edit" })
).toBeInTheDocument();
});
});