mirror of
https://github.com/fleetdm/fleet
synced 2026-05-06 06:48:54 +00:00
## PR 2/2 for #32037 - Implements update for the Linux setup experience from the end-user's point of view (the "My device" page). - Works in concert with the new endpoints implemented in https://github.com/fleetdm/fleet/pull/32493 - My device page calls a new endpoint to get in-progress setup experience software installations. If there are any, the page is replaced with a "Setting up your device" page - The UI polls this endpoint until all such installations are either successful or failed (including canceled) - Setting up your device page includes a table displaying the name and status of each software installation - Once all installations are finished (succeed/fail), renders the regular My device page - Add a handler for the new API call for relevant tests  ## Testing Can use [this branch with fake data](https://github.com/fleetdm/fleet/tree/32037-end-user-fake-data) to help test this PR - [x] Changes file added for user-visible changes in `changes/` - [x] Added/updated automated tests - additional tests coming in follow-up - [x] QA'd all new/changed functionality manually --------- Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
88 lines
2.4 KiB
TypeScript
88 lines
2.4 KiB
TypeScript
import { IDeviceUser } from "interfaces/host";
|
|
import { IDeviceSoftware, ISetupSoftwareStatus } from "interfaces/software";
|
|
import {
|
|
IGetDeviceSoftwareResponse,
|
|
IGetSetupSoftwareStatusesResponse,
|
|
} from "services/entities/device_user";
|
|
import { createMockHostSoftwarePackage } from "./hostMock";
|
|
|
|
const DEFAULT_DEVICE_USER_MOCK: IDeviceUser = {
|
|
email: "test@test.com",
|
|
source: "test_source",
|
|
};
|
|
|
|
const createMockDeviceUser = (
|
|
overrides?: Partial<IDeviceUser>
|
|
): IDeviceUser => {
|
|
return { ...DEFAULT_DEVICE_USER_MOCK, ...overrides };
|
|
};
|
|
|
|
const DEFAULT_DEVICE_SOFTWARE_MOCK: IDeviceSoftware = {
|
|
id: 1,
|
|
name: "mock software 1.app",
|
|
icon_url: null,
|
|
source: "apps",
|
|
bundle_identifier: "com.app.mock",
|
|
status: null,
|
|
installed_versions: null,
|
|
software_package: createMockHostSoftwarePackage(),
|
|
app_store_app: null,
|
|
};
|
|
|
|
export const createMockDeviceSoftware = (
|
|
overrides?: Partial<IDeviceSoftware>
|
|
) => {
|
|
return { ...DEFAULT_DEVICE_SOFTWARE_MOCK, ...overrides };
|
|
};
|
|
|
|
const DEFAULT_DEVICE_SOFTWARE_RESPONSE_MOCK = {
|
|
software: [createMockDeviceSoftware()],
|
|
count: 0,
|
|
meta: {
|
|
has_next_results: false,
|
|
has_previous_results: false,
|
|
},
|
|
};
|
|
|
|
export const createMockDeviceSoftwareResponse = (
|
|
overrides?: Partial<IGetDeviceSoftwareResponse>
|
|
) => {
|
|
return {
|
|
...DEFAULT_DEVICE_SOFTWARE_RESPONSE_MOCK,
|
|
...overrides,
|
|
};
|
|
};
|
|
|
|
const DEFAULT_SETUP_SOFTWARE_STATUS_MOCK: ISetupSoftwareStatus = {
|
|
name: "Slack",
|
|
status: "pending",
|
|
};
|
|
|
|
export const createMockSetupSoftwareStatus = (
|
|
overrides?: Partial<ISetupSoftwareStatus>
|
|
): ISetupSoftwareStatus => {
|
|
return { ...DEFAULT_SETUP_SOFTWARE_STATUS_MOCK, ...overrides };
|
|
};
|
|
|
|
const DEFAULT_SETUP_SOFTWARE_STATUSES_RESPONSE_MOCK: IGetSetupSoftwareStatusesResponse = {
|
|
setup_experience_results: {
|
|
software: [
|
|
createMockSetupSoftwareStatus({ name: "1Password", status: "pending" }),
|
|
createMockSetupSoftwareStatus({ name: "Chrome", status: "failure" }),
|
|
createMockSetupSoftwareStatus({ name: "Firefox", status: "cancelled" }),
|
|
createMockSetupSoftwareStatus({ name: "Slack", status: "success" }),
|
|
createMockSetupSoftwareStatus({ name: "Zoom", status: "running" }),
|
|
],
|
|
},
|
|
};
|
|
|
|
export const createMockSetupSoftwareStatusesResponse = (
|
|
overrides?: Partial<IGetSetupSoftwareStatusesResponse>
|
|
): IGetSetupSoftwareStatusesResponse => {
|
|
return {
|
|
...DEFAULT_SETUP_SOFTWARE_STATUSES_RESPONSE_MOCK,
|
|
...overrides,
|
|
};
|
|
};
|
|
|
|
export default createMockDeviceUser;
|