mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 09:28:54 +00:00
<!-- Add the related story/sub-task/bug number, like Resolves #123, or remove if NA --> **Related issue:** Resolves #37847 # Checklist for submitter Issue is resolved by the `&& isSupportedHostQueriesPlatform` condition. ## Testing - [x] Added/updated automated tests - [ ] 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) - [x] QA'd all new/changed functionality manually Manually tested by passing a mocked host platform (`"ios"`) and verified the **Add Query** button is not shown. ### Before <img width="719" height="399" alt="Screenshot 2026-01-06 at 1 55 33 PM" src="https://github.com/user-attachments/assets/12cf1bc7-62bb-4e8b-a005-b38debd5f564" /> ### After <img width="711" height="389" alt="Screenshot 2026-01-06 at 1 52 03 PM" src="https://github.com/user-attachments/assets/c077b030-451e-4333-b4e9-bcd8d9734c96" />
67 lines
1.6 KiB
TypeScript
67 lines
1.6 KiB
TypeScript
import { ISchedulableQuery } from "interfaces/schedulable_query";
|
|
import { IQueryStats } from "interfaces/query_stats";
|
|
|
|
const DEFAULT_QUERY_MOCK: ISchedulableQuery = {
|
|
created_at: "2022-11-03T17:22:14Z",
|
|
updated_at: "2022-11-03T17:22:14Z",
|
|
id: 1,
|
|
name: "Test Query",
|
|
description: "A test query",
|
|
query: "SELECT * FROM users",
|
|
saved: true,
|
|
author_id: 1,
|
|
author_name: "Test User",
|
|
author_email: "test@example.com",
|
|
observer_can_run: false,
|
|
discard_data: false,
|
|
interval: 300,
|
|
packs: [],
|
|
team_id: null,
|
|
platform: "",
|
|
min_osquery_version: "",
|
|
automations_enabled: false,
|
|
logging: "snapshot",
|
|
stats: {
|
|
user_time_p50: 0,
|
|
user_time_p95: 2,
|
|
system_time_p50: 0,
|
|
system_time_p95: 1,
|
|
total_executions: 6,
|
|
},
|
|
editingExistingQuery: false,
|
|
};
|
|
|
|
const createMockQuery = (
|
|
overrides?: Partial<ISchedulableQuery>
|
|
): ISchedulableQuery => {
|
|
return { ...DEFAULT_QUERY_MOCK, ...overrides };
|
|
};
|
|
|
|
const DEFAULT_QUERY_STATS_MOCK: IQueryStats = {
|
|
scheduled_query_name: "test-query",
|
|
scheduled_query_id: 1,
|
|
query_name: "Test Query",
|
|
discard_data: false,
|
|
last_fetched: "2025-01-01T00:00:00Z",
|
|
automations_enabled: false,
|
|
description: "A test query",
|
|
pack_name: "test-pack",
|
|
pack_id: 1,
|
|
average_memory: 100,
|
|
denylisted: false,
|
|
executions: 10,
|
|
interval: 3600,
|
|
last_executed: "2025-01-01T00:00:00Z",
|
|
output_size: 1024,
|
|
system_time: 50,
|
|
user_time: 100,
|
|
wall_time: 150,
|
|
};
|
|
|
|
export const createMockQueryStats = (
|
|
overrides?: Partial<IQueryStats>
|
|
): IQueryStats => {
|
|
return { ...DEFAULT_QUERY_STATS_MOCK, ...overrides };
|
|
};
|
|
|
|
export default createMockQuery;
|