Frontend integration tests: Create mock mac admins handler (#8728)

This commit is contained in:
RachelElysia 2022-11-16 13:57:51 -05:00 committed by GitHub
parent 9b709b23a9
commit 82d1c13b44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 40 additions and 0 deletions

View File

@ -0,0 +1,24 @@
import { IMacadminsResponse } from "interfaces/host";
const DEFAULT_MAC_ADMINS_MOCK: IMacadminsResponse = {
macadmins: {
mobile_device_management: {
enrollment_status: "Enrolled (manual)",
server_url: "https://kandji.com/2",
name: "Kandji",
id: 11,
},
munki: {
version: "1.2.3",
},
munki_issues: [],
},
};
const createMockMacAdmins = (
overrides?: Partial<IMacadminsResponse>
): IMacadminsResponse => {
return { ...DEFAULT_MAC_ADMINS_MOCK, ...overrides };
};
export default createMockMacAdmins;

View File

@ -87,6 +87,8 @@ export interface IMunkiData {
export interface IMDMData {
enrollment_status: string;
server_url: string;
id: number;
name: string;
}
export interface IMunkiIssue {

View File

@ -2,6 +2,7 @@ import { defaultActivityHandler } from "./handlers/activity-handlers";
import {
defaultDeviceHandler,
defaultDeviceMappingHandler,
defaultMacAdminsHandler,
} from "./handlers/device-handler";
export const baseUrl = (path: string) => {
@ -11,6 +12,7 @@ export const baseUrl = (path: string) => {
const handlers = [
defaultDeviceHandler,
defaultDeviceMappingHandler,
defaultMacAdminsHandler,
defaultActivityHandler,
];

View File

@ -3,6 +3,7 @@ import { rest } from "msw";
import createMockDeviceUser from "__mocks__/deviceUserMock";
import createMockHost from "__mocks__/hostMock";
import createMockLicense from "__mocks__/licenseMock";
import createMockMacAdmins from "__mocks__/macAdminsMock";
import { baseUrl } from "test/test-utils";
export const defaultDeviceHandler = rest.get(
@ -29,3 +30,14 @@ export const defaultDeviceMappingHandler = rest.get(
);
}
);
export const defaultMacAdminsHandler = rest.get(
baseUrl("/device/:token/macadmins"),
(req, res, context) => {
return res(
context.json({
macadmins: createMockMacAdmins(),
})
);
}
);