fleet/frontend/__mocks__/mdmMock.ts
Scott Gress f1bad72003
Use new multiplatform keys on the front end (#41763)
<!-- Add the related story/sub-task/bug number, like Resolves #123, or
remove if NA -->
**Related issue:** Resolves #41601 

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Details

This PR updates the front end to use the following renamed API keys:

* bootstrap_package -> macos_bootstrap_package
* manual_agent_install -> macos_manual_agent_install
* enable_release_device_manually -> apple_
enable_release_device_manually
* script -> macos_script
* macos_setup -> setup_experience
* macos_settings -> apple_settings
* custom_settings -> configuration_profiles
* macos_setup_assistant -> apple_setup_assistant

It also ensures that consumers of the "get fleet config" API pull from
the `.fleet` property rather than `.team`, so that they can use all of
the newly renamed response fields.

## Summary by CodeRabbit

* **Refactor**
* Restructured Mobile Device Management configuration for Apple devices,
reorganizing setup experience, bootstrap package, and device
configuration field organization.
* Updated filter terminology and query parameters throughout device
management interfaces, improving how users filter and navigate Apple
device settings.
* Enhanced configuration field naming conventions for better clarity and
maintainability across device management features.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

# Checklist for submitter

If some of the following don't apply, delete the relevant line.

- [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.

## Testing

- [X] Added/updated automated tests
- [X] QA'd all new/changed functionality manually

  ---
  Manual Test Plan

  Prerequisites

  - Fleet server with MDM enabled (macOS at minimum)
  - At least one macOS host enrolled in Fleet MDM
  - A team configured with setup experience settings

  ---
  1. Manage Hosts — Filters

- [X] macOS settings filter:
  - Go to Hosts > Manage Hosts
  - Filter by macOS settings status (e.g. Pending, Verified, Failed)
  - Verify the filter applies and hosts list updates
  - Check that the URL contains apple_settings=<status>
- Copy the URL, paste it in a new tab — verify the filter is still
applied
- Manually edit the URL to use macos_settings=<status> instead — verify
it still works (backward compat)
- Clear the filter pill — verify both apple_settings and macos_settings
are removed from the URL

- [X] Bootstrap package filter:
  - Filter by bootstrap package status
  - Verify the URL contains macos_bootstrap_package=<status>
- Manually edit the URL to use bootstrap_package=<status> — verify it
still works
  - Clear the filter pill — verify both params are removed

  ---
  2. Setup Experience (Controls Page)

- [X] Bootstrap package:
  - Go to Controls > Setup experience for a team
  - Upload a bootstrap package — verify it appears in the table
- Toggle the "manual agent install" advanced option on/off — verify it
saves
  - Delete the bootstrap package — verify it's removed
- In the bootstrap package table, click "View all hosts" link for a
status row — verify it navigates to Manage Hosts with
macos_bootstrap_package in the URL

- [X] End user authentication:
  - Toggle end user authentication on/off for a team and for "No team"
  - Verify the toggle reflects the saved state after page reload

- [X] Setup assistant:
  - Upload a setup assistant profile
- Verify the "release device manually" toggle works for both a team and
"No team"

- [X] Install software:
- Verify the "require all software" checkbox reflects the correct saved
state for both team and "No team"
2026-03-30 08:56:21 -05:00

82 lines
1.9 KiB
TypeScript

import { IHostMdmData } from "interfaces/host";
import {
IMdmSolution,
IMdmProfile,
IMdmSummaryMdmSolution,
} from "interfaces/mdm";
const DEFAULT_MDM_SOLUTION_MOCK: IMdmSolution = {
id: 1,
name: "MDM Solution",
server_url: "http://mdmsolution.com",
hosts_count: 5,
};
export const createMockMdmSolution = (
overrides?: Partial<IMdmSolution>
): IMdmSolution => {
return { ...DEFAULT_MDM_SOLUTION_MOCK, ...overrides };
};
const DEFAULT_HOST_SUMMARY_MDM_SOLUTION_MOCK: IMdmSummaryMdmSolution = {
id: 1,
name: "MDM Solution",
server_url: "http://mdmsolution.com",
hosts_count: 5,
};
export const createMockMdmSummaryMdmSolution = (
overrides?: Partial<IMdmSummaryMdmSolution>
): IMdmSummaryMdmSolution => {
return { ...DEFAULT_HOST_SUMMARY_MDM_SOLUTION_MOCK, ...overrides };
};
const DEFAULT_MDM_PROFILE_DATA: IMdmProfile = {
profile_uuid: "123-abc",
team_id: 0,
name: "Test Profile",
platform: "darwin",
identifier: "com.test.profile",
created_at: "2021-01-01T00:00:00Z",
updated_at: "2021-01-01T00:00:00Z",
checksum: "123abc",
};
export const createMockMdmProfile = (
overrides?: Partial<IMdmProfile>
): IMdmProfile => {
return { ...DEFAULT_MDM_PROFILE_DATA, ...overrides };
};
const DEFAULT_HOST_MDM_DATA: IHostMdmData = {
encryption_key_available: false,
enrollment_status: "On (automatic)",
server_url: "http://mdmsolution.com",
name: "MDM Solution",
id: 1,
profiles: [],
os_settings: {
disk_encryption: {
status: "verified",
detail: "",
},
certificates: [],
},
apple_settings: {
disk_encryption: null,
action_required: null,
},
setup_experience: {
bootstrap_package_status: "",
details: "",
bootstrap_package_name: "",
},
device_status: "unlocked",
pending_action: "",
};
export const createMockHostMdmData = (
overrides?: Partial<IHostMdmData>
): IHostMdmData => {
return { ...DEFAULT_HOST_MDM_DATA, ...overrides };
};