From cbd7f12d1e6e1874204440b60d9b7ec3839b7cd7 Mon Sep 17 00:00:00 2001 From: Jayanthi Date: Fri, 10 Jan 2025 09:09:11 -0800 Subject: [PATCH 01/30] Testing --- src/Frontend/test/mocks/browser.ts | 37 ++-- .../preconditions/hasNoFailingCustomChecks.ts | 176 +++++++++++++++++- 2 files changed, 193 insertions(+), 20 deletions(-) diff --git a/src/Frontend/test/mocks/browser.ts b/src/Frontend/test/mocks/browser.ts index 2481bbc71..7b0cb802a 100644 --- a/src/Frontend/test/mocks/browser.ts +++ b/src/Frontend/test/mocks/browser.ts @@ -25,23 +25,22 @@ const driver = makeDriver(); (async () => { await driver.setUp(precondition.serviceControlWithMonitoring); //override the default mocked endpoints with a custom list - await driver.setUp( - precondition.monitoredEndpointsNamed([ - "Universe.Solarsystem.Mercury.Endpoint1", - "Universe.Solarsystem.Mercury.Endpoint2", - "Universe.Solarsystem.Venus.Endpoint3", - "Universe.Solarsystem.Venus.Endpoint4", - "Universe.Solarsystem.Earth.Endpoint5", - "Universe.Solarsystem.Earth.Endpoint6", - ]) - ); - - await driver.setUp( - precondition.hasFailedMessage({ - withGroupId: "81dca64e-76fc-e1c3-11a2-3069f51c58c8", - withMessageId: "40134401-bab9-41aa-9acb-b19c0066f22d", - withContentType: "application/json", - withBody: { Index: 0, Data: "" }, - }) - ); + // await driver.setUp( + // precondition.monitoredEndpointsNamed([ + // "Universe.Solarsystem.Mercury.Endpoint1", + // "Universe.Solarsystem.Mercury.Endpoint2", + // "Universe.Solarsystem.Venus.Endpoint3", + // "Universe.Solarsystem.Venus.Endpoint4", + // "Universe.Solarsystem.Earth.Endpoint5", + // "Universe.Solarsystem.Earth.Endpoint6", + // ]) + // ); + // await driver.setUp( + // precondition.hasFailedMessage({ + // withGroupId: "81dca64e-76fc-e1c3-11a2-3069f51c58c8", + // withMessageId: "40134401-bab9-41aa-9acb-b19c0066f22d", + // withContentType: "application/json", + // withBody: { Index: 0, Data: "" }, + // }) + // ); })(); diff --git a/src/Frontend/test/preconditions/hasNoFailingCustomChecks.ts b/src/Frontend/test/preconditions/hasNoFailingCustomChecks.ts index 947c3620b..180bd39cb 100644 --- a/src/Frontend/test/preconditions/hasNoFailingCustomChecks.ts +++ b/src/Frontend/test/preconditions/hasNoFailingCustomChecks.ts @@ -1,3 +1,4 @@ +import CustomCheck from "@/resources/CustomCheck"; import { SetupFactoryOptions } from "../driver"; const content = JSON.stringify([]); @@ -5,7 +6,180 @@ const content = JSON.stringify([]); export const hasNoFailingCustomChecks = ({ driver }: SetupFactoryOptions) => { const serviceControlInstanceUrl = window.defaultConfig.service_control_url; driver.mockEndpoint(`${serviceControlInstanceUrl}customchecks`, { - body: content, + body: [ + { + id: "CustomChecks/6131fa95-9414-1898-9c83-c5b18587945b", + custom_check_id: "Audit Message Ingestion", + category: "ServiceControl.Audit Health", + status: "Fail", + failure_reason: "I dont know the reason", + reported_at: "2025-01-10T05:06:30.4074087Z", + originating_endpoint: { + name: "Particular.ServiceControl.Audit", + host_id: "ff605b55-6fbb-af56-5753-73c1ff73e601", + host: "JAYANTHI-LAPTOP", + }, + }, + ], }); + return content; }; +// [ +// { +// "id": "CustomChecks/6131fa95-9414-1898-9c83-c5b18587945b", +// "custom_check_id": "Audit Message Ingestion", +// "category": "ServiceControl.Audit Health", +// "status": "pass", +// "reported_at": "2025-01-10T05:06:30.4074087Z", +// "originating_endpoint": { +// "name": "Particular.ServiceControl.Audit", +// "host_id": "ff605b55-6fbb-af56-5753-73c1ff73e601", +// "host": "JAYANTHI-LAPTOP" +// } +// }, +// { +// "id": "CustomChecks/36752f09-8a72-752e-e48f-6c378329d43b", +// "custom_check_id": "Error Message Ingestion", +// "category": "ServiceControl Health", +// "status": "pass", +// "reported_at": "2025-01-10T05:42:00.531067Z", +// "originating_endpoint": { +// "name": "Particular.ServiceControl", +// "host_id": "9f822d11-b097-a4df-3db5-e069e5d356fe", +// "host": "JAYANTHI-LAPTOP" +// } +// }, +// { +// "id": "CustomChecks/02564a68-8c3e-92f6-d977-ce45d7ce46ed", +// "custom_check_id": "ServiceControl.Audit database", +// "category": "Storage space", +// "status": "pass", +// "reported_at": "2025-01-10T05:51:44.4635095Z", +// "originating_endpoint": { +// "name": "Particular.ServiceControl.Audit", +// "host_id": "ff605b55-6fbb-af56-5753-73c1ff73e601", +// "host": "JAYANTHI-LAPTOP" +// } +// }, +// { +// "id": "CustomChecks/5443ee67-c22a-521f-5dc1-b979f831151a", +// "custom_check_id": "Audit Database Index Lag", +// "category": "ServiceControl.Audit Health", +// "status": "pass", +// "reported_at": "2025-01-10T05:51:47.7264687Z", +// "originating_endpoint": { +// "name": "Particular.ServiceControl.Audit", +// "host_id": "ff605b55-6fbb-af56-5753-73c1ff73e601", +// "host": "JAYANTHI-LAPTOP" +// } +// }, +// { +// "id": "CustomChecks/93b62dc3-e1bf-abfd-4268-8d36fef2b0c6", +// "custom_check_id": "ServiceControl database", +// "category": "Storage space", +// "status": "pass", +// "reported_at": "2025-01-10T05:52:03.8512021Z", +// "originating_endpoint": { +// "name": "Particular.ServiceControl", +// "host_id": "9f822d11-b097-a4df-3db5-e069e5d356fe", +// "host": "JAYANTHI-LAPTOP" +// } +// }, +// { +// "id": "CustomChecks/7e09172e-7c59-9a0c-52da-e2ecc1784e15", +// "custom_check_id": "Saga Audit Configuration", +// "category": "Configuration", +// "status": "pass", +// "reported_at": "2025-01-10T05:52:03.850927Z", +// "originating_endpoint": { +// "name": "Particular.ServiceControl", +// "host_id": "9f822d11-b097-a4df-3db5-e069e5d356fe", +// "host": "JAYANTHI-LAPTOP" +// } +// }, +// { +// "id": "CustomChecks/7940dbbf-3019-cb8a-3add-b9ff9c57edb7", +// "custom_check_id": "Error Database Index Errors", +// "category": "ServiceControl Health", +// "status": "pass", +// "reported_at": "2025-01-10T05:52:03.8522051Z", +// "originating_endpoint": { +// "name": "Particular.ServiceControl", +// "host_id": "9f822d11-b097-a4df-3db5-e069e5d356fe", +// "host": "JAYANTHI-LAPTOP" +// } +// }, +// { +// "id": "CustomChecks/4dc66bce-632b-5404-bc3d-e1943d99c301", +// "custom_check_id": "Error Database Index Lag", +// "category": "ServiceControl Health", +// "status": "pass", +// "reported_at": "2025-01-10T05:52:05.8153025Z", +// "originating_endpoint": { +// "name": "Particular.ServiceControl", +// "host_id": "9f822d11-b097-a4df-3db5-e069e5d356fe", +// "host": "JAYANTHI-LAPTOP" +// } +// }, +// { +// "id": "CustomChecks/3eab20ba-3c24-b354-d298-aae5412c0125", +// "custom_check_id": "ServiceControl Remotes", +// "category": "Health", +// "status": "pass", +// "reported_at": "2025-01-10T05:52:10.1360722Z", +// "originating_endpoint": { +// "name": "Particular.ServiceControl", +// "host_id": "9f822d11-b097-a4df-3db5-e069e5d356fe", +// "host": "JAYANTHI-LAPTOP" +// } +// }, +// { +// "id": "CustomChecks/c7011287-308f-c7b7-f50a-cca3c3fe17da", +// "custom_check_id": "ServiceControl Primary Instance", +// "category": "Health", +// "status": "pass", +// "reported_at": "2025-01-10T05:52:18.4970695Z", +// "originating_endpoint": { +// "name": "Particular.ServiceControl", +// "host_id": "9f822d11-b097-a4df-3db5-e069e5d356fe", +// "host": "JAYANTHI-LAPTOP" +// } +// }, +// { +// "id": "CustomChecks/66675ab0-b69a-6a5a-6a56-da7709464fba", +// "custom_check_id": "Message Ingestion Process", +// "category": "ServiceControl Health", +// "status": "pass", +// "reported_at": "2025-01-10T05:52:29.398929Z", +// "originating_endpoint": { +// "name": "Particular.ServiceControl", +// "host_id": "9f822d11-b097-a4df-3db5-e069e5d356fe", +// "host": "JAYANTHI-LAPTOP" +// } +// }, +// { +// "id": "CustomChecks/418dafe7-1dd2-886b-65d1-2b3e71e4feb2", +// "custom_check_id": "Error Message Ingestion Process", +// "category": "ServiceControl Health", +// "status": "pass", +// "reported_at": "2025-01-10T05:52:29.3984912Z", +// "originating_endpoint": { +// "name": "Particular.ServiceControl", +// "host_id": "9f822d11-b097-a4df-3db5-e069e5d356fe", +// "host": "JAYANTHI-LAPTOP" +// } +// }, +// { +// "id": "CustomChecks/a406f1a7-412c-dd2c-7f90-9aa32da0698b", +// "custom_check_id": "Audit Message Ingestion Process", +// "category": "ServiceControl Health", +// "status": "pass", +// "reported_at": "2025-01-10T05:52:31.4929675Z", +// "originating_endpoint": { +// "name": "Particular.ServiceControl.Audit", +// "host_id": "ff605b55-6fbb-af56-5753-73c1ff73e601", +// "host": "JAYANTHI-LAPTOP" +// } +// } +// ] From 778cbf24a5328382683be145d13dd700c8fe7bf5 Mon Sep 17 00:00:00 2001 From: Jayanthi Date: Fri, 10 Jan 2025 16:29:50 -0800 Subject: [PATCH 02/30] raw testing of mock data Frontend custom checks --- src/Frontend/test/mocks/browser.ts | 21 ++++++++++--------- .../preconditions/hasNoFailingCustomChecks.ts | 7 +++++-- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/Frontend/test/mocks/browser.ts b/src/Frontend/test/mocks/browser.ts index 7b0cb802a..14df40ed8 100644 --- a/src/Frontend/test/mocks/browser.ts +++ b/src/Frontend/test/mocks/browser.ts @@ -25,16 +25,17 @@ const driver = makeDriver(); (async () => { await driver.setUp(precondition.serviceControlWithMonitoring); //override the default mocked endpoints with a custom list - // await driver.setUp( - // precondition.monitoredEndpointsNamed([ - // "Universe.Solarsystem.Mercury.Endpoint1", - // "Universe.Solarsystem.Mercury.Endpoint2", - // "Universe.Solarsystem.Venus.Endpoint3", - // "Universe.Solarsystem.Venus.Endpoint4", - // "Universe.Solarsystem.Earth.Endpoint5", - // "Universe.Solarsystem.Earth.Endpoint6", - // ]) - // ); + await driver.setUp(precondition.hasNoFailingCustomChecks); + // await driver.setUp( + // precondition.monitoredEndpointsNamed([ + // "Universe.Solarsystem.Mercury.Endpoint1", + // "Universe.Solarsystem.Mercury.Endpoint2", + // "Universe.Solarsystem.Venus.Endpoint3", + // "Universe.Solarsystem.Venus.Endpoint4", + // "Universe.Solarsystem.Earth.Endpoint5", + // "Universe.Solarsystem.Earth.Endpoint6", + // ]) + // ); // await driver.setUp( // precondition.hasFailedMessage({ // withGroupId: "81dca64e-76fc-e1c3-11a2-3069f51c58c8", diff --git a/src/Frontend/test/preconditions/hasNoFailingCustomChecks.ts b/src/Frontend/test/preconditions/hasNoFailingCustomChecks.ts index 180bd39cb..db14ad671 100644 --- a/src/Frontend/test/preconditions/hasNoFailingCustomChecks.ts +++ b/src/Frontend/test/preconditions/hasNoFailingCustomChecks.ts @@ -1,7 +1,7 @@ import CustomCheck from "@/resources/CustomCheck"; import { SetupFactoryOptions } from "../driver"; -const content = JSON.stringify([]); +//const content = JSON.stringify([]); export const hasNoFailingCustomChecks = ({ driver }: SetupFactoryOptions) => { const serviceControlInstanceUrl = window.defaultConfig.service_control_url; @@ -21,9 +21,12 @@ export const hasNoFailingCustomChecks = ({ driver }: SetupFactoryOptions) => { }, }, ], + headers: { + "Total-Count": "1", + }, }); - return content; + //return content; }; // [ // { From 07ade8506b789260592ad64b8e78d9cb085efe33 Mon Sep 17 00:00:00 2001 From: Christian Date: Fri, 10 Jan 2025 22:51:03 -0600 Subject: [PATCH 03/30] dynamic precondition function hasCustomChecks --- .../serviceControlWithHeartbeats.ts | 2 +- .../serviceControlWithThroughput.ts | 2 +- src/Frontend/test/mocks/browser.ts | 8 +- .../test/preconditions/customChecks.ts | 57 ++++++ .../preconditions/hasNoFailingCustomChecks.ts | 188 ------------------ src/Frontend/test/preconditions/index.ts | 2 +- .../serviceControlWithMonitoring.ts | 2 +- 7 files changed, 68 insertions(+), 193 deletions(-) create mode 100644 src/Frontend/test/preconditions/customChecks.ts delete mode 100644 src/Frontend/test/preconditions/hasNoFailingCustomChecks.ts diff --git a/src/Frontend/src/components/heartbeats/serviceControlWithHeartbeats.ts b/src/Frontend/src/components/heartbeats/serviceControlWithHeartbeats.ts index c674aba34..a30f5f7b5 100644 --- a/src/Frontend/src/components/heartbeats/serviceControlWithHeartbeats.ts +++ b/src/Frontend/src/components/heartbeats/serviceControlWithHeartbeats.ts @@ -6,7 +6,7 @@ export const serviceControlWithHeartbeats = async ({ driver }: SetupFactoryOptio await driver.setUp(precondition.hasUpToDateServicePulse); await driver.setUp(precondition.hasUpToDateServiceControl); await driver.setUp(precondition.errorsDefaultHandler); - await driver.setUp(precondition.hasNoFailingCustomChecks); + await driver.setUp(precondition.hasZeroCustomChecks); await driver.setUp(precondition.hasEventLogItems); await driver.setUp(precondition.hasServiceControlMainInstance(minimumSCVersionForEndpointSettings)); await driver.setUp(precondition.hasNoDisconnectedEndpoints); diff --git a/src/Frontend/src/views/throughputreport/serviceControlWithThroughput.ts b/src/Frontend/src/views/throughputreport/serviceControlWithThroughput.ts index b22ea3064..13768b9f8 100644 --- a/src/Frontend/src/views/throughputreport/serviceControlWithThroughput.ts +++ b/src/Frontend/src/views/throughputreport/serviceControlWithThroughput.ts @@ -6,7 +6,7 @@ export const serviceControlWithThroughput = async ({ driver }: SetupFactoryOptio await driver.setUp(precondition.hasUpToDateServicePulse); await driver.setUp(precondition.hasUpToDateServiceControl); await driver.setUp(precondition.errorsDefaultHandler); - await driver.setUp(precondition.hasNoFailingCustomChecks); + await driver.setUp(precondition.hasZeroCustomChecks); await driver.setUp(precondition.hasEventLogItems); await driver.setUp(precondition.hasNoHeartbeatsEndpoints); await driver.setUp(precondition.hasServiceControlMainInstance(minimumSCVersionForThroughput)); diff --git a/src/Frontend/test/mocks/browser.ts b/src/Frontend/test/mocks/browser.ts index 14df40ed8..47a93bb18 100644 --- a/src/Frontend/test/mocks/browser.ts +++ b/src/Frontend/test/mocks/browser.ts @@ -25,7 +25,13 @@ const driver = makeDriver(); (async () => { await driver.setUp(precondition.serviceControlWithMonitoring); //override the default mocked endpoints with a custom list - await driver.setUp(precondition.hasNoFailingCustomChecks); + await driver.setUp( + precondition.hasCustomChecks([ + { failed: true, reason: "Test reason 1" }, + { failed: true, reason: "Test reason 2" }, + ]) + ); + // await driver.setUp( // precondition.monitoredEndpointsNamed([ // "Universe.Solarsystem.Mercury.Endpoint1", diff --git a/src/Frontend/test/preconditions/customChecks.ts b/src/Frontend/test/preconditions/customChecks.ts new file mode 100644 index 000000000..a88039ef2 --- /dev/null +++ b/src/Frontend/test/preconditions/customChecks.ts @@ -0,0 +1,57 @@ +import CustomCheck from "@/resources/CustomCheck"; +import { SetupFactoryOptions } from "../driver"; + +export const hasZeroCustomChecks = ({ driver }: SetupFactoryOptions) => { + const serviceControlInstanceUrl = window.defaultConfig.service_control_url; + driver.mockEndpoint(`${serviceControlInstanceUrl}customchecks`, { + body: [], + headers: { + "Total-Count": "0", + }, + }); +}; + +const customCheckTemplate = { + id: "CustomChecks/6131fa95-9414-1898-9c83-c5b18587945b", + custom_check_id: "Audit Message Ingestion", + category: "ServiceControl.Audit Health", + status: "Pass", + failure_reason: "I dont know the reason", + reported_at: "2025-01-10T05:06:30.4074087Z", + originating_endpoint: { + name: "Particular.ServiceControl.Audit", + host_id: "ff605b55-6fbb-af56-5753-73c1ff73e601", + host: "ABC", + }, +}; + +export const hasCustomChecks = + (params: { failed: boolean; reason: string }[]) => + ({ driver }: SetupFactoryOptions) => { + const serviceControlInstanceUrl = window.defaultConfig.service_control_url; + + const customChecks = params.map((check) => { + return { + ...customCheckTemplate, + status: check.failed ? "Fail" : "Pass", + failure_reason: check.reason.toString(), + }; + }); + + const failedCustomChecks = customChecks.filter((check) => check.status === "Fail"); + + driver.mockEndpointDynamic(`${serviceControlInstanceUrl}customchecks`, (url) => { + const status = url.searchParams.get("status"); + if (status === "fail") { + return { + body: failedCustomChecks, + headers: { "Total-Count": failedCustomChecks.length.toString() }, + }; + } + + return { + body: customChecks, + headers: { "Total-Count": customChecks.length.toString() }, + }; + }); + }; diff --git a/src/Frontend/test/preconditions/hasNoFailingCustomChecks.ts b/src/Frontend/test/preconditions/hasNoFailingCustomChecks.ts deleted file mode 100644 index db14ad671..000000000 --- a/src/Frontend/test/preconditions/hasNoFailingCustomChecks.ts +++ /dev/null @@ -1,188 +0,0 @@ -import CustomCheck from "@/resources/CustomCheck"; -import { SetupFactoryOptions } from "../driver"; - -//const content = JSON.stringify([]); - -export const hasNoFailingCustomChecks = ({ driver }: SetupFactoryOptions) => { - const serviceControlInstanceUrl = window.defaultConfig.service_control_url; - driver.mockEndpoint(`${serviceControlInstanceUrl}customchecks`, { - body: [ - { - id: "CustomChecks/6131fa95-9414-1898-9c83-c5b18587945b", - custom_check_id: "Audit Message Ingestion", - category: "ServiceControl.Audit Health", - status: "Fail", - failure_reason: "I dont know the reason", - reported_at: "2025-01-10T05:06:30.4074087Z", - originating_endpoint: { - name: "Particular.ServiceControl.Audit", - host_id: "ff605b55-6fbb-af56-5753-73c1ff73e601", - host: "JAYANTHI-LAPTOP", - }, - }, - ], - headers: { - "Total-Count": "1", - }, - }); - - //return content; -}; -// [ -// { -// "id": "CustomChecks/6131fa95-9414-1898-9c83-c5b18587945b", -// "custom_check_id": "Audit Message Ingestion", -// "category": "ServiceControl.Audit Health", -// "status": "pass", -// "reported_at": "2025-01-10T05:06:30.4074087Z", -// "originating_endpoint": { -// "name": "Particular.ServiceControl.Audit", -// "host_id": "ff605b55-6fbb-af56-5753-73c1ff73e601", -// "host": "JAYANTHI-LAPTOP" -// } -// }, -// { -// "id": "CustomChecks/36752f09-8a72-752e-e48f-6c378329d43b", -// "custom_check_id": "Error Message Ingestion", -// "category": "ServiceControl Health", -// "status": "pass", -// "reported_at": "2025-01-10T05:42:00.531067Z", -// "originating_endpoint": { -// "name": "Particular.ServiceControl", -// "host_id": "9f822d11-b097-a4df-3db5-e069e5d356fe", -// "host": "JAYANTHI-LAPTOP" -// } -// }, -// { -// "id": "CustomChecks/02564a68-8c3e-92f6-d977-ce45d7ce46ed", -// "custom_check_id": "ServiceControl.Audit database", -// "category": "Storage space", -// "status": "pass", -// "reported_at": "2025-01-10T05:51:44.4635095Z", -// "originating_endpoint": { -// "name": "Particular.ServiceControl.Audit", -// "host_id": "ff605b55-6fbb-af56-5753-73c1ff73e601", -// "host": "JAYANTHI-LAPTOP" -// } -// }, -// { -// "id": "CustomChecks/5443ee67-c22a-521f-5dc1-b979f831151a", -// "custom_check_id": "Audit Database Index Lag", -// "category": "ServiceControl.Audit Health", -// "status": "pass", -// "reported_at": "2025-01-10T05:51:47.7264687Z", -// "originating_endpoint": { -// "name": "Particular.ServiceControl.Audit", -// "host_id": "ff605b55-6fbb-af56-5753-73c1ff73e601", -// "host": "JAYANTHI-LAPTOP" -// } -// }, -// { -// "id": "CustomChecks/93b62dc3-e1bf-abfd-4268-8d36fef2b0c6", -// "custom_check_id": "ServiceControl database", -// "category": "Storage space", -// "status": "pass", -// "reported_at": "2025-01-10T05:52:03.8512021Z", -// "originating_endpoint": { -// "name": "Particular.ServiceControl", -// "host_id": "9f822d11-b097-a4df-3db5-e069e5d356fe", -// "host": "JAYANTHI-LAPTOP" -// } -// }, -// { -// "id": "CustomChecks/7e09172e-7c59-9a0c-52da-e2ecc1784e15", -// "custom_check_id": "Saga Audit Configuration", -// "category": "Configuration", -// "status": "pass", -// "reported_at": "2025-01-10T05:52:03.850927Z", -// "originating_endpoint": { -// "name": "Particular.ServiceControl", -// "host_id": "9f822d11-b097-a4df-3db5-e069e5d356fe", -// "host": "JAYANTHI-LAPTOP" -// } -// }, -// { -// "id": "CustomChecks/7940dbbf-3019-cb8a-3add-b9ff9c57edb7", -// "custom_check_id": "Error Database Index Errors", -// "category": "ServiceControl Health", -// "status": "pass", -// "reported_at": "2025-01-10T05:52:03.8522051Z", -// "originating_endpoint": { -// "name": "Particular.ServiceControl", -// "host_id": "9f822d11-b097-a4df-3db5-e069e5d356fe", -// "host": "JAYANTHI-LAPTOP" -// } -// }, -// { -// "id": "CustomChecks/4dc66bce-632b-5404-bc3d-e1943d99c301", -// "custom_check_id": "Error Database Index Lag", -// "category": "ServiceControl Health", -// "status": "pass", -// "reported_at": "2025-01-10T05:52:05.8153025Z", -// "originating_endpoint": { -// "name": "Particular.ServiceControl", -// "host_id": "9f822d11-b097-a4df-3db5-e069e5d356fe", -// "host": "JAYANTHI-LAPTOP" -// } -// }, -// { -// "id": "CustomChecks/3eab20ba-3c24-b354-d298-aae5412c0125", -// "custom_check_id": "ServiceControl Remotes", -// "category": "Health", -// "status": "pass", -// "reported_at": "2025-01-10T05:52:10.1360722Z", -// "originating_endpoint": { -// "name": "Particular.ServiceControl", -// "host_id": "9f822d11-b097-a4df-3db5-e069e5d356fe", -// "host": "JAYANTHI-LAPTOP" -// } -// }, -// { -// "id": "CustomChecks/c7011287-308f-c7b7-f50a-cca3c3fe17da", -// "custom_check_id": "ServiceControl Primary Instance", -// "category": "Health", -// "status": "pass", -// "reported_at": "2025-01-10T05:52:18.4970695Z", -// "originating_endpoint": { -// "name": "Particular.ServiceControl", -// "host_id": "9f822d11-b097-a4df-3db5-e069e5d356fe", -// "host": "JAYANTHI-LAPTOP" -// } -// }, -// { -// "id": "CustomChecks/66675ab0-b69a-6a5a-6a56-da7709464fba", -// "custom_check_id": "Message Ingestion Process", -// "category": "ServiceControl Health", -// "status": "pass", -// "reported_at": "2025-01-10T05:52:29.398929Z", -// "originating_endpoint": { -// "name": "Particular.ServiceControl", -// "host_id": "9f822d11-b097-a4df-3db5-e069e5d356fe", -// "host": "JAYANTHI-LAPTOP" -// } -// }, -// { -// "id": "CustomChecks/418dafe7-1dd2-886b-65d1-2b3e71e4feb2", -// "custom_check_id": "Error Message Ingestion Process", -// "category": "ServiceControl Health", -// "status": "pass", -// "reported_at": "2025-01-10T05:52:29.3984912Z", -// "originating_endpoint": { -// "name": "Particular.ServiceControl", -// "host_id": "9f822d11-b097-a4df-3db5-e069e5d356fe", -// "host": "JAYANTHI-LAPTOP" -// } -// }, -// { -// "id": "CustomChecks/a406f1a7-412c-dd2c-7f90-9aa32da0698b", -// "custom_check_id": "Audit Message Ingestion Process", -// "category": "ServiceControl Health", -// "status": "pass", -// "reported_at": "2025-01-10T05:52:31.4929675Z", -// "originating_endpoint": { -// "name": "Particular.ServiceControl.Audit", -// "host_id": "ff605b55-6fbb-af56-5753-73c1ff73e601", -// "host": "JAYANTHI-LAPTOP" -// } -// } -// ] diff --git a/src/Frontend/test/preconditions/index.ts b/src/Frontend/test/preconditions/index.ts index 0c20e7a9f..2cb0b8b0a 100644 --- a/src/Frontend/test/preconditions/index.ts +++ b/src/Frontend/test/preconditions/index.ts @@ -5,7 +5,7 @@ export { hasServiceControlMonitoringInstanceUrl } from "../preconditions/hasServ export { hasUpToDateServiceControl } from "../preconditions/hasUpToDateServiceControl"; export { hasUpToDateServicePulse } from "../preconditions/hasUpToDateServicePulse"; export { errorsDefaultHandler } from "../preconditions/hasNoErrors"; -export { hasNoFailingCustomChecks } from "../preconditions/hasNoFailingCustomChecks"; +export * from "./customChecks"; export { hasNoDisconnectedEndpoints } from "../preconditions/hasNoDisconnectedEndpoints"; export { hasNoMonitoredEndpoints, hasMonitoredEndpointsList, monitoredEndpointsNamed } from "../preconditions/hasMonitoredEndpoints"; export { hasEventLogItems } from "../preconditions/hasEventLogItems"; diff --git a/src/Frontend/test/preconditions/serviceControlWithMonitoring.ts b/src/Frontend/test/preconditions/serviceControlWithMonitoring.ts index 588c7ea40..b6a697331 100644 --- a/src/Frontend/test/preconditions/serviceControlWithMonitoring.ts +++ b/src/Frontend/test/preconditions/serviceControlWithMonitoring.ts @@ -23,7 +23,7 @@ export const serviceControlWithMonitoring = async ({ driver }: SetupFactoryOptio await driver.setUp(precondition.errorsDefaultHandler); //http://localhost:33333/api/customchecks - await driver.setUp(precondition.hasNoFailingCustomChecks); + await driver.setUp(precondition.hasZeroCustomChecks); //http://localhost:33633/monitored-endpoints/disconnected await driver.setUp(precondition.hasNoDisconnectedEndpoints); From fcfd091789610011a64cecfa0cb2091d2c0290db Mon Sep 17 00:00:00 2001 From: Christian Date: Fri, 10 Jan 2025 23:25:55 -0600 Subject: [PATCH 04/30] No data custom checks tests --- src/Frontend/src/components/NoData.vue | 2 +- src/Frontend/test/mocks/browser.ts | 2 + .../questions/messageShownWithText.ts | 6 +++ .../customchecks/viewing-no-data.spec.ts | 39 ++++++++++++++----- 4 files changed, 39 insertions(+), 10 deletions(-) create mode 100644 src/Frontend/test/specs/customchecks/questions/messageShownWithText.ts diff --git a/src/Frontend/src/components/NoData.vue b/src/Frontend/src/components/NoData.vue index b8929b154..9eb810542 100644 --- a/src/Frontend/src/components/NoData.vue +++ b/src/Frontend/src/components/NoData.vue @@ -11,7 +11,7 @@ const props = defineProps<{
-

{{ props.message }}

+

{{ props.message }}

 

diff --git a/src/Frontend/test/mocks/browser.ts b/src/Frontend/test/mocks/browser.ts index 47a93bb18..43a3f92b2 100644 --- a/src/Frontend/test/mocks/browser.ts +++ b/src/Frontend/test/mocks/browser.ts @@ -32,6 +32,8 @@ const driver = makeDriver(); ]) ); + await driver.setUp(precondition.hasZeroCustomChecks); + // await driver.setUp( // precondition.monitoredEndpointsNamed([ // "Universe.Solarsystem.Mercury.Endpoint1", diff --git a/src/Frontend/test/specs/customchecks/questions/messageShownWithText.ts b/src/Frontend/test/specs/customchecks/questions/messageShownWithText.ts new file mode 100644 index 000000000..cccaf410b --- /dev/null +++ b/src/Frontend/test/specs/customchecks/questions/messageShownWithText.ts @@ -0,0 +1,6 @@ +import { screen } from "@testing-library/vue"; + +export function messageShownWithText(message: string) { + const statusElements = screen.getAllByRole("status"); + return statusElements.find((el) => el.textContent === message) !== null; +} diff --git a/src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts b/src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts index ea3ff2892..553ff0613 100644 --- a/src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts +++ b/src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts @@ -1,21 +1,42 @@ import { test, describe } from "../../drivers/vitest/driver"; - +import * as precondition from "../../preconditions"; +import { messageShownWithText } from "./questions/messageShownWithText"; +import { expect } from "vitest"; describe("FEATURE: No data", () => { describe("RULE: When there is no data to show a message should be displayed ", () => { - test.todo("EXAMPLE: 'No failed custom checks' should be displayed when there are no custom checks"); + test("EXAMPLE: There are no failed or passing custom checks", async ({ driver }) => { + await driver.setUp(precondition.serviceControlWithMonitoring); + // Given there are no custom checks + await driver.setUp(precondition.hasZeroCustomChecks); - /* SCENARIO - Given there are no custom checks - When navigating to the custom checks tab - Then a message is shown "No failed custom checks" - */ + // When navigating to the custom checks tab + await driver.goTo("/custom-checks"); - test.todo("EXAMPLE: 'No failed custom checks' should be displayed when all custom checks are in a success state"); - /* SCENARIO + // Then a message is shown "No failed custom checks" + expect(messageShownWithText("No failed custom checks")).toBe(true); + }); + + test("EXAMPLE: There are custom checks but none of them are failing", async ({ driver }) => { + /* SCENARIO Given there are custom checks And all custom checks are in a success state When navigating to the custom checks tab The a message is shown "No failed custom checks" */ + await driver.setUp(precondition.serviceControlWithMonitoring); + // Given there are custom checks but none of them are failing + await driver.setUp( + precondition.hasCustomChecks([ + { failed: false, reason: "Test reason 1" }, + { failed: false, reason: "Test reason 2" }, + ]) + ); + + // When navigating to the custom checks tab + await driver.goTo("/custom-checks"); + + // Then a message is shown "No failed custom checks" + expect(messageShownWithText("No failed custom checks")).toBe(true); + }); }); }); From 300bfd10506f69a94d1790f6f23e2675d82e0937 Mon Sep 17 00:00:00 2001 From: Christian Date: Fri, 10 Jan 2025 23:39:34 -0600 Subject: [PATCH 05/30] wip Failing custom checks tests --- .../viewing-failing-custom-checks.spec.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Frontend/test/specs/customchecks/viewing-failing-custom-checks.spec.ts b/src/Frontend/test/specs/customchecks/viewing-failing-custom-checks.spec.ts index d1b09282e..376a50b48 100644 --- a/src/Frontend/test/specs/customchecks/viewing-failing-custom-checks.spec.ts +++ b/src/Frontend/test/specs/customchecks/viewing-failing-custom-checks.spec.ts @@ -1,9 +1,18 @@ import { test, describe } from "../../drivers/vitest/driver"; +import * as precondition from "../../preconditions"; describe("FEATURE: Failing custom checks", () => { describe("RULE: Custom checks are displayed", () => { - test.todo("EXAMPLE: All custom checks are in a failed state and should be displayed in a list on the custom checks tab"); - + test("EXAMPLE: All custom checks are in a failed state and should be displayed in a list on the custom checks tab", async ({ driver }) => { + await driver.setUp(precondition.serviceControlWithMonitoring); + // Given there are failing custom checks + await driver.setUp( + precondition.hasCustomChecks([ + { failed: true, reason: "Test reason 1" }, + { failed: true, reason: "Test reason 2" }, + ]) + ); + }); /* SCENARIO Given there are custom checks And all custom checks are in a failed state From 44edfad665d0a43f3b2a8b3802172c2549234e4a Mon Sep 17 00:00:00 2001 From: Christian Date: Fri, 10 Jan 2025 23:45:54 -0600 Subject: [PATCH 06/30] All custom checks are in a failed state TODOs --- .../viewing-failing-custom-checks.spec.ts | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/Frontend/test/specs/customchecks/viewing-failing-custom-checks.spec.ts b/src/Frontend/test/specs/customchecks/viewing-failing-custom-checks.spec.ts index 376a50b48..8e32908c8 100644 --- a/src/Frontend/test/specs/customchecks/viewing-failing-custom-checks.spec.ts +++ b/src/Frontend/test/specs/customchecks/viewing-failing-custom-checks.spec.ts @@ -3,31 +3,32 @@ import * as precondition from "../../preconditions"; describe("FEATURE: Failing custom checks", () => { describe("RULE: Custom checks are displayed", () => { - test("EXAMPLE: All custom checks are in a failed state and should be displayed in a list on the custom checks tab", async ({ driver }) => { + test("EXAMPLE: All custom checks are in a failed state", async ({ driver }) => { await driver.setUp(precondition.serviceControlWithMonitoring); // Given there are failing custom checks + // And all custom checks are in a failed state await driver.setUp( precondition.hasCustomChecks([ { failed: true, reason: "Test reason 1" }, { failed: true, reason: "Test reason 2" }, ]) ); - }); - /* SCENARIO - Given there are custom checks - And all custom checks are in a failed state - When navigating to the custom checks tab - Then a list of custom checks is shown - */ - /* NOTES + // When navigating to the custom checks tab + await driver.goTo("/custom-checks"); + + //TODO: Then a list of custom checks is shown and all FAILED checks should be displayed in a list on the custom checks tab + + //TODO: retrieve the list of custom checks and check the different attributes being rendered. + /* NOTES Failure reason (if given) Name (Check) Category Endpoint Host Last checked - */ + */ + }); }); describe("RULE: Only failed custom checks are displayed", () => { test.todo("EXAMPLE: Only failed custom checks should be displayed in the list on the custom checks tab"); From a337eb2955d37b80fd7dc98f7b45df14bd713f0b Mon Sep 17 00:00:00 2001 From: Christian Date: Fri, 10 Jan 2025 23:53:40 -0600 Subject: [PATCH 07/30] precondition.hasCustomChecks params rename --- src/Frontend/test/mocks/browser.ts | 4 ++-- src/Frontend/test/preconditions/customChecks.ts | 4 ++-- .../specs/customchecks/viewing-failing-custom-checks.spec.ts | 4 ++-- src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Frontend/test/mocks/browser.ts b/src/Frontend/test/mocks/browser.ts index 43a3f92b2..2f1e4b497 100644 --- a/src/Frontend/test/mocks/browser.ts +++ b/src/Frontend/test/mocks/browser.ts @@ -27,8 +27,8 @@ const driver = makeDriver(); //override the default mocked endpoints with a custom list await driver.setUp( precondition.hasCustomChecks([ - { failed: true, reason: "Test reason 1" }, - { failed: true, reason: "Test reason 2" }, + { failing: true, reason: "Test reason 1" }, + { failing: true, reason: "Test reason 2" }, ]) ); diff --git a/src/Frontend/test/preconditions/customChecks.ts b/src/Frontend/test/preconditions/customChecks.ts index a88039ef2..546c3f251 100644 --- a/src/Frontend/test/preconditions/customChecks.ts +++ b/src/Frontend/test/preconditions/customChecks.ts @@ -26,14 +26,14 @@ const customCheckTemplate = { }; export const hasCustomChecks = - (params: { failed: boolean; reason: string }[]) => + (params: { failing: boolean; reason: string }[]) => ({ driver }: SetupFactoryOptions) => { const serviceControlInstanceUrl = window.defaultConfig.service_control_url; const customChecks = params.map((check) => { return { ...customCheckTemplate, - status: check.failed ? "Fail" : "Pass", + status: check.failing ? "Fail" : "Pass", failure_reason: check.reason.toString(), }; }); diff --git a/src/Frontend/test/specs/customchecks/viewing-failing-custom-checks.spec.ts b/src/Frontend/test/specs/customchecks/viewing-failing-custom-checks.spec.ts index 8e32908c8..534988b8d 100644 --- a/src/Frontend/test/specs/customchecks/viewing-failing-custom-checks.spec.ts +++ b/src/Frontend/test/specs/customchecks/viewing-failing-custom-checks.spec.ts @@ -9,8 +9,8 @@ describe("FEATURE: Failing custom checks", () => { // And all custom checks are in a failed state await driver.setUp( precondition.hasCustomChecks([ - { failed: true, reason: "Test reason 1" }, - { failed: true, reason: "Test reason 2" }, + { failing: true, reason: "Test reason 1" }, + { failing: true, reason: "Test reason 2" }, ]) ); diff --git a/src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts b/src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts index 553ff0613..d9971083c 100644 --- a/src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts +++ b/src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts @@ -27,8 +27,8 @@ describe("FEATURE: No data", () => { // Given there are custom checks but none of them are failing await driver.setUp( precondition.hasCustomChecks([ - { failed: false, reason: "Test reason 1" }, - { failed: false, reason: "Test reason 2" }, + { failing: false, reason: "Test reason 1" }, + { failing: false, reason: "Test reason 2" }, ]) ); From dca2eb7e9c6dcb2a41812b43558fd160cc2918d4 Mon Sep 17 00:00:00 2001 From: Christian Date: Sat, 11 Jan 2025 00:01:38 -0600 Subject: [PATCH 08/30] WIP All custom checks are in a failed state asserts --- .../specs/customchecks/viewing-failing-custom-checks.spec.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Frontend/test/specs/customchecks/viewing-failing-custom-checks.spec.ts b/src/Frontend/test/specs/customchecks/viewing-failing-custom-checks.spec.ts index 534988b8d..b5f84417e 100644 --- a/src/Frontend/test/specs/customchecks/viewing-failing-custom-checks.spec.ts +++ b/src/Frontend/test/specs/customchecks/viewing-failing-custom-checks.spec.ts @@ -1,5 +1,8 @@ +import { waitFor } from "@testing-library/vue"; import { test, describe } from "../../drivers/vitest/driver"; import * as precondition from "../../preconditions"; +import { messageShownWithText } from "./questions/messageShownWithText"; +import { expect } from "vitest"; describe("FEATURE: Failing custom checks", () => { describe("RULE: Custom checks are displayed", () => { @@ -17,6 +20,8 @@ describe("FEATURE: Failing custom checks", () => { // When navigating to the custom checks tab await driver.goTo("/custom-checks"); + waitFor(() => expect(messageShownWithText("No failed custom checks")).toBe(false)); + //TODO: Then a list of custom checks is shown and all FAILED checks should be displayed in a list on the custom checks tab //TODO: retrieve the list of custom checks and check the different attributes being rendered. From c78b1e9de49173d8ab7ce03afb657a88b36d926b Mon Sep 17 00:00:00 2001 From: Jayanthi Date: Sat, 11 Jan 2025 23:19:48 -0800 Subject: [PATCH 09/30] Revert "WIP All custom checks are in a failed state asserts" This reverts commit dca2eb7e9c6dcb2a41812b43558fd160cc2918d4. --- .../specs/customchecks/viewing-failing-custom-checks.spec.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/Frontend/test/specs/customchecks/viewing-failing-custom-checks.spec.ts b/src/Frontend/test/specs/customchecks/viewing-failing-custom-checks.spec.ts index b5f84417e..534988b8d 100644 --- a/src/Frontend/test/specs/customchecks/viewing-failing-custom-checks.spec.ts +++ b/src/Frontend/test/specs/customchecks/viewing-failing-custom-checks.spec.ts @@ -1,8 +1,5 @@ -import { waitFor } from "@testing-library/vue"; import { test, describe } from "../../drivers/vitest/driver"; import * as precondition from "../../preconditions"; -import { messageShownWithText } from "./questions/messageShownWithText"; -import { expect } from "vitest"; describe("FEATURE: Failing custom checks", () => { describe("RULE: Custom checks are displayed", () => { @@ -20,8 +17,6 @@ describe("FEATURE: Failing custom checks", () => { // When navigating to the custom checks tab await driver.goTo("/custom-checks"); - waitFor(() => expect(messageShownWithText("No failed custom checks")).toBe(false)); - //TODO: Then a list of custom checks is shown and all FAILED checks should be displayed in a list on the custom checks tab //TODO: retrieve the list of custom checks and check the different attributes being rendered. From 34319439a1dfd1f3db0210aa08e606f22453d9ad Mon Sep 17 00:00:00 2001 From: Jayanthi Date: Sat, 11 Jan 2025 23:19:56 -0800 Subject: [PATCH 10/30] Revert "precondition.hasCustomChecks params rename" This reverts commit a337eb2955d37b80fd7dc98f7b45df14bd713f0b. --- src/Frontend/test/mocks/browser.ts | 4 ++-- src/Frontend/test/preconditions/customChecks.ts | 4 ++-- .../specs/customchecks/viewing-failing-custom-checks.spec.ts | 4 ++-- src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Frontend/test/mocks/browser.ts b/src/Frontend/test/mocks/browser.ts index 2f1e4b497..43a3f92b2 100644 --- a/src/Frontend/test/mocks/browser.ts +++ b/src/Frontend/test/mocks/browser.ts @@ -27,8 +27,8 @@ const driver = makeDriver(); //override the default mocked endpoints with a custom list await driver.setUp( precondition.hasCustomChecks([ - { failing: true, reason: "Test reason 1" }, - { failing: true, reason: "Test reason 2" }, + { failed: true, reason: "Test reason 1" }, + { failed: true, reason: "Test reason 2" }, ]) ); diff --git a/src/Frontend/test/preconditions/customChecks.ts b/src/Frontend/test/preconditions/customChecks.ts index 546c3f251..a88039ef2 100644 --- a/src/Frontend/test/preconditions/customChecks.ts +++ b/src/Frontend/test/preconditions/customChecks.ts @@ -26,14 +26,14 @@ const customCheckTemplate = { }; export const hasCustomChecks = - (params: { failing: boolean; reason: string }[]) => + (params: { failed: boolean; reason: string }[]) => ({ driver }: SetupFactoryOptions) => { const serviceControlInstanceUrl = window.defaultConfig.service_control_url; const customChecks = params.map((check) => { return { ...customCheckTemplate, - status: check.failing ? "Fail" : "Pass", + status: check.failed ? "Fail" : "Pass", failure_reason: check.reason.toString(), }; }); diff --git a/src/Frontend/test/specs/customchecks/viewing-failing-custom-checks.spec.ts b/src/Frontend/test/specs/customchecks/viewing-failing-custom-checks.spec.ts index 534988b8d..8e32908c8 100644 --- a/src/Frontend/test/specs/customchecks/viewing-failing-custom-checks.spec.ts +++ b/src/Frontend/test/specs/customchecks/viewing-failing-custom-checks.spec.ts @@ -9,8 +9,8 @@ describe("FEATURE: Failing custom checks", () => { // And all custom checks are in a failed state await driver.setUp( precondition.hasCustomChecks([ - { failing: true, reason: "Test reason 1" }, - { failing: true, reason: "Test reason 2" }, + { failed: true, reason: "Test reason 1" }, + { failed: true, reason: "Test reason 2" }, ]) ); diff --git a/src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts b/src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts index d9971083c..553ff0613 100644 --- a/src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts +++ b/src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts @@ -27,8 +27,8 @@ describe("FEATURE: No data", () => { // Given there are custom checks but none of them are failing await driver.setUp( precondition.hasCustomChecks([ - { failing: false, reason: "Test reason 1" }, - { failing: false, reason: "Test reason 2" }, + { failed: false, reason: "Test reason 1" }, + { failed: false, reason: "Test reason 2" }, ]) ); From 0b93fd47765f9df88a530f148a5ed5c7e2e719b6 Mon Sep 17 00:00:00 2001 From: Jayanthi Date: Sat, 11 Jan 2025 23:20:01 -0800 Subject: [PATCH 11/30] Revert "All custom checks are in a failed state TODOs" This reverts commit 44edfad665d0a43f3b2a8b3802172c2549234e4a. --- .../viewing-failing-custom-checks.spec.ts | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/Frontend/test/specs/customchecks/viewing-failing-custom-checks.spec.ts b/src/Frontend/test/specs/customchecks/viewing-failing-custom-checks.spec.ts index 8e32908c8..376a50b48 100644 --- a/src/Frontend/test/specs/customchecks/viewing-failing-custom-checks.spec.ts +++ b/src/Frontend/test/specs/customchecks/viewing-failing-custom-checks.spec.ts @@ -3,32 +3,31 @@ import * as precondition from "../../preconditions"; describe("FEATURE: Failing custom checks", () => { describe("RULE: Custom checks are displayed", () => { - test("EXAMPLE: All custom checks are in a failed state", async ({ driver }) => { + test("EXAMPLE: All custom checks are in a failed state and should be displayed in a list on the custom checks tab", async ({ driver }) => { await driver.setUp(precondition.serviceControlWithMonitoring); // Given there are failing custom checks - // And all custom checks are in a failed state await driver.setUp( precondition.hasCustomChecks([ { failed: true, reason: "Test reason 1" }, { failed: true, reason: "Test reason 2" }, ]) ); + }); + /* SCENARIO + Given there are custom checks + And all custom checks are in a failed state + When navigating to the custom checks tab + Then a list of custom checks is shown + */ - // When navigating to the custom checks tab - await driver.goTo("/custom-checks"); - - //TODO: Then a list of custom checks is shown and all FAILED checks should be displayed in a list on the custom checks tab - - //TODO: retrieve the list of custom checks and check the different attributes being rendered. - /* NOTES + /* NOTES Failure reason (if given) Name (Check) Category Endpoint Host Last checked - */ - }); + */ }); describe("RULE: Only failed custom checks are displayed", () => { test.todo("EXAMPLE: Only failed custom checks should be displayed in the list on the custom checks tab"); From 3c056ab79d997ec39182062a72bf96e5e4b302d5 Mon Sep 17 00:00:00 2001 From: Jayanthi Date: Sat, 11 Jan 2025 23:20:07 -0800 Subject: [PATCH 12/30] Revert "wip Failing custom checks tests" This reverts commit 300bfd10506f69a94d1790f6f23e2675d82e0937. --- .../viewing-failing-custom-checks.spec.ts | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/Frontend/test/specs/customchecks/viewing-failing-custom-checks.spec.ts b/src/Frontend/test/specs/customchecks/viewing-failing-custom-checks.spec.ts index 376a50b48..d1b09282e 100644 --- a/src/Frontend/test/specs/customchecks/viewing-failing-custom-checks.spec.ts +++ b/src/Frontend/test/specs/customchecks/viewing-failing-custom-checks.spec.ts @@ -1,18 +1,9 @@ import { test, describe } from "../../drivers/vitest/driver"; -import * as precondition from "../../preconditions"; describe("FEATURE: Failing custom checks", () => { describe("RULE: Custom checks are displayed", () => { - test("EXAMPLE: All custom checks are in a failed state and should be displayed in a list on the custom checks tab", async ({ driver }) => { - await driver.setUp(precondition.serviceControlWithMonitoring); - // Given there are failing custom checks - await driver.setUp( - precondition.hasCustomChecks([ - { failed: true, reason: "Test reason 1" }, - { failed: true, reason: "Test reason 2" }, - ]) - ); - }); + test.todo("EXAMPLE: All custom checks are in a failed state and should be displayed in a list on the custom checks tab"); + /* SCENARIO Given there are custom checks And all custom checks are in a failed state From 9e4bcbe6b21fe8ee426d280f7c79ec6d32bfd968 Mon Sep 17 00:00:00 2001 From: Jayanthi Date: Sat, 11 Jan 2025 23:20:12 -0800 Subject: [PATCH 13/30] Revert "No data custom checks tests" This reverts commit fcfd091789610011a64cecfa0cb2091d2c0290db. --- src/Frontend/src/components/NoData.vue | 2 +- src/Frontend/test/mocks/browser.ts | 2 - .../questions/messageShownWithText.ts | 6 --- .../customchecks/viewing-no-data.spec.ts | 39 +++++-------------- 4 files changed, 10 insertions(+), 39 deletions(-) delete mode 100644 src/Frontend/test/specs/customchecks/questions/messageShownWithText.ts diff --git a/src/Frontend/src/components/NoData.vue b/src/Frontend/src/components/NoData.vue index 9eb810542..b8929b154 100644 --- a/src/Frontend/src/components/NoData.vue +++ b/src/Frontend/src/components/NoData.vue @@ -11,7 +11,7 @@ const props = defineProps<{
-

