fleet/frontend/__mocks__/labelsMock.ts
Ian Littman 8e4e89f4e9
API + auth + UI changes for team labels (#37208)
Covers #36760, #36758.

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

- [x] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)

## Testing

- [x] Added/updated automated tests
- [x] Where appropriate, [automated tests simulate multiple hosts and
test for host
isolation](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/reference/patterns-backend.md#unit-testing)
(updates to one hosts's records do not affect another)

- [ ] QA'd all new/changed functionality manually
2025-12-29 21:28:45 -06:00

36 lines
958 B
TypeScript

import { ILabel } from "interfaces/label";
import { IGetLabelResponse } from "services/entities/labels";
const DEFAULT_LABEL_MOCK: ILabel = {
created_at: "2024-04-12T13:32:00Z",
updated_at: "2024-04-12T14:27:07Z",
id: 1,
name: "test label",
description: "test label description",
query: "SELECT 1;",
platform: "darwin",
label_type: "regular",
label_membership_type: "dynamic",
display_text: "test macsss",
count: 0,
host_ids: null,
team_id: null,
criteria: {
vital: "end_user_idp_department",
value: " IT admins",
},
};
export const createMockLabel = (overrides?: Partial<ILabel>): ILabel => {
return { ...DEFAULT_LABEL_MOCK, ...overrides };
};
const DEFAULT_GET_LABEL_RESPONSE_MOCK: IGetLabelResponse = {
label: createMockLabel(),
};
export const createMockGetLabelResponse = (
overrides?: Partial<IGetLabelResponse>
): IGetLabelResponse => {
return { ...DEFAULT_GET_LABEL_RESPONSE_MOCK, ...overrides };
};