fleet/frontend/__mocks__
jacobshandling 166e5ed663
UI: Batch script run detail page (#32333)
## For #31226 

New features:
- Dynamic header for each possible state of a batch script run: Started,
Scheduled, and Finished (corresponds to tabs at
`/controls/scripts/progress`
- Unique tabs for each possible status of hosts targeted by a batch
script run: Ran, Errored, Pending, Incompatible, Canceled.
- Within each tab, sortable, paginated host results with output preview
and execution time.
- View script/run details, cancel a batch, view manage hosts page
filtered for the script batch run and a status.
- Global script batch runs activities and and Scripts progress rows now
navigate to this details page.

Cleanups and improvements:
- Expand tab count badge options using “alert”/“pending” variants across
hosts, policies, and query results.
- Misc cleanups and improvements


![ezgif-1438d4041f694f](https://github.com/user-attachments/assets/2d93127b-dea4-4ca6-abcc-7c888b2e0b93)


- [x] Changes file added for user-visible changes in `changes/`,


- [x] Updated automated tests - new tests tracked for follow-up work
- [x] QA'd all new/changed functionality manually

---------

Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
2025-08-29 09:37:05 -06:00
..
activityMock.ts API only users show a different avatar in the activity feed (#30512) 2025-07-07 10:45:51 -04:00
appleMdm.ts UI – Add VPP features for iPadOS and iOS (#20755) 2024-07-30 10:14:25 -07:00
axiosError.ts Feat UI update macos windows setup (#12744) 2023-07-17 15:51:40 +01:00
certificatesMock.ts update host details cert card (#29827) 2025-06-13 13:00:41 +01:00
configMock.ts Add "Require BitLocker PIN" checkbox to disk encryption page (#31132) 2025-07-23 14:36:28 -05:00
deviceUserMock.ts Update VPP UI to incorporate last_install API changes (#20704) 2024-07-24 14:32:59 -05:00
fileMock.js add prettier and have it format all fleet application code (#625) 2021-04-12 14:32:25 +01:00
hostMock.ts Fleet UI: Add update details modal (#31250) 2025-07-25 09:28:25 -04:00
idpMock.ts add new idp section on integrations page and show the users idp connection with fleet (#27566) 2025-03-28 11:23:07 +00:00
labelsMock.ts UI: Labels by IdP (#30368) 2025-06-30 10:05:03 -07:00
licenseMock.ts integration test device user page with mock and custom renderer (#8475) 2022-11-01 18:59:40 +00:00
macAdminsMock.ts UI for bootstrap package flows (#11288) 2023-04-27 16:10:41 +01:00
mdmMock.ts UI tests for setup experience (#22861) 2024-10-14 13:01:56 +01:00
operatingSystemsMock.ts Fleet UI: Add Linux kernel vulns card/table (#31840) 2025-08-14 09:30:49 -04:00
osqueryTableMock.ts Fleet Frontend: Create integration tests QuerySidePanel.tests.tsx (#12179) 2023-06-07 12:01:59 -04:00
policyMock.ts UI: Update conditional access on a per-policy basis (#28658) 2025-05-01 11:43:38 -07:00
queryMock.ts Fleet UI: Can run a live query on an edited (but not saved) existing query (#16282) 2024-01-25 13:12:59 -05:00
queryReportMock.ts Added server_settings.query_report_cap (#19692) 2024-06-14 12:24:01 -03:00
README.md Organize contributor docs and establish ADR process and template (#29101) 2025-05-17 15:03:52 -05:00
scheduleableQueryMock.ts Fleet UI: Can run a live query on an edited (but not saved) existing query (#16282) 2024-01-25 13:12:59 -05:00
scriptMock.ts UI: Batch script run detail page (#32333) 2025-08-29 09:37:05 -06:00
setupExperienceMock.ts disabled manual agent install checkbox when setup experience software and run script is already added (#28679) 2025-04-30 16:22:24 +01:00
softwareMock.ts Fleet UI: Add self-service opening instructions to apps and programs (#32169) 2025-08-26 11:02:30 -04:00
teamMock.ts refactor activity items and add query name to live_query activity type (#8740) 2022-11-17 14:25:40 +00:00
userMock.ts Fleet UI: Add update details modal (#31250) 2025-07-25 09:28:25 -04:00
vulnerabilitiesMock.ts Fleet UI: Add Linux kernel vulns card/table (#31840) 2025-08-14 09:30:49 -04:00

Frontend mocks

Each __mocks___/*Mock.ts file contains one or more default mock objects and their corresponding helper function to partially override the default mock creating custom mocks.

Table of contents

Default mocks

Default mocks are simple to work with objects. We limit the default mock to a single object that can be modified with the helper function as needed using overrides.

The default mock object is returned by calling the helper function with no arguments.

Example

A single default activity is defined in __mocks__/activityMock.ts as:

const DEFAULT_ACTIVITY_MOCK: IActivity = {
  created_at: "2022-11-03T17:22:14Z",
  id: 1,
  actor_full_name: "Test",
  actor_id: 1,
  actor_gravatar: "",
  actor_email: "test@example.com",
  type: ActivityType.EditedAgentOptions,
};

To return this default object, call its helper function createActivityMock() with no arguments.

Custom mocks

Custom mocks are useful when we need a mock object with specific data.

Use the helper function with arguments to override the default mock data with the specific data you need.

Example

createMockActivity({ id: 2, actor_full_name: "Gabe" }) will return modifications to the DEFAULT_ACTIVITY_MOCK to override the id and actor_full_name keys only.

Check out the frontend test directory for information about our unit and integration testing layers. We use default mocks and custom mocks when mocking server requests.

Follow this guide to run tests locally.

Visit the frontend overview of Fleet UI testing for more information on our testing strategy, philosophies, and tools.