{{ props.message }}

+

{{ props.message }}

 

diff --git a/src/Frontend/test/mocks/browser.ts b/src/Frontend/test/mocks/browser.ts index 43a3f92b2..47a93bb18 100644 --- a/src/Frontend/test/mocks/browser.ts +++ b/src/Frontend/test/mocks/browser.ts @@ -32,8 +32,6 @@ const driver = makeDriver(); ]) ); - await driver.setUp(precondition.hasZeroCustomChecks); - // await driver.setUp( // precondition.monitoredEndpointsNamed([ // "Universe.Solarsystem.Mercury.Endpoint1", diff --git a/src/Frontend/test/specs/customchecks/questions/messageShownWithText.ts b/src/Frontend/test/specs/customchecks/questions/messageShownWithText.ts deleted file mode 100644 index cccaf410b..000000000 --- a/src/Frontend/test/specs/customchecks/questions/messageShownWithText.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { screen } from "@testing-library/vue"; - -export function messageShownWithText(message: string) { - const statusElements = screen.getAllByRole("status"); - return statusElements.find((el) => el.textContent === message) !== null; -} diff --git a/src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts b/src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts index 553ff0613..ea3ff2892 100644 --- a/src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts +++ b/src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts @@ -1,42 +1,21 @@ import { test, describe } from "../../drivers/vitest/driver"; -import * as precondition from "../../preconditions"; -import { messageShownWithText } from "./questions/messageShownWithText"; -import { expect } from "vitest"; + describe("FEATURE: No data", () => { describe("RULE: When there is no data to show a message should be displayed ", () => { - test("EXAMPLE: There are no failed or passing custom checks", async ({ driver }) => { - await driver.setUp(precondition.serviceControlWithMonitoring); - // Given there are no custom checks - await driver.setUp(precondition.hasZeroCustomChecks); - - // When navigating to the custom checks tab - await driver.goTo("/custom-checks"); + test.todo("EXAMPLE: 'No failed custom checks' should be displayed when there are no custom checks"); - // Then a message is shown "No failed custom checks" - expect(messageShownWithText("No failed custom checks")).toBe(true); - }); + /* SCENARIO + Given there are no custom checks + When navigating to the custom checks tab + Then a message is shown "No failed custom checks" + */ - test("EXAMPLE: There are custom checks but none of them are failing", async ({ driver }) => { - /* SCENARIO + test.todo("EXAMPLE: 'No failed custom checks' should be displayed when all custom checks are in a success state"); + /* SCENARIO Given there are custom checks And all custom checks are in a success state When navigating to the custom checks tab The a message is shown "No failed custom checks" */ - await driver.setUp(precondition.serviceControlWithMonitoring); - // Given there are custom checks but none of them are failing - await driver.setUp( - precondition.hasCustomChecks([ - { failed: false, reason: "Test reason 1" }, - { failed: false, reason: "Test reason 2" }, - ]) - ); - - // When navigating to the custom checks tab - await driver.goTo("/custom-checks"); - - // Then a message is shown "No failed custom checks" - expect(messageShownWithText("No failed custom checks")).toBe(true); - }); }); }); From 3f810b098d32a8a6f2afa06ff45c8146217705f1 Mon Sep 17 00:00:00 2001 From: Jayanthi Date: Sat, 11 Jan 2025 23:20:17 -0800 Subject: [PATCH 14/30] Revert "dynamic precondition function hasCustomChecks" This reverts commit 07ade8506b789260592ad64b8e78d9cb085efe33. --- .../serviceControlWithHeartbeats.ts | 2 +- .../serviceControlWithThroughput.ts | 2 +- src/Frontend/test/mocks/browser.ts | 8 +- .../test/preconditions/customChecks.ts | 57 ------ .../preconditions/hasNoFailingCustomChecks.ts | 188 ++++++++++++++++++ src/Frontend/test/preconditions/index.ts | 2 +- .../serviceControlWithMonitoring.ts | 2 +- 7 files changed, 193 insertions(+), 68 deletions(-) delete mode 100644 src/Frontend/test/preconditions/customChecks.ts create mode 100644 src/Frontend/test/preconditions/hasNoFailingCustomChecks.ts diff --git a/src/Frontend/src/components/heartbeats/serviceControlWithHeartbeats.ts b/src/Frontend/src/components/heartbeats/serviceControlWithHeartbeats.ts index a30f5f7b5..c674aba34 100644 --- a/src/Frontend/src/components/heartbeats/serviceControlWithHeartbeats.ts +++ b/src/Frontend/src/components/heartbeats/serviceControlWithHeartbeats.ts @@ -6,7 +6,7 @@ export const serviceControlWithHeartbeats = async ({ driver }: SetupFactoryOptio await driver.setUp(precondition.hasUpToDateServicePulse); await driver.setUp(precondition.hasUpToDateServiceControl); await driver.setUp(precondition.errorsDefaultHandler); - await driver.setUp(precondition.hasZeroCustomChecks); + await driver.setUp(precondition.hasNoFailingCustomChecks); await driver.setUp(precondition.hasEventLogItems); await driver.setUp(precondition.hasServiceControlMainInstance(minimumSCVersionForEndpointSettings)); await driver.setUp(precondition.hasNoDisconnectedEndpoints); diff --git a/src/Frontend/src/views/throughputreport/serviceControlWithThroughput.ts b/src/Frontend/src/views/throughputreport/serviceControlWithThroughput.ts index 13768b9f8..b22ea3064 100644 --- a/src/Frontend/src/views/throughputreport/serviceControlWithThroughput.ts +++ b/src/Frontend/src/views/throughputreport/serviceControlWithThroughput.ts @@ -6,7 +6,7 @@ export const serviceControlWithThroughput = async ({ driver }: SetupFactoryOptio await driver.setUp(precondition.hasUpToDateServicePulse); await driver.setUp(precondition.hasUpToDateServiceControl); await driver.setUp(precondition.errorsDefaultHandler); - await driver.setUp(precondition.hasZeroCustomChecks); + await driver.setUp(precondition.hasNoFailingCustomChecks); await driver.setUp(precondition.hasEventLogItems); await driver.setUp(precondition.hasNoHeartbeatsEndpoints); await driver.setUp(precondition.hasServiceControlMainInstance(minimumSCVersionForThroughput)); diff --git a/src/Frontend/test/mocks/browser.ts b/src/Frontend/test/mocks/browser.ts index 47a93bb18..14df40ed8 100644 --- a/src/Frontend/test/mocks/browser.ts +++ b/src/Frontend/test/mocks/browser.ts @@ -25,13 +25,7 @@ const driver = makeDriver(); (async () => { await driver.setUp(precondition.serviceControlWithMonitoring); //override the default mocked endpoints with a custom list - await driver.setUp( - precondition.hasCustomChecks([ - { failed: true, reason: "Test reason 1" }, - { failed: true, reason: "Test reason 2" }, - ]) - ); - + await driver.setUp(precondition.hasNoFailingCustomChecks); // await driver.setUp( // precondition.monitoredEndpointsNamed([ // "Universe.Solarsystem.Mercury.Endpoint1", diff --git a/src/Frontend/test/preconditions/customChecks.ts b/src/Frontend/test/preconditions/customChecks.ts deleted file mode 100644 index a88039ef2..000000000 --- a/src/Frontend/test/preconditions/customChecks.ts +++ /dev/null @@ -1,57 +0,0 @@ -import CustomCheck from "@/resources/CustomCheck"; -import { SetupFactoryOptions } from "../driver"; - -export const hasZeroCustomChecks = ({ driver }: SetupFactoryOptions) => { - const serviceControlInstanceUrl = window.defaultConfig.service_control_url; - driver.mockEndpoint(`${serviceControlInstanceUrl}customchecks`, { - body: [], - headers: { - "Total-Count": "0", - }, - }); -}; - -const customCheckTemplate = { - id: "CustomChecks/6131fa95-9414-1898-9c83-c5b18587945b", - custom_check_id: "Audit Message Ingestion", - category: "ServiceControl.Audit Health", - status: "Pass", - failure_reason: "I dont know the reason", - reported_at: "2025-01-10T05:06:30.4074087Z", - originating_endpoint: { - name: "Particular.ServiceControl.Audit", - host_id: "ff605b55-6fbb-af56-5753-73c1ff73e601", - host: "ABC", - }, -}; - -export const hasCustomChecks = - (params: { failed: boolean; reason: string }[]) => - ({ driver }: SetupFactoryOptions) => { - const serviceControlInstanceUrl = window.defaultConfig.service_control_url; - - const customChecks = params.map((check) => { - return { - ...customCheckTemplate, - status: check.failed ? "Fail" : "Pass", - failure_reason: check.reason.toString(), - }; - }); - - const failedCustomChecks = customChecks.filter((check) => check.status === "Fail"); - - driver.mockEndpointDynamic(`${serviceControlInstanceUrl}customchecks`, (url) => { - const status = url.searchParams.get("status"); - if (status === "fail") { - return { - body: failedCustomChecks, - headers: { "Total-Count": failedCustomChecks.length.toString() }, - }; - } - - return { - body: customChecks, - headers: { "Total-Count": customChecks.length.toString() }, - }; - }); - }; diff --git a/src/Frontend/test/preconditions/hasNoFailingCustomChecks.ts b/src/Frontend/test/preconditions/hasNoFailingCustomChecks.ts new file mode 100644 index 000000000..db14ad671 --- /dev/null +++ b/src/Frontend/test/preconditions/hasNoFailingCustomChecks.ts @@ -0,0 +1,188 @@ +import CustomCheck from "@/resources/CustomCheck"; +import { SetupFactoryOptions } from "../driver"; + +//const content = JSON.stringify([]); + +export const hasNoFailingCustomChecks = ({ driver }: SetupFactoryOptions) => { + const serviceControlInstanceUrl = window.defaultConfig.service_control_url; + driver.mockEndpoint(`${serviceControlInstanceUrl}customchecks`, { + body: [ + { + id: "CustomChecks/6131fa95-9414-1898-9c83-c5b18587945b", + custom_check_id: "Audit Message Ingestion", + category: "ServiceControl.Audit Health", + status: "Fail", + failure_reason: "I dont know the reason", + reported_at: "2025-01-10T05:06:30.4074087Z", + originating_endpoint: { + name: "Particular.ServiceControl.Audit", + host_id: "ff605b55-6fbb-af56-5753-73c1ff73e601", + host: "JAYANTHI-LAPTOP", + }, + }, + ], + headers: { + "Total-Count": "1", + }, + }); + + //return content; +}; +// [ +// { +// "id": "CustomChecks/6131fa95-9414-1898-9c83-c5b18587945b", +// "custom_check_id": "Audit Message Ingestion", +// "category": "ServiceControl.Audit Health", +// "status": "pass", +// "reported_at": "2025-01-10T05:06:30.4074087Z", +// "originating_endpoint": { +// "name": "Particular.ServiceControl.Audit", +// "host_id": "ff605b55-6fbb-af56-5753-73c1ff73e601", +// "host": "JAYANTHI-LAPTOP" +// } +// }, +// { +// "id": "CustomChecks/36752f09-8a72-752e-e48f-6c378329d43b", +// "custom_check_id": "Error Message Ingestion", +// "category": "ServiceControl Health", +// "status": "pass", +// "reported_at": "2025-01-10T05:42:00.531067Z", +// "originating_endpoint": { +// "name": "Particular.ServiceControl", +// "host_id": "9f822d11-b097-a4df-3db5-e069e5d356fe", +// "host": "JAYANTHI-LAPTOP" +// } +// }, +// { +// "id": "CustomChecks/02564a68-8c3e-92f6-d977-ce45d7ce46ed", +// "custom_check_id": "ServiceControl.Audit database", +// "category": "Storage space", +// "status": "pass", +// "reported_at": "2025-01-10T05:51:44.4635095Z", +// "originating_endpoint": { +// "name": "Particular.ServiceControl.Audit", +// "host_id": "ff605b55-6fbb-af56-5753-73c1ff73e601", +// "host": "JAYANTHI-LAPTOP" +// } +// }, +// { +// "id": "CustomChecks/5443ee67-c22a-521f-5dc1-b979f831151a", +// "custom_check_id": "Audit Database Index Lag", +// "category": "ServiceControl.Audit Health", +// "status": "pass", +// "reported_at": "2025-01-10T05:51:47.7264687Z", +// "originating_endpoint": { +// "name": "Particular.ServiceControl.Audit", +// "host_id": "ff605b55-6fbb-af56-5753-73c1ff73e601", +// "host": "JAYANTHI-LAPTOP" +// } +// }, +// { +// "id": "CustomChecks/93b62dc3-e1bf-abfd-4268-8d36fef2b0c6", +// "custom_check_id": "ServiceControl database", +// "category": "Storage space", +// "status": "pass", +// "reported_at": "2025-01-10T05:52:03.8512021Z", +// "originating_endpoint": { +// "name": "Particular.ServiceControl", +// "host_id": "9f822d11-b097-a4df-3db5-e069e5d356fe", +// "host": "JAYANTHI-LAPTOP" +// } +// }, +// { +// "id": "CustomChecks/7e09172e-7c59-9a0c-52da-e2ecc1784e15", +// "custom_check_id": "Saga Audit Configuration", +// "category": "Configuration", +// "status": "pass", +// "reported_at": "2025-01-10T05:52:03.850927Z", +// "originating_endpoint": { +// "name": "Particular.ServiceControl", +// "host_id": "9f822d11-b097-a4df-3db5-e069e5d356fe", +// "host": "JAYANTHI-LAPTOP" +// } +// }, +// { +// "id": "CustomChecks/7940dbbf-3019-cb8a-3add-b9ff9c57edb7", +// "custom_check_id": "Error Database Index Errors", +// "category": "ServiceControl Health", +// "status": "pass", +// "reported_at": "2025-01-10T05:52:03.8522051Z", +// "originating_endpoint": { +// "name": "Particular.ServiceControl", +// "host_id": "9f822d11-b097-a4df-3db5-e069e5d356fe", +// "host": "JAYANTHI-LAPTOP" +// } +// }, +// { +// "id": "CustomChecks/4dc66bce-632b-5404-bc3d-e1943d99c301", +// "custom_check_id": "Error Database Index Lag", +// "category": "ServiceControl Health", +// "status": "pass", +// "reported_at": "2025-01-10T05:52:05.8153025Z", +// "originating_endpoint": { +// "name": "Particular.ServiceControl", +// "host_id": "9f822d11-b097-a4df-3db5-e069e5d356fe", +// "host": "JAYANTHI-LAPTOP" +// } +// }, +// { +// "id": "CustomChecks/3eab20ba-3c24-b354-d298-aae5412c0125", +// "custom_check_id": "ServiceControl Remotes", +// "category": "Health", +// "status": "pass", +// "reported_at": "2025-01-10T05:52:10.1360722Z", +// "originating_endpoint": { +// "name": "Particular.ServiceControl", +// "host_id": "9f822d11-b097-a4df-3db5-e069e5d356fe", +// "host": "JAYANTHI-LAPTOP" +// } +// }, +// { +// "id": "CustomChecks/c7011287-308f-c7b7-f50a-cca3c3fe17da", +// "custom_check_id": "ServiceControl Primary Instance", +// "category": "Health", +// "status": "pass", +// "reported_at": "2025-01-10T05:52:18.4970695Z", +// "originating_endpoint": { +// "name": "Particular.ServiceControl", +// "host_id": "9f822d11-b097-a4df-3db5-e069e5d356fe", +// "host": "JAYANTHI-LAPTOP" +// } +// }, +// { +// "id": "CustomChecks/66675ab0-b69a-6a5a-6a56-da7709464fba", +// "custom_check_id": "Message Ingestion Process", +// "category": "ServiceControl Health", +// "status": "pass", +// "reported_at": "2025-01-10T05:52:29.398929Z", +// "originating_endpoint": { +// "name": "Particular.ServiceControl", +// "host_id": "9f822d11-b097-a4df-3db5-e069e5d356fe", +// "host": "JAYANTHI-LAPTOP" +// } +// }, +// { +// "id": "CustomChecks/418dafe7-1dd2-886b-65d1-2b3e71e4feb2", +// "custom_check_id": "Error Message Ingestion Process", +// "category": "ServiceControl Health", +// "status": "pass", +// "reported_at": "2025-01-10T05:52:29.3984912Z", +// "originating_endpoint": { +// "name": "Particular.ServiceControl", +// "host_id": "9f822d11-b097-a4df-3db5-e069e5d356fe", +// "host": "JAYANTHI-LAPTOP" +// } +// }, +// { +// "id": "CustomChecks/a406f1a7-412c-dd2c-7f90-9aa32da0698b", +// "custom_check_id": "Audit Message Ingestion Process", +// "category": "ServiceControl Health", +// "status": "pass", +// "reported_at": "2025-01-10T05:52:31.4929675Z", +// "originating_endpoint": { +// "name": "Particular.ServiceControl.Audit", +// "host_id": "ff605b55-6fbb-af56-5753-73c1ff73e601", +// "host": "JAYANTHI-LAPTOP" +// } +// } +// ] diff --git a/src/Frontend/test/preconditions/index.ts b/src/Frontend/test/preconditions/index.ts index 2cb0b8b0a..0c20e7a9f 100644 --- a/src/Frontend/test/preconditions/index.ts +++ b/src/Frontend/test/preconditions/index.ts @@ -5,7 +5,7 @@ export { hasServiceControlMonitoringInstanceUrl } from "../preconditions/hasServ export { hasUpToDateServiceControl } from "../preconditions/hasUpToDateServiceControl"; export { hasUpToDateServicePulse } from "../preconditions/hasUpToDateServicePulse"; export { errorsDefaultHandler } from "../preconditions/hasNoErrors"; -export * from "./customChecks"; +export { hasNoFailingCustomChecks } from "../preconditions/hasNoFailingCustomChecks"; export { hasNoDisconnectedEndpoints } from "../preconditions/hasNoDisconnectedEndpoints"; export { hasNoMonitoredEndpoints, hasMonitoredEndpointsList, monitoredEndpointsNamed } from "../preconditions/hasMonitoredEndpoints"; export { hasEventLogItems } from "../preconditions/hasEventLogItems"; diff --git a/src/Frontend/test/preconditions/serviceControlWithMonitoring.ts b/src/Frontend/test/preconditions/serviceControlWithMonitoring.ts index b6a697331..588c7ea40 100644 --- a/src/Frontend/test/preconditions/serviceControlWithMonitoring.ts +++ b/src/Frontend/test/preconditions/serviceControlWithMonitoring.ts @@ -23,7 +23,7 @@ export const serviceControlWithMonitoring = async ({ driver }: SetupFactoryOptio await driver.setUp(precondition.errorsDefaultHandler); //http://localhost:33333/api/customchecks - await driver.setUp(precondition.hasZeroCustomChecks); + await driver.setUp(precondition.hasNoFailingCustomChecks); //http://localhost:33633/monitored-endpoints/disconnected await driver.setUp(precondition.hasNoDisconnectedEndpoints); From 56aef1bdd50064687d2db9a72c07ef93e70d5b35 Mon Sep 17 00:00:00 2001 From: Jayanthi Date: Sun, 19 Jan 2025 21:27:03 -0800 Subject: [PATCH 15/30] wip : add mocks for custom checks data, add test to check for "no failed custom checks message" - --- .../serviceControlWithHeartbeats.ts | 2 +- src/Frontend/src/views/CustomChecksView.vue | 2 +- .../serviceControlWithThroughput.ts | 2 +- src/Frontend/test/mocks/browser.ts | 38 ++-- .../preconditions/hasCustomChecksEmpty.ts | 14 ++ .../preconditions/hasCustomChecksFailing.ts | 117 +++++++++++ .../preconditions/hasCustomChecksPassing.ts | 169 ++++++++++++++++ .../preconditions/hasNoFailingCustomChecks.ts | 188 ------------------ src/Frontend/test/preconditions/index.ts | 4 +- .../serviceControlWithMonitoring.ts | 2 +- .../questions/customChecksMessage.ts | 6 + .../customchecks/viewing-no-data.spec.ts | 46 ++++- 12 files changed, 370 insertions(+), 220 deletions(-) create mode 100644 src/Frontend/test/preconditions/hasCustomChecksEmpty.ts create mode 100644 src/Frontend/test/preconditions/hasCustomChecksFailing.ts create mode 100644 src/Frontend/test/preconditions/hasCustomChecksPassing.ts delete mode 100644 src/Frontend/test/preconditions/hasNoFailingCustomChecks.ts create mode 100644 src/Frontend/test/specs/customchecks/questions/customChecksMessage.ts diff --git a/src/Frontend/src/components/heartbeats/serviceControlWithHeartbeats.ts b/src/Frontend/src/components/heartbeats/serviceControlWithHeartbeats.ts index c674aba34..0f3e82b87 100644 --- a/src/Frontend/src/components/heartbeats/serviceControlWithHeartbeats.ts +++ b/src/Frontend/src/components/heartbeats/serviceControlWithHeartbeats.ts @@ -6,7 +6,7 @@ export const serviceControlWithHeartbeats = async ({ driver }: SetupFactoryOptio await driver.setUp(precondition.hasUpToDateServicePulse); await driver.setUp(precondition.hasUpToDateServiceControl); await driver.setUp(precondition.errorsDefaultHandler); - await driver.setUp(precondition.hasNoFailingCustomChecks); + await driver.setUp(precondition.hasCustomChecksEmpty); await driver.setUp(precondition.hasEventLogItems); await driver.setUp(precondition.hasServiceControlMainInstance(minimumSCVersionForEndpointSettings)); await driver.setUp(precondition.hasNoDisconnectedEndpoints); diff --git a/src/Frontend/src/views/CustomChecksView.vue b/src/Frontend/src/views/CustomChecksView.vue index 2837be073..af41435f1 100644 --- a/src/Frontend/src/views/CustomChecksView.vue +++ b/src/Frontend/src/views/CustomChecksView.vue @@ -19,7 +19,7 @@ const { pageNumber, failingCount, failedChecks } = storeToRefs(store);
- +
diff --git a/src/Frontend/src/views/throughputreport/serviceControlWithThroughput.ts b/src/Frontend/src/views/throughputreport/serviceControlWithThroughput.ts index b22ea3064..f8fb63cf4 100644 --- a/src/Frontend/src/views/throughputreport/serviceControlWithThroughput.ts +++ b/src/Frontend/src/views/throughputreport/serviceControlWithThroughput.ts @@ -6,7 +6,7 @@ export const serviceControlWithThroughput = async ({ driver }: SetupFactoryOptio await driver.setUp(precondition.hasUpToDateServicePulse); await driver.setUp(precondition.hasUpToDateServiceControl); await driver.setUp(precondition.errorsDefaultHandler); - await driver.setUp(precondition.hasNoFailingCustomChecks); + await driver.setUp(precondition.hasCustomChecksEmpty); await driver.setUp(precondition.hasEventLogItems); await driver.setUp(precondition.hasNoHeartbeatsEndpoints); await driver.setUp(precondition.hasServiceControlMainInstance(minimumSCVersionForThroughput)); diff --git a/src/Frontend/test/mocks/browser.ts b/src/Frontend/test/mocks/browser.ts index 14df40ed8..c499e8560 100644 --- a/src/Frontend/test/mocks/browser.ts +++ b/src/Frontend/test/mocks/browser.ts @@ -25,23 +25,23 @@ const driver = makeDriver(); (async () => { await driver.setUp(precondition.serviceControlWithMonitoring); //override the default mocked endpoints with a custom list - await driver.setUp(precondition.hasNoFailingCustomChecks); - // await driver.setUp( - // precondition.monitoredEndpointsNamed([ - // "Universe.Solarsystem.Mercury.Endpoint1", - // "Universe.Solarsystem.Mercury.Endpoint2", - // "Universe.Solarsystem.Venus.Endpoint3", - // "Universe.Solarsystem.Venus.Endpoint4", - // "Universe.Solarsystem.Earth.Endpoint5", - // "Universe.Solarsystem.Earth.Endpoint6", - // ]) - // ); - // await driver.setUp( - // precondition.hasFailedMessage({ - // withGroupId: "81dca64e-76fc-e1c3-11a2-3069f51c58c8", - // withMessageId: "40134401-bab9-41aa-9acb-b19c0066f22d", - // withContentType: "application/json", - // withBody: { Index: 0, Data: "" }, - // }) - // ); + await driver.setUp(precondition.hasCustomChecksEmpty); + await driver.setUp( + precondition.monitoredEndpointsNamed([ + "Universe.Solarsystem.Mercury.Endpoint1", + "Universe.Solarsystem.Mercury.Endpoint2", + "Universe.Solarsystem.Venus.Endpoint3", + "Universe.Solarsystem.Venus.Endpoint4", + "Universe.Solarsystem.Earth.Endpoint5", + "Universe.Solarsystem.Earth.Endpoint6", + ]) + ); + await driver.setUp( + precondition.hasFailedMessage({ + withGroupId: "81dca64e-76fc-e1c3-11a2-3069f51c58c8", + withMessageId: "40134401-bab9-41aa-9acb-b19c0066f22d", + withContentType: "application/json", + withBody: { Index: 0, Data: "" }, + }) + ); })(); diff --git a/src/Frontend/test/preconditions/hasCustomChecksEmpty.ts b/src/Frontend/test/preconditions/hasCustomChecksEmpty.ts new file mode 100644 index 000000000..070a79c86 --- /dev/null +++ b/src/Frontend/test/preconditions/hasCustomChecksEmpty.ts @@ -0,0 +1,14 @@ +//import CustomCheck from "@/resources/CustomCheck"; +import { SetupFactoryOptions } from "../driver"; + +const content = JSON.stringify([]); + +export const hasCustomChecksEmpty = ({ driver }: SetupFactoryOptions) => { + const serviceControlInstanceUrl = window.defaultConfig.service_control_url; + driver.mockEndpoint(`${serviceControlInstanceUrl}customchecks`, { + body: content, + headers: { + "Total-Count": "0", //count of failing custom checks + }, + }); +}; diff --git a/src/Frontend/test/preconditions/hasCustomChecksFailing.ts b/src/Frontend/test/preconditions/hasCustomChecksFailing.ts new file mode 100644 index 000000000..74cddb7c2 --- /dev/null +++ b/src/Frontend/test/preconditions/hasCustomChecksFailing.ts @@ -0,0 +1,117 @@ +import CustomCheck from "@/resources/CustomCheck"; +import { SetupFactoryOptions } from "../driver"; + +export const hasCustomChecksFailing = ({ driver }: SetupFactoryOptions) => { + const serviceControlInstanceUrl = window.defaultConfig.service_control_url; + driver.mockEndpoint(`${serviceControlInstanceUrl}customchecks`, { + body: [ + { + id: "CustomChecks/6131fa95-9414-1898-9c83-c5b18587945b", + custom_check_id: "Audit Message Ingestion", + category: "ServiceControl.Audit Health", + status: "Fail", + failure_reason: "I dont know the reason", + reported_at: "2025-01-10T05:06:30.4074087Z", + originating_endpoint: { + name: "Particular.ServiceControl.Audit", + host_id: "ff605b55-6fbb-af56-5753-73c1ff73e601", + host: "COMPUSA-LAPTOP", + }, + }, + { + id: "CustomChecks/36752f09-8a72-752e-e48f-6c378329d43b", + custom_check_id: "Error Message Ingestion", + category: "ServiceControl Health", + status: "Fail", + failure_reason: "I am unable to ingest error messages", + reported_at: "2025-01-10T05:42:00.531067Z", + originating_endpoint: { + name: "Particular.ServiceControl", + host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", + host: "COMPUSA-LAPTOP", + }, + }, + { + id: "CustomChecks/93b62dc3-e1bf-abfd-4268-8d36fef2b0c6", + custom_check_id: "ServiceControl database", + category: "Storage space", + status: "Fail", + failure_reason: "I dont have enough storage", + reported_at: "2025-01-10T05:52:03.8512021Z", + originating_endpoint: { + name: "Particular.ServiceControl", + host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", + host: "COMPUSA-LAPTOP", + }, + }, + { + id: "CustomChecks/7e09172e-7c59-9a0c-52da-e2ecc1784e15", + custom_check_id: "Saga Audit Configuration", + category: "Configuration", + status: "Fail", + failure_reason: "There is something wrong in Saga Audit configuration", + reported_at: "2025-01-10T05:52:03.850927Z", + originating_endpoint: { + name: "Particular.ServiceControl", + host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", + host: "COMPUSA-LAPTOP", + }, + }, + { + id: "CustomChecks/4dc66bce-632b-5404-bc3d-e1943d99c301", + custom_check_id: "Error Database Index Lag", + category: "ServiceControl Health", + status: "Fail", + failure_reason: "There is an index lag", + reported_at: "2025-01-10T05:52:05.8153025Z", + originating_endpoint: { + name: "Particular.ServiceControl", + host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", + host: "COMPUSA-LAPTOP", + }, + }, + { + id: "CustomChecks/66675ab0-b69a-6a5a-6a56-da7709464fba", + custom_check_id: "Message Ingestion Process", + category: "ServiceControl Health", + status: "Fail", + failure_reason: "Unable to ingest messages", + reported_at: "2025-01-10T05:52:29.398929Z", + originating_endpoint: { + name: "Particular.ServiceControl", + host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", + host: "COMPUSA-LAPTOP", + }, + }, + { + id: "CustomChecks/418dafe7-1dd2-886b-65d1-2b3e71e4feb2", + custom_check_id: "Error Message Ingestion Process", + category: "ServiceControl Health", + status: "Fail", + failure_reason: "I dont know the reason", + reported_at: "2025-01-10T05:52:29.3984912Z", + originating_endpoint: { + name: "Particular.ServiceControl", + host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", + host: "COMPUSA-LAPTOP", + }, + }, + { + id: "CustomChecks/a406f1a7-412c-dd2c-7f90-9aa32da0698b", + custom_check_id: "Audit Message Ingestion Process", + category: "ServiceControl Health", + status: "Fail", + failure_reason: "I dont know the reason for Audit Message Ingestion failure", + reported_at: "2025-01-10T05:52:31.4929675Z", + originating_endpoint: { + name: "Particular.ServiceControl.Audit", + host_id: "ff605b55-6fbb-af56-5753-73c1ff73e601", + host: "COMPUSA-LAPTOP", + }, + }, + ], + headers: { + "Total-Count": "8", //count of failing custom checks + }, + }); +}; diff --git a/src/Frontend/test/preconditions/hasCustomChecksPassing.ts b/src/Frontend/test/preconditions/hasCustomChecksPassing.ts new file mode 100644 index 000000000..c65d57c44 --- /dev/null +++ b/src/Frontend/test/preconditions/hasCustomChecksPassing.ts @@ -0,0 +1,169 @@ +import CustomCheck from "@/resources/CustomCheck"; +import { SetupFactoryOptions } from "../driver"; + +export const hasCustomChecksPassing = ({ driver }: SetupFactoryOptions) => { + const serviceControlInstanceUrl = window.defaultConfig.service_control_url; + driver.mockEndpoint(`${serviceControlInstanceUrl}customchecks`, { + body: [ + { + id: "CustomChecks/6131fa95-9414-1898-9c83-c5b18587945b", + custom_check_id: "Audit Message Ingestion", + category: "ServiceControl.Audit Health", + status: "Pass", + reported_at: "2025-01-10T05:06:30.4074087Z", + originating_endpoint: { + name: "Particular.ServiceControl.Audit", + host_id: "ff605b55-6fbb-af56-5753-73c1ff73e601", + host: "COMPUSA-LAPTOP", + }, + }, + { + id: "CustomChecks/36752f09-8a72-752e-e48f-6c378329d43b", + custom_check_id: "Error Message Ingestion", + category: "ServiceControl Health", + status: "Pass", + reported_at: "2025-01-10T05:42:00.531067Z", + originating_endpoint: { + name: "Particular.ServiceControl", + host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", + host: "COMPUSA-LAPTOP", + }, + }, + { + id: "CustomChecks/02564a68-8c3e-92f6-d977-ce45d7ce46ed", + custom_check_id: "ServiceControl.Audit database", + category: "Storage space", + status: "Pass", + reported_at: "2025-01-10T05:51:44.4635095Z", + originating_endpoint: { + name: "Particular.ServiceControl.Audit", + host_id: "ff605b55-6fbb-af56-5753-73c1ff73e601", + host: "COMPUSA-LAPTOP", + }, + }, + { + id: "CustomChecks/5443ee67-c22a-521f-5dc1-b979f831151a", + custom_check_id: "Audit Database Index Lag", + category: "ServiceControl.Audit Health", + status: "Pass", + reported_at: "2025-01-10T05:51:47.7264687Z", + originating_endpoint: { + name: "Particular.ServiceControl.Audit", + host_id: "ff605b55-6fbb-af56-5753-73c1ff73e601", + host: "COMPUSA-LAPTOP", + }, + }, + { + id: "CustomChecks/93b62dc3-e1bf-abfd-4268-8d36fef2b0c6", + custom_check_id: "ServiceControl database", + category: "Storage space", + status: "Pass", + reported_at: "2025-01-10T05:52:03.8512021Z", + originating_endpoint: { + name: "Particular.ServiceControl", + host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", + host: "COMPUSA-LAPTOP", + }, + }, + { + id: "CustomChecks/7e09172e-7c59-9a0c-52da-e2ecc1784e15", + custom_check_id: "Saga Audit Configuration", + category: "Configuration", + status: "Pass", + reported_at: "2025-01-10T05:52:03.850927Z", + originating_endpoint: { + name: "Particular.ServiceControl", + host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", + host: "COMPUSA-LAPTOP", + }, + }, + { + id: "CustomChecks/7940dbbf-3019-cb8a-3add-b9ff9c57edb7", + custom_check_id: "Error Database Index Errors", + category: "ServiceControl Health", + status: "Pass", + reported_at: "2025-01-10T05:52:03.8522051Z", + originating_endpoint: { + name: "Particular.ServiceControl", + host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", + host: "COMPUSA-LAPTOP", + }, + }, + { + id: "CustomChecks/4dc66bce-632b-5404-bc3d-e1943d99c301", + custom_check_id: "Error Database Index Lag", + category: "ServiceControl Health", + status: "Pass", + reported_at: "2025-01-10T05:52:05.8153025Z", + originating_endpoint: { + name: "Particular.ServiceControl", + host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", + host: "COMPUSA-LAPTOP", + }, + }, + { + id: "CustomChecks/3eab20ba-3c24-b354-d298-aae5412c0125", + custom_check_id: "ServiceControl Remotes", + category: "Health", + status: "Pass", + reported_at: "2025-01-10T05:52:10.1360722Z", + originating_endpoint: { + name: "Particular.ServiceControl", + host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", + host: "COMPUSA-LAPTOP", + }, + }, + { + id: "CustomChecks/c7011287-308f-c7b7-f50a-cca3c3fe17da", + custom_check_id: "ServiceControl Primary Instance", + category: "Health", + status: "Pass", + reported_at: "2025-01-10T05:52:18.4970695Z", + originating_endpoint: { + name: "Particular.ServiceControl", + host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", + host: "COMPUSA-LAPTOP", + }, + }, + { + id: "CustomChecks/66675ab0-b69a-6a5a-6a56-da7709464fba", + custom_check_id: "Message Ingestion Process", + category: "ServiceControl Health", + status: "Pass", + reported_at: "2025-01-10T05:52:29.398929Z", + originating_endpoint: { + name: "Particular.ServiceControl", + host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", + host: "COMPUSA-LAPTOP", + }, + }, + { + id: "CustomChecks/418dafe7-1dd2-886b-65d1-2b3e71e4feb2", + custom_check_id: "Error Message Ingestion Process", + category: "ServiceControl Health", + status: "Pass", + reported_at: "2025-01-10T05:52:29.3984912Z", + originating_endpoint: { + name: "Particular.ServiceControl", + host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", + host: "COMPUSA-LAPTOP", + }, + }, + { + id: "CustomChecks/a406f1a7-412c-dd2c-7f90-9aa32da0698b", + custom_check_id: "Audit Message Ingestion Process", + category: "ServiceControl Health", + status: "Pass", + reported_at: "2025-01-10T05:52:31.4929675Z", + originating_endpoint: { + name: "Particular.ServiceControl.Audit", + host_id: "ff605b55-6fbb-af56-5753-73c1ff73e601", + host: "COMPUSA-LAPTOP", + }, + }, + ], + headers: { + "Total-Count": "0", //count of failing custom checks + }, + }); +}; diff --git a/src/Frontend/test/preconditions/hasNoFailingCustomChecks.ts b/src/Frontend/test/preconditions/hasNoFailingCustomChecks.ts deleted file mode 100644 index db14ad671..000000000 --- a/src/Frontend/test/preconditions/hasNoFailingCustomChecks.ts +++ /dev/null @@ -1,188 +0,0 @@ -import CustomCheck from "@/resources/CustomCheck"; -import { SetupFactoryOptions } from "../driver"; - -//const content = JSON.stringify([]); - -export const hasNoFailingCustomChecks = ({ driver }: SetupFactoryOptions) => { - const serviceControlInstanceUrl = window.defaultConfig.service_control_url; - driver.mockEndpoint(`${serviceControlInstanceUrl}customchecks`, { - body: [ - { - id: "CustomChecks/6131fa95-9414-1898-9c83-c5b18587945b", - custom_check_id: "Audit Message Ingestion", - category: "ServiceControl.Audit Health", - status: "Fail", - failure_reason: "I dont know the reason", - reported_at: "2025-01-10T05:06:30.4074087Z", - originating_endpoint: { - name: "Particular.ServiceControl.Audit", - host_id: "ff605b55-6fbb-af56-5753-73c1ff73e601", - host: "JAYANTHI-LAPTOP", - }, - }, - ], - headers: { - "Total-Count": "1", - }, - }); - - //return content; -}; -// [ -// { -// "id": "CustomChecks/6131fa95-9414-1898-9c83-c5b18587945b", -// "custom_check_id": "Audit Message Ingestion", -// "category": "ServiceControl.Audit Health", -// "status": "pass", -// "reported_at": "2025-01-10T05:06:30.4074087Z", -// "originating_endpoint": { -// "name": "Particular.ServiceControl.Audit", -// "host_id": "ff605b55-6fbb-af56-5753-73c1ff73e601", -// "host": "JAYANTHI-LAPTOP" -// } -// }, -// { -// "id": "CustomChecks/36752f09-8a72-752e-e48f-6c378329d43b", -// "custom_check_id": "Error Message Ingestion", -// "category": "ServiceControl Health", -// "status": "pass", -// "reported_at": "2025-01-10T05:42:00.531067Z", -// "originating_endpoint": { -// "name": "Particular.ServiceControl", -// "host_id": "9f822d11-b097-a4df-3db5-e069e5d356fe", -// "host": "JAYANTHI-LAPTOP" -// } -// }, -// { -// "id": "CustomChecks/02564a68-8c3e-92f6-d977-ce45d7ce46ed", -// "custom_check_id": "ServiceControl.Audit database", -// "category": "Storage space", -// "status": "pass", -// "reported_at": "2025-01-10T05:51:44.4635095Z", -// "originating_endpoint": { -// "name": "Particular.ServiceControl.Audit", -// "host_id": "ff605b55-6fbb-af56-5753-73c1ff73e601", -// "host": "JAYANTHI-LAPTOP" -// } -// }, -// { -// "id": "CustomChecks/5443ee67-c22a-521f-5dc1-b979f831151a", -// "custom_check_id": "Audit Database Index Lag", -// "category": "ServiceControl.Audit Health", -// "status": "pass", -// "reported_at": "2025-01-10T05:51:47.7264687Z", -// "originating_endpoint": { -// "name": "Particular.ServiceControl.Audit", -// "host_id": "ff605b55-6fbb-af56-5753-73c1ff73e601", -// "host": "JAYANTHI-LAPTOP" -// } -// }, -// { -// "id": "CustomChecks/93b62dc3-e1bf-abfd-4268-8d36fef2b0c6", -// "custom_check_id": "ServiceControl database", -// "category": "Storage space", -// "status": "pass", -// "reported_at": "2025-01-10T05:52:03.8512021Z", -// "originating_endpoint": { -// "name": "Particular.ServiceControl", -// "host_id": "9f822d11-b097-a4df-3db5-e069e5d356fe", -// "host": "JAYANTHI-LAPTOP" -// } -// }, -// { -// "id": "CustomChecks/7e09172e-7c59-9a0c-52da-e2ecc1784e15", -// "custom_check_id": "Saga Audit Configuration", -// "category": "Configuration", -// "status": "pass", -// "reported_at": "2025-01-10T05:52:03.850927Z", -// "originating_endpoint": { -// "name": "Particular.ServiceControl", -// "host_id": "9f822d11-b097-a4df-3db5-e069e5d356fe", -// "host": "JAYANTHI-LAPTOP" -// } -// }, -// { -// "id": "CustomChecks/7940dbbf-3019-cb8a-3add-b9ff9c57edb7", -// "custom_check_id": "Error Database Index Errors", -// "category": "ServiceControl Health", -// "status": "pass", -// "reported_at": "2025-01-10T05:52:03.8522051Z", -// "originating_endpoint": { -// "name": "Particular.ServiceControl", -// "host_id": "9f822d11-b097-a4df-3db5-e069e5d356fe", -// "host": "JAYANTHI-LAPTOP" -// } -// }, -// { -// "id": "CustomChecks/4dc66bce-632b-5404-bc3d-e1943d99c301", -// "custom_check_id": "Error Database Index Lag", -// "category": "ServiceControl Health", -// "status": "pass", -// "reported_at": "2025-01-10T05:52:05.8153025Z", -// "originating_endpoint": { -// "name": "Particular.ServiceControl", -// "host_id": "9f822d11-b097-a4df-3db5-e069e5d356fe", -// "host": "JAYANTHI-LAPTOP" -// } -// }, -// { -// "id": "CustomChecks/3eab20ba-3c24-b354-d298-aae5412c0125", -// "custom_check_id": "ServiceControl Remotes", -// "category": "Health", -// "status": "pass", -// "reported_at": "2025-01-10T05:52:10.1360722Z", -// "originating_endpoint": { -// "name": "Particular.ServiceControl", -// "host_id": "9f822d11-b097-a4df-3db5-e069e5d356fe", -// "host": "JAYANTHI-LAPTOP" -// } -// }, -// { -// "id": "CustomChecks/c7011287-308f-c7b7-f50a-cca3c3fe17da", -// "custom_check_id": "ServiceControl Primary Instance", -// "category": "Health", -// "status": "pass", -// "reported_at": "2025-01-10T05:52:18.4970695Z", -// "originating_endpoint": { -// "name": "Particular.ServiceControl", -// "host_id": "9f822d11-b097-a4df-3db5-e069e5d356fe", -// "host": "JAYANTHI-LAPTOP" -// } -// }, -// { -// "id": "CustomChecks/66675ab0-b69a-6a5a-6a56-da7709464fba", -// "custom_check_id": "Message Ingestion Process", -// "category": "ServiceControl Health", -// "status": "pass", -// "reported_at": "2025-01-10T05:52:29.398929Z", -// "originating_endpoint": { -// "name": "Particular.ServiceControl", -// "host_id": "9f822d11-b097-a4df-3db5-e069e5d356fe", -// "host": "JAYANTHI-LAPTOP" -// } -// }, -// { -// "id": "CustomChecks/418dafe7-1dd2-886b-65d1-2b3e71e4feb2", -// "custom_check_id": "Error Message Ingestion Process", -// "category": "ServiceControl Health", -// "status": "pass", -// "reported_at": "2025-01-10T05:52:29.3984912Z", -// "originating_endpoint": { -// "name": "Particular.ServiceControl", -// "host_id": "9f822d11-b097-a4df-3db5-e069e5d356fe", -// "host": "JAYANTHI-LAPTOP" -// } -// }, -// { -// "id": "CustomChecks/a406f1a7-412c-dd2c-7f90-9aa32da0698b", -// "custom_check_id": "Audit Message Ingestion Process", -// "category": "ServiceControl Health", -// "status": "pass", -// "reported_at": "2025-01-10T05:52:31.4929675Z", -// "originating_endpoint": { -// "name": "Particular.ServiceControl.Audit", -// "host_id": "ff605b55-6fbb-af56-5753-73c1ff73e601", -// "host": "JAYANTHI-LAPTOP" -// } -// } -// ] diff --git a/src/Frontend/test/preconditions/index.ts b/src/Frontend/test/preconditions/index.ts index 0c20e7a9f..b126efdb6 100644 --- a/src/Frontend/test/preconditions/index.ts +++ b/src/Frontend/test/preconditions/index.ts @@ -5,7 +5,9 @@ export { hasServiceControlMonitoringInstanceUrl } from "../preconditions/hasServ export { hasUpToDateServiceControl } from "../preconditions/hasUpToDateServiceControl"; export { hasUpToDateServicePulse } from "../preconditions/hasUpToDateServicePulse"; export { errorsDefaultHandler } from "../preconditions/hasNoErrors"; -export { hasNoFailingCustomChecks } from "../preconditions/hasNoFailingCustomChecks"; +export { hasCustomChecksEmpty } from "./hasCustomChecksEmpty"; +export { hasCustomChecksFailing } from "./hasCustomChecksFailing"; +export { hasCustomChecksPassing } from "./hasCustomChecksPassing"; export { hasNoDisconnectedEndpoints } from "../preconditions/hasNoDisconnectedEndpoints"; export { hasNoMonitoredEndpoints, hasMonitoredEndpointsList, monitoredEndpointsNamed } from "../preconditions/hasMonitoredEndpoints"; export { hasEventLogItems } from "../preconditions/hasEventLogItems"; diff --git a/src/Frontend/test/preconditions/serviceControlWithMonitoring.ts b/src/Frontend/test/preconditions/serviceControlWithMonitoring.ts index 588c7ea40..f5cceb237 100644 --- a/src/Frontend/test/preconditions/serviceControlWithMonitoring.ts +++ b/src/Frontend/test/preconditions/serviceControlWithMonitoring.ts @@ -23,7 +23,7 @@ export const serviceControlWithMonitoring = async ({ driver }: SetupFactoryOptio await driver.setUp(precondition.errorsDefaultHandler); //http://localhost:33333/api/customchecks - await driver.setUp(precondition.hasNoFailingCustomChecks); + await driver.setUp(precondition.hasCustomChecksEmpty); //http://localhost:33633/monitored-endpoints/disconnected await driver.setUp(precondition.hasNoDisconnectedEndpoints); diff --git a/src/Frontend/test/specs/customchecks/questions/customChecksMessage.ts b/src/Frontend/test/specs/customchecks/questions/customChecksMessage.ts new file mode 100644 index 000000000..46d8bc68f --- /dev/null +++ b/src/Frontend/test/specs/customchecks/questions/customChecksMessage.ts @@ -0,0 +1,6 @@ +import { screen } from "@testing-library/vue"; + +export async function customChecksMessage() { + const txtMessage = await screen.findByRole("heading", { name: "customcheck-message" }); + return txtMessage.innerHTML; +} diff --git a/src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts b/src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts index ea3ff2892..18c2635d3 100644 --- a/src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts +++ b/src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts @@ -1,21 +1,51 @@ import { test, describe } from "../../drivers/vitest/driver"; - +import { expect } from "vitest"; +import * as precondition from "../../preconditions"; +import { customChecksMessage } from "./questions/customChecksMessage"; +import { waitFor } from "@testing-library/vue"; +// import NoData from "../../../src/components/NoData.vue"; +// import { screen } from "@testing-library/vue"; +// import { render } from "@component-test-utils"; describe("FEATURE: No data", () => { - describe("RULE: When there is no data to show a message should be displayed ", () => { - test.todo("EXAMPLE: 'No failed custom checks' should be displayed when there are no custom checks"); - - /* SCENARIO + /* SCENARIO Given there are no custom checks When navigating to the custom checks tab Then a message is shown "No failed custom checks" */ - - test.todo("EXAMPLE: 'No failed custom checks' should be displayed when all custom checks are in a success state"); - /* SCENARIO + describe("RULE: When there is no data to show a message should be displayed ", () => { + test("EXAMPLE: 'No failed custom checks' should be displayed when there are no custom checks", async ({ driver }) => { + //Arrange + await driver.setUp(precondition.hasCustomChecksEmpty); + //Act + await driver.goTo("/custom-checks"); + //Expect + //render(NoData, { props: { message: "No failed custom checks" } }); + //expect(await screen.findByText("No failed custom checks")).toBeVisible(); + // expect(await customChecksMessage()).toBe("No failed custom checks"); + await waitFor(async () => { + expect(await customChecksMessage()).toBe("No failed custom checks"); + }); + }); + }); + /* SCENARIO Given there are custom checks And all custom checks are in a success state When navigating to the custom checks tab The a message is shown "No failed custom checks" */ + describe("RULE: When there is no data to show a message should be displayed ", () => { + test("EXAMPLE: 'No failed custom checks' should be displayed when all custom checks are in a success state", async ({ driver }) => { + //Arrange + await driver.setUp(precondition.hasCustomChecksPassing); + //Act + await driver.goTo("/custom-checks"); + //Expect + //render(NoData, { props: { message: "No failed custom checks" } }); + // expect(await screen.findByText("No failed custom checks")).toBeVisible(); + //expect(await customChecksMessage()).toBe("No failed custom checks"); + await waitFor(async () => { + expect(await customChecksMessage()).toBe("No failed custom checks"); + }); + }); }); }); From 1d62fbed32fd649b563dd9402be61dbcc2ab30b7 Mon Sep 17 00:00:00 2001 From: Jayanthi Date: Sun, 19 Jan 2025 22:22:53 -0800 Subject: [PATCH 16/30] add driver set up for servicecontrolwithmonitoring to fix the tests --- .../preconditions/hasCustomChecksFailing.ts | 16 +++++----- .../preconditions/hasCustomChecksPassing.ts | 26 ++++++++-------- .../questions/customChecksMessage.ts | 2 +- .../customchecks/viewing-no-data.spec.ts | 30 ++++++++----------- 4 files changed, 35 insertions(+), 39 deletions(-) diff --git a/src/Frontend/test/preconditions/hasCustomChecksFailing.ts b/src/Frontend/test/preconditions/hasCustomChecksFailing.ts index 74cddb7c2..3da3f249a 100644 --- a/src/Frontend/test/preconditions/hasCustomChecksFailing.ts +++ b/src/Frontend/test/preconditions/hasCustomChecksFailing.ts @@ -15,7 +15,7 @@ export const hasCustomChecksFailing = ({ driver }: SetupFactoryOptions) => { originating_endpoint: { name: "Particular.ServiceControl.Audit", host_id: "ff605b55-6fbb-af56-5753-73c1ff73e601", - host: "COMPUSA-LAPTOP", + host: "COMPUSA", }, }, { @@ -28,7 +28,7 @@ export const hasCustomChecksFailing = ({ driver }: SetupFactoryOptions) => { originating_endpoint: { name: "Particular.ServiceControl", host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", - host: "COMPUSA-LAPTOP", + host: "COMPUSA", }, }, { @@ -41,7 +41,7 @@ export const hasCustomChecksFailing = ({ driver }: SetupFactoryOptions) => { originating_endpoint: { name: "Particular.ServiceControl", host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", - host: "COMPUSA-LAPTOP", + host: "COMPUSA", }, }, { @@ -54,7 +54,7 @@ export const hasCustomChecksFailing = ({ driver }: SetupFactoryOptions) => { originating_endpoint: { name: "Particular.ServiceControl", host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", - host: "COMPUSA-LAPTOP", + host: "COMPUSA", }, }, { @@ -67,7 +67,7 @@ export const hasCustomChecksFailing = ({ driver }: SetupFactoryOptions) => { originating_endpoint: { name: "Particular.ServiceControl", host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", - host: "COMPUSA-LAPTOP", + host: "COMPUSA", }, }, { @@ -80,7 +80,7 @@ export const hasCustomChecksFailing = ({ driver }: SetupFactoryOptions) => { originating_endpoint: { name: "Particular.ServiceControl", host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", - host: "COMPUSA-LAPTOP", + host: "COMPUSA", }, }, { @@ -93,7 +93,7 @@ export const hasCustomChecksFailing = ({ driver }: SetupFactoryOptions) => { originating_endpoint: { name: "Particular.ServiceControl", host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", - host: "COMPUSA-LAPTOP", + host: "COMPUSA", }, }, { @@ -106,7 +106,7 @@ export const hasCustomChecksFailing = ({ driver }: SetupFactoryOptions) => { originating_endpoint: { name: "Particular.ServiceControl.Audit", host_id: "ff605b55-6fbb-af56-5753-73c1ff73e601", - host: "COMPUSA-LAPTOP", + host: "COMPUSA", }, }, ], diff --git a/src/Frontend/test/preconditions/hasCustomChecksPassing.ts b/src/Frontend/test/preconditions/hasCustomChecksPassing.ts index c65d57c44..0d6bf6d2f 100644 --- a/src/Frontend/test/preconditions/hasCustomChecksPassing.ts +++ b/src/Frontend/test/preconditions/hasCustomChecksPassing.ts @@ -14,7 +14,7 @@ export const hasCustomChecksPassing = ({ driver }: SetupFactoryOptions) => { originating_endpoint: { name: "Particular.ServiceControl.Audit", host_id: "ff605b55-6fbb-af56-5753-73c1ff73e601", - host: "COMPUSA-LAPTOP", + host: "COMPUSA", }, }, { @@ -26,7 +26,7 @@ export const hasCustomChecksPassing = ({ driver }: SetupFactoryOptions) => { originating_endpoint: { name: "Particular.ServiceControl", host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", - host: "COMPUSA-LAPTOP", + host: "COMPUSA", }, }, { @@ -38,7 +38,7 @@ export const hasCustomChecksPassing = ({ driver }: SetupFactoryOptions) => { originating_endpoint: { name: "Particular.ServiceControl.Audit", host_id: "ff605b55-6fbb-af56-5753-73c1ff73e601", - host: "COMPUSA-LAPTOP", + host: "COMPUSA", }, }, { @@ -50,7 +50,7 @@ export const hasCustomChecksPassing = ({ driver }: SetupFactoryOptions) => { originating_endpoint: { name: "Particular.ServiceControl.Audit", host_id: "ff605b55-6fbb-af56-5753-73c1ff73e601", - host: "COMPUSA-LAPTOP", + host: "COMPUSA", }, }, { @@ -62,7 +62,7 @@ export const hasCustomChecksPassing = ({ driver }: SetupFactoryOptions) => { originating_endpoint: { name: "Particular.ServiceControl", host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", - host: "COMPUSA-LAPTOP", + host: "COMPUSA", }, }, { @@ -74,7 +74,7 @@ export const hasCustomChecksPassing = ({ driver }: SetupFactoryOptions) => { originating_endpoint: { name: "Particular.ServiceControl", host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", - host: "COMPUSA-LAPTOP", + host: "COMPUSA", }, }, { @@ -86,7 +86,7 @@ export const hasCustomChecksPassing = ({ driver }: SetupFactoryOptions) => { originating_endpoint: { name: "Particular.ServiceControl", host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", - host: "COMPUSA-LAPTOP", + host: "COMPUSA", }, }, { @@ -98,7 +98,7 @@ export const hasCustomChecksPassing = ({ driver }: SetupFactoryOptions) => { originating_endpoint: { name: "Particular.ServiceControl", host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", - host: "COMPUSA-LAPTOP", + host: "COMPUSA", }, }, { @@ -110,7 +110,7 @@ export const hasCustomChecksPassing = ({ driver }: SetupFactoryOptions) => { originating_endpoint: { name: "Particular.ServiceControl", host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", - host: "COMPUSA-LAPTOP", + host: "COMPUSA", }, }, { @@ -122,7 +122,7 @@ export const hasCustomChecksPassing = ({ driver }: SetupFactoryOptions) => { originating_endpoint: { name: "Particular.ServiceControl", host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", - host: "COMPUSA-LAPTOP", + host: "COMPUSA", }, }, { @@ -134,7 +134,7 @@ export const hasCustomChecksPassing = ({ driver }: SetupFactoryOptions) => { originating_endpoint: { name: "Particular.ServiceControl", host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", - host: "COMPUSA-LAPTOP", + host: "COMPUSA", }, }, { @@ -146,7 +146,7 @@ export const hasCustomChecksPassing = ({ driver }: SetupFactoryOptions) => { originating_endpoint: { name: "Particular.ServiceControl", host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", - host: "COMPUSA-LAPTOP", + host: "COMPUSA", }, }, { @@ -158,7 +158,7 @@ export const hasCustomChecksPassing = ({ driver }: SetupFactoryOptions) => { originating_endpoint: { name: "Particular.ServiceControl.Audit", host_id: "ff605b55-6fbb-af56-5753-73c1ff73e601", - host: "COMPUSA-LAPTOP", + host: "COMPUSA", }, }, ], diff --git a/src/Frontend/test/specs/customchecks/questions/customChecksMessage.ts b/src/Frontend/test/specs/customchecks/questions/customChecksMessage.ts index 46d8bc68f..398dab07d 100644 --- a/src/Frontend/test/specs/customchecks/questions/customChecksMessage.ts +++ b/src/Frontend/test/specs/customchecks/questions/customChecksMessage.ts @@ -2,5 +2,5 @@ import { screen } from "@testing-library/vue"; export async function customChecksMessage() { const txtMessage = await screen.findByRole("heading", { name: "customcheck-message" }); - return txtMessage.innerHTML; + return txtMessage.textContent?.trim(); } diff --git a/src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts b/src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts index 18c2635d3..d033cc772 100644 --- a/src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts +++ b/src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts @@ -3,46 +3,42 @@ import { expect } from "vitest"; import * as precondition from "../../preconditions"; import { customChecksMessage } from "./questions/customChecksMessage"; import { waitFor } from "@testing-library/vue"; -// import NoData from "../../../src/components/NoData.vue"; -// import { screen } from "@testing-library/vue"; -// import { render } from "@component-test-utils"; + describe("FEATURE: No data", () => { - /* SCENARIO + describe("RULE: When there is no data to show a message should be displayed ", () => { + /* SCENARIO Given there are no custom checks When navigating to the custom checks tab Then a message is shown "No failed custom checks" */ - describe("RULE: When there is no data to show a message should be displayed ", () => { test("EXAMPLE: 'No failed custom checks' should be displayed when there are no custom checks", async ({ driver }) => { //Arrange + await driver.setUp(precondition.serviceControlWithMonitoring); + // given that the custom check list is empty await driver.setUp(precondition.hasCustomChecksEmpty); - //Act + + //Act - When navigating to the custom checks tab await driver.goTo("/custom-checks"); //Expect - //render(NoData, { props: { message: "No failed custom checks" } }); - //expect(await screen.findByText("No failed custom checks")).toBeVisible(); - // expect(await customChecksMessage()).toBe("No failed custom checks"); await waitFor(async () => { expect(await customChecksMessage()).toBe("No failed custom checks"); }); }); - }); - /* SCENARIO + /* SCENARIO Given there are custom checks And all custom checks are in a success state When navigating to the custom checks tab - The a message is shown "No failed custom checks" + Then a message is shown "No failed custom checks" */ - describe("RULE: When there is no data to show a message should be displayed ", () => { test("EXAMPLE: 'No failed custom checks' should be displayed when all custom checks are in a success state", async ({ driver }) => { //Arrange + await driver.setUp(precondition.serviceControlWithMonitoring); + // given that the custom check list is not empty and status of all checks are passing await driver.setUp(precondition.hasCustomChecksPassing); - //Act + + //Act - When navigating to the custom checks tab await driver.goTo("/custom-checks"); //Expect - //render(NoData, { props: { message: "No failed custom checks" } }); - // expect(await screen.findByText("No failed custom checks")).toBeVisible(); - //expect(await customChecksMessage()).toBe("No failed custom checks"); await waitFor(async () => { expect(await customChecksMessage()).toBe("No failed custom checks"); }); From 59919548a4a4c76c65600d508557c16cd70facf4 Mon Sep 17 00:00:00 2001 From: Jayanthi Date: Sun, 19 Jan 2025 22:54:23 -0800 Subject: [PATCH 17/30] refactor files and code --- ...CustomChecksPassing.ts => customChecks.ts} | 129 +++++++++++++++++- .../preconditions/hasCustomChecksEmpty.ts | 14 -- .../preconditions/hasCustomChecksFailing.ts | 117 ---------------- src/Frontend/test/preconditions/index.ts | 4 +- 4 files changed, 129 insertions(+), 135 deletions(-) rename src/Frontend/test/preconditions/{hasCustomChecksPassing.ts => customChecks.ts} (56%) delete mode 100644 src/Frontend/test/preconditions/hasCustomChecksEmpty.ts delete mode 100644 src/Frontend/test/preconditions/hasCustomChecksFailing.ts diff --git a/src/Frontend/test/preconditions/hasCustomChecksPassing.ts b/src/Frontend/test/preconditions/customChecks.ts similarity index 56% rename from src/Frontend/test/preconditions/hasCustomChecksPassing.ts rename to src/Frontend/test/preconditions/customChecks.ts index 0d6bf6d2f..90092e160 100644 --- a/src/Frontend/test/preconditions/hasCustomChecksPassing.ts +++ b/src/Frontend/test/preconditions/customChecks.ts @@ -1,5 +1,132 @@ -import CustomCheck from "@/resources/CustomCheck"; import { SetupFactoryOptions } from "../driver"; +import CustomCheck from "@/resources/CustomCheck"; + +const content = JSON.stringify([]); + +export const hasCustomChecksEmpty = ({ driver }: SetupFactoryOptions) => { + const serviceControlInstanceUrl = window.defaultConfig.service_control_url; + driver.mockEndpoint(`${serviceControlInstanceUrl}customchecks`, { + body: content, + headers: { + "Total-Count": "0", //count of failing custom checks + }, + }); +}; + +export const hasCustomChecksFailing = ({ driver }: SetupFactoryOptions) => { + const serviceControlInstanceUrl = window.defaultConfig.service_control_url; + driver.mockEndpoint(`${serviceControlInstanceUrl}customchecks`, { + body: [ + { + id: "CustomChecks/6131fa95-9414-1898-9c83-c5b18587945b", + custom_check_id: "Audit Message Ingestion", + category: "ServiceControl.Audit Health", + status: "Fail", + failure_reason: "I dont know the reason", + reported_at: "2025-01-10T05:06:30.4074087Z", + originating_endpoint: { + name: "Particular.ServiceControl.Audit", + host_id: "ff605b55-6fbb-af56-5753-73c1ff73e601", + host: "COMPUSA", + }, + }, + { + id: "CustomChecks/36752f09-8a72-752e-e48f-6c378329d43b", + custom_check_id: "Error Message Ingestion", + category: "ServiceControl Health", + status: "Fail", + failure_reason: "I am unable to ingest error messages", + reported_at: "2025-01-10T05:42:00.531067Z", + originating_endpoint: { + name: "Particular.ServiceControl", + host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", + host: "COMPUSA", + }, + }, + { + id: "CustomChecks/93b62dc3-e1bf-abfd-4268-8d36fef2b0c6", + custom_check_id: "ServiceControl database", + category: "Storage space", + status: "Fail", + failure_reason: "I dont have enough storage", + reported_at: "2025-01-10T05:52:03.8512021Z", + originating_endpoint: { + name: "Particular.ServiceControl", + host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", + host: "COMPUSA", + }, + }, + { + id: "CustomChecks/7e09172e-7c59-9a0c-52da-e2ecc1784e15", + custom_check_id: "Saga Audit Configuration", + category: "Configuration", + status: "Fail", + failure_reason: "There is something wrong in Saga Audit configuration", + reported_at: "2025-01-10T05:52:03.850927Z", + originating_endpoint: { + name: "Particular.ServiceControl", + host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", + host: "COMPUSA", + }, + }, + { + id: "CustomChecks/4dc66bce-632b-5404-bc3d-e1943d99c301", + custom_check_id: "Error Database Index Lag", + category: "ServiceControl Health", + status: "Fail", + failure_reason: "There is an index lag", + reported_at: "2025-01-10T05:52:05.8153025Z", + originating_endpoint: { + name: "Particular.ServiceControl", + host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", + host: "COMPUSA", + }, + }, + { + id: "CustomChecks/66675ab0-b69a-6a5a-6a56-da7709464fba", + custom_check_id: "Message Ingestion Process", + category: "ServiceControl Health", + status: "Fail", + failure_reason: "Unable to ingest messages", + reported_at: "2025-01-10T05:52:29.398929Z", + originating_endpoint: { + name: "Particular.ServiceControl", + host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", + host: "COMPUSA", + }, + }, + { + id: "CustomChecks/418dafe7-1dd2-886b-65d1-2b3e71e4feb2", + custom_check_id: "Error Message Ingestion Process", + category: "ServiceControl Health", + status: "Fail", + failure_reason: "I dont know the reason", + reported_at: "2025-01-10T05:52:29.3984912Z", + originating_endpoint: { + name: "Particular.ServiceControl", + host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", + host: "COMPUSA", + }, + }, + { + id: "CustomChecks/a406f1a7-412c-dd2c-7f90-9aa32da0698b", + custom_check_id: "Audit Message Ingestion Process", + category: "ServiceControl Health", + status: "Fail", + failure_reason: "I dont know the reason for Audit Message Ingestion failure", + reported_at: "2025-01-10T05:52:31.4929675Z", + originating_endpoint: { + name: "Particular.ServiceControl.Audit", + host_id: "ff605b55-6fbb-af56-5753-73c1ff73e601", + host: "COMPUSA", + }, + }, + ], + headers: { + "Total-Count": "8", //count of failing custom checks + }, + }); +}; export const hasCustomChecksPassing = ({ driver }: SetupFactoryOptions) => { const serviceControlInstanceUrl = window.defaultConfig.service_control_url; diff --git a/src/Frontend/test/preconditions/hasCustomChecksEmpty.ts b/src/Frontend/test/preconditions/hasCustomChecksEmpty.ts deleted file mode 100644 index 070a79c86..000000000 --- a/src/Frontend/test/preconditions/hasCustomChecksEmpty.ts +++ /dev/null @@ -1,14 +0,0 @@ -//import CustomCheck from "@/resources/CustomCheck"; -import { SetupFactoryOptions } from "../driver"; - -const content = JSON.stringify([]); - -export const hasCustomChecksEmpty = ({ driver }: SetupFactoryOptions) => { - const serviceControlInstanceUrl = window.defaultConfig.service_control_url; - driver.mockEndpoint(`${serviceControlInstanceUrl}customchecks`, { - body: content, - headers: { - "Total-Count": "0", //count of failing custom checks - }, - }); -}; diff --git a/src/Frontend/test/preconditions/hasCustomChecksFailing.ts b/src/Frontend/test/preconditions/hasCustomChecksFailing.ts deleted file mode 100644 index 3da3f249a..000000000 --- a/src/Frontend/test/preconditions/hasCustomChecksFailing.ts +++ /dev/null @@ -1,117 +0,0 @@ -import CustomCheck from "@/resources/CustomCheck"; -import { SetupFactoryOptions } from "../driver"; - -export const hasCustomChecksFailing = ({ driver }: SetupFactoryOptions) => { - const serviceControlInstanceUrl = window.defaultConfig.service_control_url; - driver.mockEndpoint(`${serviceControlInstanceUrl}customchecks`, { - body: [ - { - id: "CustomChecks/6131fa95-9414-1898-9c83-c5b18587945b", - custom_check_id: "Audit Message Ingestion", - category: "ServiceControl.Audit Health", - status: "Fail", - failure_reason: "I dont know the reason", - reported_at: "2025-01-10T05:06:30.4074087Z", - originating_endpoint: { - name: "Particular.ServiceControl.Audit", - host_id: "ff605b55-6fbb-af56-5753-73c1ff73e601", - host: "COMPUSA", - }, - }, - { - id: "CustomChecks/36752f09-8a72-752e-e48f-6c378329d43b", - custom_check_id: "Error Message Ingestion", - category: "ServiceControl Health", - status: "Fail", - failure_reason: "I am unable to ingest error messages", - reported_at: "2025-01-10T05:42:00.531067Z", - originating_endpoint: { - name: "Particular.ServiceControl", - host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", - host: "COMPUSA", - }, - }, - { - id: "CustomChecks/93b62dc3-e1bf-abfd-4268-8d36fef2b0c6", - custom_check_id: "ServiceControl database", - category: "Storage space", - status: "Fail", - failure_reason: "I dont have enough storage", - reported_at: "2025-01-10T05:52:03.8512021Z", - originating_endpoint: { - name: "Particular.ServiceControl", - host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", - host: "COMPUSA", - }, - }, - { - id: "CustomChecks/7e09172e-7c59-9a0c-52da-e2ecc1784e15", - custom_check_id: "Saga Audit Configuration", - category: "Configuration", - status: "Fail", - failure_reason: "There is something wrong in Saga Audit configuration", - reported_at: "2025-01-10T05:52:03.850927Z", - originating_endpoint: { - name: "Particular.ServiceControl", - host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", - host: "COMPUSA", - }, - }, - { - id: "CustomChecks/4dc66bce-632b-5404-bc3d-e1943d99c301", - custom_check_id: "Error Database Index Lag", - category: "ServiceControl Health", - status: "Fail", - failure_reason: "There is an index lag", - reported_at: "2025-01-10T05:52:05.8153025Z", - originating_endpoint: { - name: "Particular.ServiceControl", - host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", - host: "COMPUSA", - }, - }, - { - id: "CustomChecks/66675ab0-b69a-6a5a-6a56-da7709464fba", - custom_check_id: "Message Ingestion Process", - category: "ServiceControl Health", - status: "Fail", - failure_reason: "Unable to ingest messages", - reported_at: "2025-01-10T05:52:29.398929Z", - originating_endpoint: { - name: "Particular.ServiceControl", - host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", - host: "COMPUSA", - }, - }, - { - id: "CustomChecks/418dafe7-1dd2-886b-65d1-2b3e71e4feb2", - custom_check_id: "Error Message Ingestion Process", - category: "ServiceControl Health", - status: "Fail", - failure_reason: "I dont know the reason", - reported_at: "2025-01-10T05:52:29.3984912Z", - originating_endpoint: { - name: "Particular.ServiceControl", - host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", - host: "COMPUSA", - }, - }, - { - id: "CustomChecks/a406f1a7-412c-dd2c-7f90-9aa32da0698b", - custom_check_id: "Audit Message Ingestion Process", - category: "ServiceControl Health", - status: "Fail", - failure_reason: "I dont know the reason for Audit Message Ingestion failure", - reported_at: "2025-01-10T05:52:31.4929675Z", - originating_endpoint: { - name: "Particular.ServiceControl.Audit", - host_id: "ff605b55-6fbb-af56-5753-73c1ff73e601", - host: "COMPUSA", - }, - }, - ], - headers: { - "Total-Count": "8", //count of failing custom checks - }, - }); -}; diff --git a/src/Frontend/test/preconditions/index.ts b/src/Frontend/test/preconditions/index.ts index b126efdb6..5ae8f6370 100644 --- a/src/Frontend/test/preconditions/index.ts +++ b/src/Frontend/test/preconditions/index.ts @@ -5,9 +5,7 @@ export { hasServiceControlMonitoringInstanceUrl } from "../preconditions/hasServ export { hasUpToDateServiceControl } from "../preconditions/hasUpToDateServiceControl"; export { hasUpToDateServicePulse } from "../preconditions/hasUpToDateServicePulse"; export { errorsDefaultHandler } from "../preconditions/hasNoErrors"; -export { hasCustomChecksEmpty } from "./hasCustomChecksEmpty"; -export { hasCustomChecksFailing } from "./hasCustomChecksFailing"; -export { hasCustomChecksPassing } from "./hasCustomChecksPassing"; +export { hasCustomChecksEmpty, hasCustomChecksFailing, hasCustomChecksPassing } from "./customChecks"; export { hasNoDisconnectedEndpoints } from "../preconditions/hasNoDisconnectedEndpoints"; export { hasNoMonitoredEndpoints, hasMonitoredEndpointsList, monitoredEndpointsNamed } from "../preconditions/hasMonitoredEndpoints"; export { hasEventLogItems } from "../preconditions/hasEventLogItems"; From a62462446c720457d6e396f0294b3702637a7b25 Mon Sep 17 00:00:00 2001 From: Jayanthi Date: Mon, 20 Jan 2025 00:07:26 -0800 Subject: [PATCH 18/30] add a template for custom check items and use it for tests --- .../test/mocks/custom-checks-template.ts | 108 +++++++ .../test/preconditions/customChecks.ts | 278 +----------------- 2 files changed, 117 insertions(+), 269 deletions(-) create mode 100644 src/Frontend/test/mocks/custom-checks-template.ts diff --git a/src/Frontend/test/mocks/custom-checks-template.ts b/src/Frontend/test/mocks/custom-checks-template.ts new file mode 100644 index 000000000..542e4b179 --- /dev/null +++ b/src/Frontend/test/mocks/custom-checks-template.ts @@ -0,0 +1,108 @@ +import CustomCheck, { Status } from "@/resources/CustomCheck"; + +export const customCheckItems: CustomCheck[] = [ + { + id: "CustomChecks/6131fa95-9414-1898-9c83-c5b18587945b", + custom_check_id: "Audit Message Ingestion", + category: "ServiceControl.Audit Health", + status: Status.Fail, + failure_reason: "I dont know the reason", + reported_at: "2025-01-10T05:06:30.4074087Z", + originating_endpoint: { + name: "Particular.ServiceControl.Audit", + host_id: "ff605b55-6fbb-af56-5753-73c1ff73e601", + host: "COMPUSA", + }, + }, + { + id: "CustomChecks/36752f09-8a72-752e-e48f-6c378329d43b", + custom_check_id: "Error Message Ingestion", + category: "ServiceControl Health", + status: Status.Fail, + failure_reason: "I am unable to ingest error messages", + reported_at: "2025-01-10T05:42:00.531067Z", + originating_endpoint: { + name: "Particular.ServiceControl", + host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", + host: "COMPUSA", + }, + }, + { + id: "CustomChecks/93b62dc3-e1bf-abfd-4268-8d36fef2b0c6", + custom_check_id: "ServiceControl database", + category: "Storage space", + status: Status.Pass, + failure_reason: "", + reported_at: "2025-01-10T05:52:03.8512021Z", + originating_endpoint: { + name: "Particular.ServiceControl", + host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", + host: "COMPUSA", + }, + }, + { + id: "CustomChecks/7e09172e-7c59-9a0c-52da-e2ecc1784e15", + custom_check_id: "Saga Audit Configuration", + category: "Configuration", + status: Status.Fail, + failure_reason: "There is something wrong in Saga Audit configuration", + reported_at: "2025-01-10T05:52:03.850927Z", + originating_endpoint: { + name: "Particular.ServiceControl", + host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", + host: "COMPUSA", + }, + }, + { + id: "CustomChecks/4dc66bce-632b-5404-bc3d-e1943d99c301", + custom_check_id: "Error Database Index Lag", + category: "ServiceControl Health", + status: Status.Pass, + failure_reason: "", + reported_at: "2025-01-10T05:52:05.8153025Z", + originating_endpoint: { + name: "Particular.ServiceControl", + host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", + host: "COMPUSA", + }, + }, + { + id: "CustomChecks/66675ab0-b69a-6a5a-6a56-da7709464fba", + custom_check_id: "Message Ingestion Process", + category: "ServiceControl Health", + status: Status.Fail, + failure_reason: "Unable to ingest messages", + reported_at: "2025-01-10T05:52:29.398929Z", + originating_endpoint: { + name: "Particular.ServiceControl", + host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", + host: "COMPUSA", + }, + }, + { + id: "CustomChecks/418dafe7-1dd2-886b-65d1-2b3e71e4feb2", + custom_check_id: "Error Message Ingestion Process", + category: "ServiceControl Health", + status: Status.Fail, + failure_reason: "No idea whats going on here", + reported_at: "2025-01-10T05:52:29.3984912Z", + originating_endpoint: { + name: "Particular.ServiceControl", + host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", + host: "COMPUSA", + }, + }, + { + id: "CustomChecks/a406f1a7-412c-dd2c-7f90-9aa32da0698b", + custom_check_id: "Audit Message Ingestion Process", + category: "ServiceControl Health", + status: Status.Pass, + failure_reason: "", + reported_at: "2025-01-10T05:52:31.4929675Z", + originating_endpoint: { + name: "Particular.ServiceControl.Audit", + host_id: "ff605b55-6fbb-af56-5753-73c1ff73e601", + host: "COMPUSA", + }, + }, +]; diff --git a/src/Frontend/test/preconditions/customChecks.ts b/src/Frontend/test/preconditions/customChecks.ts index 90092e160..f2fc393f6 100644 --- a/src/Frontend/test/preconditions/customChecks.ts +++ b/src/Frontend/test/preconditions/customChecks.ts @@ -1,7 +1,11 @@ import { SetupFactoryOptions } from "../driver"; -import CustomCheck from "@/resources/CustomCheck"; +import { customCheckItems } from "../mocks/custom-checks-template"; const content = JSON.stringify([]); +const failedCustomCheckItems = customCheckItems.filter((check) => check.status === "Fail"); +const failedCustomCheckCount = failedCustomCheckItems.length.toString(); +const passedCustomCheckItems = customCheckItems.filter((check) => check.status === "Pass"); +const passedCustomCheckCount = passedCustomCheckItems.length.toString(); export const hasCustomChecksEmpty = ({ driver }: SetupFactoryOptions) => { const serviceControlInstanceUrl = window.defaultConfig.service_control_url; @@ -12,285 +16,21 @@ export const hasCustomChecksEmpty = ({ driver }: SetupFactoryOptions) => { }, }); }; - export const hasCustomChecksFailing = ({ driver }: SetupFactoryOptions) => { const serviceControlInstanceUrl = window.defaultConfig.service_control_url; driver.mockEndpoint(`${serviceControlInstanceUrl}customchecks`, { - body: [ - { - id: "CustomChecks/6131fa95-9414-1898-9c83-c5b18587945b", - custom_check_id: "Audit Message Ingestion", - category: "ServiceControl.Audit Health", - status: "Fail", - failure_reason: "I dont know the reason", - reported_at: "2025-01-10T05:06:30.4074087Z", - originating_endpoint: { - name: "Particular.ServiceControl.Audit", - host_id: "ff605b55-6fbb-af56-5753-73c1ff73e601", - host: "COMPUSA", - }, - }, - { - id: "CustomChecks/36752f09-8a72-752e-e48f-6c378329d43b", - custom_check_id: "Error Message Ingestion", - category: "ServiceControl Health", - status: "Fail", - failure_reason: "I am unable to ingest error messages", - reported_at: "2025-01-10T05:42:00.531067Z", - originating_endpoint: { - name: "Particular.ServiceControl", - host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", - host: "COMPUSA", - }, - }, - { - id: "CustomChecks/93b62dc3-e1bf-abfd-4268-8d36fef2b0c6", - custom_check_id: "ServiceControl database", - category: "Storage space", - status: "Fail", - failure_reason: "I dont have enough storage", - reported_at: "2025-01-10T05:52:03.8512021Z", - originating_endpoint: { - name: "Particular.ServiceControl", - host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", - host: "COMPUSA", - }, - }, - { - id: "CustomChecks/7e09172e-7c59-9a0c-52da-e2ecc1784e15", - custom_check_id: "Saga Audit Configuration", - category: "Configuration", - status: "Fail", - failure_reason: "There is something wrong in Saga Audit configuration", - reported_at: "2025-01-10T05:52:03.850927Z", - originating_endpoint: { - name: "Particular.ServiceControl", - host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", - host: "COMPUSA", - }, - }, - { - id: "CustomChecks/4dc66bce-632b-5404-bc3d-e1943d99c301", - custom_check_id: "Error Database Index Lag", - category: "ServiceControl Health", - status: "Fail", - failure_reason: "There is an index lag", - reported_at: "2025-01-10T05:52:05.8153025Z", - originating_endpoint: { - name: "Particular.ServiceControl", - host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", - host: "COMPUSA", - }, - }, - { - id: "CustomChecks/66675ab0-b69a-6a5a-6a56-da7709464fba", - custom_check_id: "Message Ingestion Process", - category: "ServiceControl Health", - status: "Fail", - failure_reason: "Unable to ingest messages", - reported_at: "2025-01-10T05:52:29.398929Z", - originating_endpoint: { - name: "Particular.ServiceControl", - host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", - host: "COMPUSA", - }, - }, - { - id: "CustomChecks/418dafe7-1dd2-886b-65d1-2b3e71e4feb2", - custom_check_id: "Error Message Ingestion Process", - category: "ServiceControl Health", - status: "Fail", - failure_reason: "I dont know the reason", - reported_at: "2025-01-10T05:52:29.3984912Z", - originating_endpoint: { - name: "Particular.ServiceControl", - host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", - host: "COMPUSA", - }, - }, - { - id: "CustomChecks/a406f1a7-412c-dd2c-7f90-9aa32da0698b", - custom_check_id: "Audit Message Ingestion Process", - category: "ServiceControl Health", - status: "Fail", - failure_reason: "I dont know the reason for Audit Message Ingestion failure", - reported_at: "2025-01-10T05:52:31.4929675Z", - originating_endpoint: { - name: "Particular.ServiceControl.Audit", - host_id: "ff605b55-6fbb-af56-5753-73c1ff73e601", - host: "COMPUSA", - }, - }, - ], + body: failedCustomCheckItems, headers: { - "Total-Count": "8", //count of failing custom checks + "Total-Count": failedCustomCheckCount, //count of failing custom checks }, }); }; - export const hasCustomChecksPassing = ({ driver }: SetupFactoryOptions) => { const serviceControlInstanceUrl = window.defaultConfig.service_control_url; driver.mockEndpoint(`${serviceControlInstanceUrl}customchecks`, { - body: [ - { - id: "CustomChecks/6131fa95-9414-1898-9c83-c5b18587945b", - custom_check_id: "Audit Message Ingestion", - category: "ServiceControl.Audit Health", - status: "Pass", - reported_at: "2025-01-10T05:06:30.4074087Z", - originating_endpoint: { - name: "Particular.ServiceControl.Audit", - host_id: "ff605b55-6fbb-af56-5753-73c1ff73e601", - host: "COMPUSA", - }, - }, - { - id: "CustomChecks/36752f09-8a72-752e-e48f-6c378329d43b", - custom_check_id: "Error Message Ingestion", - category: "ServiceControl Health", - status: "Pass", - reported_at: "2025-01-10T05:42:00.531067Z", - originating_endpoint: { - name: "Particular.ServiceControl", - host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", - host: "COMPUSA", - }, - }, - { - id: "CustomChecks/02564a68-8c3e-92f6-d977-ce45d7ce46ed", - custom_check_id: "ServiceControl.Audit database", - category: "Storage space", - status: "Pass", - reported_at: "2025-01-10T05:51:44.4635095Z", - originating_endpoint: { - name: "Particular.ServiceControl.Audit", - host_id: "ff605b55-6fbb-af56-5753-73c1ff73e601", - host: "COMPUSA", - }, - }, - { - id: "CustomChecks/5443ee67-c22a-521f-5dc1-b979f831151a", - custom_check_id: "Audit Database Index Lag", - category: "ServiceControl.Audit Health", - status: "Pass", - reported_at: "2025-01-10T05:51:47.7264687Z", - originating_endpoint: { - name: "Particular.ServiceControl.Audit", - host_id: "ff605b55-6fbb-af56-5753-73c1ff73e601", - host: "COMPUSA", - }, - }, - { - id: "CustomChecks/93b62dc3-e1bf-abfd-4268-8d36fef2b0c6", - custom_check_id: "ServiceControl database", - category: "Storage space", - status: "Pass", - reported_at: "2025-01-10T05:52:03.8512021Z", - originating_endpoint: { - name: "Particular.ServiceControl", - host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", - host: "COMPUSA", - }, - }, - { - id: "CustomChecks/7e09172e-7c59-9a0c-52da-e2ecc1784e15", - custom_check_id: "Saga Audit Configuration", - category: "Configuration", - status: "Pass", - reported_at: "2025-01-10T05:52:03.850927Z", - originating_endpoint: { - name: "Particular.ServiceControl", - host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", - host: "COMPUSA", - }, - }, - { - id: "CustomChecks/7940dbbf-3019-cb8a-3add-b9ff9c57edb7", - custom_check_id: "Error Database Index Errors", - category: "ServiceControl Health", - status: "Pass", - reported_at: "2025-01-10T05:52:03.8522051Z", - originating_endpoint: { - name: "Particular.ServiceControl", - host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", - host: "COMPUSA", - }, - }, - { - id: "CustomChecks/4dc66bce-632b-5404-bc3d-e1943d99c301", - custom_check_id: "Error Database Index Lag", - category: "ServiceControl Health", - status: "Pass", - reported_at: "2025-01-10T05:52:05.8153025Z", - originating_endpoint: { - name: "Particular.ServiceControl", - host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", - host: "COMPUSA", - }, - }, - { - id: "CustomChecks/3eab20ba-3c24-b354-d298-aae5412c0125", - custom_check_id: "ServiceControl Remotes", - category: "Health", - status: "Pass", - reported_at: "2025-01-10T05:52:10.1360722Z", - originating_endpoint: { - name: "Particular.ServiceControl", - host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", - host: "COMPUSA", - }, - }, - { - id: "CustomChecks/c7011287-308f-c7b7-f50a-cca3c3fe17da", - custom_check_id: "ServiceControl Primary Instance", - category: "Health", - status: "Pass", - reported_at: "2025-01-10T05:52:18.4970695Z", - originating_endpoint: { - name: "Particular.ServiceControl", - host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", - host: "COMPUSA", - }, - }, - { - id: "CustomChecks/66675ab0-b69a-6a5a-6a56-da7709464fba", - custom_check_id: "Message Ingestion Process", - category: "ServiceControl Health", - status: "Pass", - reported_at: "2025-01-10T05:52:29.398929Z", - originating_endpoint: { - name: "Particular.ServiceControl", - host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", - host: "COMPUSA", - }, - }, - { - id: "CustomChecks/418dafe7-1dd2-886b-65d1-2b3e71e4feb2", - custom_check_id: "Error Message Ingestion Process", - category: "ServiceControl Health", - status: "Pass", - reported_at: "2025-01-10T05:52:29.3984912Z", - originating_endpoint: { - name: "Particular.ServiceControl", - host_id: "9f822d11-b097-a4df-3db5-e069e5d356fe", - host: "COMPUSA", - }, - }, - { - id: "CustomChecks/a406f1a7-412c-dd2c-7f90-9aa32da0698b", - custom_check_id: "Audit Message Ingestion Process", - category: "ServiceControl Health", - status: "Pass", - reported_at: "2025-01-10T05:52:31.4929675Z", - originating_endpoint: { - name: "Particular.ServiceControl.Audit", - host_id: "ff605b55-6fbb-af56-5753-73c1ff73e601", - host: "COMPUSA", - }, - }, - ], + body: passedCustomCheckItems, headers: { - "Total-Count": "0", //count of failing custom checks + "Total-Count": passedCustomCheckCount, //count of passing custom checks }, }); }; From 2bff573950f51c20b85ae57abe03569006d66852 Mon Sep 17 00:00:00 2001 From: Jayanthi Date: Mon, 20 Jan 2025 00:27:19 -0800 Subject: [PATCH 19/30] use mockEndpointDynamic to add customchecks url by querystring --- .../test/preconditions/customChecks.ts | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/Frontend/test/preconditions/customChecks.ts b/src/Frontend/test/preconditions/customChecks.ts index f2fc393f6..f74a0a1e7 100644 --- a/src/Frontend/test/preconditions/customChecks.ts +++ b/src/Frontend/test/preconditions/customChecks.ts @@ -3,9 +3,7 @@ import { customCheckItems } from "../mocks/custom-checks-template"; const content = JSON.stringify([]); const failedCustomCheckItems = customCheckItems.filter((check) => check.status === "Fail"); -const failedCustomCheckCount = failedCustomCheckItems.length.toString(); const passedCustomCheckItems = customCheckItems.filter((check) => check.status === "Pass"); -const passedCustomCheckCount = passedCustomCheckItems.length.toString(); export const hasCustomChecksEmpty = ({ driver }: SetupFactoryOptions) => { const serviceControlInstanceUrl = window.defaultConfig.service_control_url; @@ -16,13 +14,22 @@ export const hasCustomChecksEmpty = ({ driver }: SetupFactoryOptions) => { }, }); }; + export const hasCustomChecksFailing = ({ driver }: SetupFactoryOptions) => { const serviceControlInstanceUrl = window.defaultConfig.service_control_url; - driver.mockEndpoint(`${serviceControlInstanceUrl}customchecks`, { - body: failedCustomCheckItems, - headers: { - "Total-Count": failedCustomCheckCount, //count of failing custom checks - }, + driver.mockEndpointDynamic(`${serviceControlInstanceUrl}customchecks`, (url) => { + const status = url.searchParams.get("status"); + if (status === "fail") { + return { + body: failedCustomCheckItems, + headers: { "Total-Count": failedCustomCheckItems.length.toString() }, + }; + } + + return { + body: passedCustomCheckItems, + headers: { "Total-Count": passedCustomCheckItems.length.toString() }, + }; }); }; export const hasCustomChecksPassing = ({ driver }: SetupFactoryOptions) => { @@ -30,7 +37,7 @@ export const hasCustomChecksPassing = ({ driver }: SetupFactoryOptions) => { driver.mockEndpoint(`${serviceControlInstanceUrl}customchecks`, { body: passedCustomCheckItems, headers: { - "Total-Count": passedCustomCheckCount, //count of passing custom checks + "Total-Count": passedCustomCheckItems.length.toString(), //count of passing custom checks }, }); }; From 48b9b80d337137da204adb20562f92c3df8d6ac1 Mon Sep 17 00:00:00 2001 From: Jayanthi Date: Mon, 20 Jan 2025 00:34:43 -0800 Subject: [PATCH 20/30] remove extra space --- src/Frontend/src/views/CustomChecksView.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Frontend/src/views/CustomChecksView.vue b/src/Frontend/src/views/CustomChecksView.vue index af41435f1..9af105f6b 100644 --- a/src/Frontend/src/views/CustomChecksView.vue +++ b/src/Frontend/src/views/CustomChecksView.vue @@ -19,7 +19,7 @@ const { pageNumber, failingCount, failedChecks } = storeToRefs(store);
- +
From 656dc4512444330c9f5ac7665426912d3bd52ece Mon Sep 17 00:00:00 2001 From: Jayanthi Date: Wed, 22 Jan 2025 15:44:09 -0800 Subject: [PATCH 21/30] Update src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts Co-authored-by: Christian --- src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts b/src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts index d033cc772..8ed32cf53 100644 --- a/src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts +++ b/src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts @@ -11,7 +11,7 @@ describe("FEATURE: No data", () => { When navigating to the custom checks tab Then a message is shown "No failed custom checks" */ - test("EXAMPLE: 'No failed custom checks' should be displayed when there are no custom checks", async ({ driver }) => { + test("EXAMPLE: There are no failed or passing custom checks", async ({ driver }) => { //Arrange await driver.setUp(precondition.serviceControlWithMonitoring); // given that the custom check list is empty From 17d3451d3f46c7801c1ce0fd9a437bce16ac7a88 Mon Sep 17 00:00:00 2001 From: Jayanthi Date: Wed, 22 Jan 2025 15:44:16 -0800 Subject: [PATCH 22/30] Update src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts Co-authored-by: Christian --- src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts b/src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts index 8ed32cf53..5216698d0 100644 --- a/src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts +++ b/src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts @@ -30,7 +30,7 @@ describe("FEATURE: No data", () => { When navigating to the custom checks tab Then a message is shown "No failed custom checks" */ - test("EXAMPLE: 'No failed custom checks' should be displayed when all custom checks are in a success state", async ({ driver }) => { + test("EXAMPLE: There are custom checks but none of them are failing", async ({ driver }) => { //Arrange await driver.setUp(precondition.serviceControlWithMonitoring); // given that the custom check list is not empty and status of all checks are passing From 7579f0d5115cc5f991451e843813ec0ee72cbb51 Mon Sep 17 00:00:00 2001 From: Jayanthi Date: Wed, 22 Jan 2025 19:47:11 -0800 Subject: [PATCH 23/30] added some console.log for testing --- .../test/specs/customchecks/viewing-no-data.spec.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts b/src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts index d033cc772..98208fca5 100644 --- a/src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts +++ b/src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts @@ -32,16 +32,25 @@ describe("FEATURE: No data", () => { */ test("EXAMPLE: 'No failed custom checks' should be displayed when all custom checks are in a success state", async ({ driver }) => { //Arrange + // vi.useFakeTimers(); await driver.setUp(precondition.serviceControlWithMonitoring); + console.log("test started now;"); // given that the custom check list is not empty and status of all checks are passing await driver.setUp(precondition.hasCustomChecksPassing); //Act - When navigating to the custom checks tab await driver.goTo("/custom-checks"); + console.log("navigating to the custom checks tab"); + //vi.advanceTimersByTime(10000); + //setTimeout(async () => { //Expect - await waitFor(async () => { + waitFor(async () => { + console.log("expecting"); expect(await customChecksMessage()).toBe("No failed custom checks"); }); + // }, 5500); + + // vi.restoreAllMocks(); }); }); }); From e8bcffaa1e34e0c7c78a90b753f0425b4c8246a0 Mon Sep 17 00:00:00 2001 From: Jayanthi Date: Mon, 27 Jan 2025 19:46:22 -0800 Subject: [PATCH 24/30] add test for no custom check data scenario --- .../test/mocks/custom-checks-template.ts | 3 ++ .../test/preconditions/customChecks.ts | 40 ++++++++++--------- .../customchecks/viewing-no-data.spec.ts | 34 ++-------------- 3 files changed, 29 insertions(+), 48 deletions(-) diff --git a/src/Frontend/test/mocks/custom-checks-template.ts b/src/Frontend/test/mocks/custom-checks-template.ts index 542e4b179..7638dc7d1 100644 --- a/src/Frontend/test/mocks/custom-checks-template.ts +++ b/src/Frontend/test/mocks/custom-checks-template.ts @@ -106,3 +106,6 @@ export const customCheckItems: CustomCheck[] = [ }, }, ]; + +export const failedCustomCheckItems = customCheckItems.filter((check) => check.status === "Fail"); +export const passedCustomCheckItems = customCheckItems.filter((check) => check.status === "Pass"); diff --git a/src/Frontend/test/preconditions/customChecks.ts b/src/Frontend/test/preconditions/customChecks.ts index f74a0a1e7..2a8642016 100644 --- a/src/Frontend/test/preconditions/customChecks.ts +++ b/src/Frontend/test/preconditions/customChecks.ts @@ -1,43 +1,47 @@ import { SetupFactoryOptions } from "../driver"; -import { customCheckItems } from "../mocks/custom-checks-template"; +import { passedCustomCheckItems, customCheckItems } from "../mocks/custom-checks-template"; -const content = JSON.stringify([]); -const failedCustomCheckItems = customCheckItems.filter((check) => check.status === "Fail"); -const passedCustomCheckItems = customCheckItems.filter((check) => check.status === "Pass"); +const emptyContent = JSON.stringify([]); export const hasCustomChecksEmpty = ({ driver }: SetupFactoryOptions) => { const serviceControlInstanceUrl = window.defaultConfig.service_control_url; driver.mockEndpoint(`${serviceControlInstanceUrl}customchecks`, { - body: content, + body: emptyContent, headers: { "Total-Count": "0", //count of failing custom checks }, }); }; -export const hasCustomChecksFailing = ({ driver }: SetupFactoryOptions) => { +export const hasCustomChecksPassing = ({ driver }: SetupFactoryOptions) => { const serviceControlInstanceUrl = window.defaultConfig.service_control_url; driver.mockEndpointDynamic(`${serviceControlInstanceUrl}customchecks`, (url) => { const status = url.searchParams.get("status"); + let dataForCustomCheckItems = passedCustomCheckItems; + if (status === "fail") { - return { - body: failedCustomCheckItems, - headers: { "Total-Count": failedCustomCheckItems.length.toString() }, - }; + dataForCustomCheckItems = dataForCustomCheckItems.filter((check) => check.status === "Fail"); } return { - body: passedCustomCheckItems, - headers: { "Total-Count": passedCustomCheckItems.length.toString() }, + body: dataForCustomCheckItems, + headers: { "Total-Count": dataForCustomCheckItems.length.toString() }, }; }); }; -export const hasCustomChecksPassing = ({ driver }: SetupFactoryOptions) => { +export const hasCustomChecks = ({ driver }: SetupFactoryOptions) => { const serviceControlInstanceUrl = window.defaultConfig.service_control_url; - driver.mockEndpoint(`${serviceControlInstanceUrl}customchecks`, { - body: passedCustomCheckItems, - headers: { - "Total-Count": passedCustomCheckItems.length.toString(), //count of passing custom checks - }, + driver.mockEndpointDynamic(`${serviceControlInstanceUrl}customchecks`, (url) => { + const status = url.searchParams.get("status"); + let dataForCustomCheckItems = customCheckItems; + + if (status === "fail") { + dataForCustomCheckItems = dataForCustomCheckItems.filter((check) => check.status === "Fail"); + } + + return { + body: dataForCustomCheckItems, + headers: { "Total-Count": dataForCustomCheckItems.length.toString() }, + }; }); }; diff --git a/src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts b/src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts index d08eb8a36..119bfc91d 100644 --- a/src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts +++ b/src/Frontend/test/specs/customchecks/viewing-no-data.spec.ts @@ -5,52 +5,26 @@ import { customChecksMessage } from "./questions/customChecksMessage"; import { waitFor } from "@testing-library/vue"; describe("FEATURE: No data", () => { - describe("RULE: When there is no data to show a message should be displayed ", () => { - /* SCENARIO - Given there are no custom checks - When navigating to the custom checks tab - Then a message is shown "No failed custom checks" - */ + describe("RULE: When there is no data to show, a message should be displayed ", () => { test("EXAMPLE: There are no failed or passing custom checks", async ({ driver }) => { - //Arrange await driver.setUp(precondition.serviceControlWithMonitoring); - // given that the custom check list is empty await driver.setUp(precondition.hasCustomChecksEmpty); - //Act - When navigating to the custom checks tab await driver.goTo("/custom-checks"); - //Expect + await waitFor(async () => { expect(await customChecksMessage()).toBe("No failed custom checks"); }); }); - /* SCENARIO - Given there are custom checks - And all custom checks are in a success state - When navigating to the custom checks tab - Then a message is shown "No failed custom checks" - */ test("EXAMPLE: There are custom checks but none of them are failing", async ({ driver }) => { - //Arrange - // vi.useFakeTimers(); await driver.setUp(precondition.serviceControlWithMonitoring); - console.log("test started now;"); - // given that the custom check list is not empty and status of all checks are passing await driver.setUp(precondition.hasCustomChecksPassing); - //Act - When navigating to the custom checks tab await driver.goTo("/custom-checks"); - console.log("navigating to the custom checks tab"); - //vi.advanceTimersByTime(10000); - //setTimeout(async () => { - //Expect - waitFor(async () => { - console.log("expecting"); + + await waitFor(async () => { expect(await customChecksMessage()).toBe("No failed custom checks"); }); - // }, 5500); - - // vi.restoreAllMocks(); }); }); }); From 3db1192beac1ece107b152b1118b1ed1207db0d8 Mon Sep 17 00:00:00 2001 From: Jayanthi Date: Mon, 27 Jan 2025 23:19:13 -0800 Subject: [PATCH 25/30] set up mock data for custom check and write tests for empty and failed custom check listing --- .../customchecks/CustomCheckView.vue | 4 +- src/Frontend/src/views/CustomChecksView.vue | 2 +- src/Frontend/test/mocks/browser.ts | 3 +- .../test/mocks/custom-checks-template.ts | 16 ++--- src/Frontend/test/preconditions/index.ts | 2 +- .../questions/customChecksMessage.ts | 6 -- .../questions/failedCustomChecks.ts | 14 +++++ .../viewing-failing-custom-checks.spec.ts | 62 +++++++++---------- .../customchecks/viewing-no-data.spec.ts | 6 +- 9 files changed, 61 insertions(+), 54 deletions(-) delete mode 100644 src/Frontend/test/specs/customchecks/questions/customChecksMessage.ts create mode 100644 src/Frontend/test/specs/customchecks/questions/failedCustomChecks.ts diff --git a/src/Frontend/src/components/customchecks/CustomCheckView.vue b/src/Frontend/src/components/customchecks/CustomCheckView.vue index 8713c9ec1..17fa1b29f 100644 --- a/src/Frontend/src/components/customchecks/CustomCheckView.vue +++ b/src/Frontend/src/components/customchecks/CustomCheckView.vue @@ -11,11 +11,11 @@ const store = useCustomChecksStore();