@oneuptime/common 12.0.34 → 13.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Models/DatabaseModels/GlobalConfig.ts +12 -12
- package/Models/DatabaseModels/InventoryItem.ts +44 -1
- package/Models/DatabaseModels/NetworkDevice.ts +126 -0
- package/Server/EnvironmentConfig.ts +47 -16
- package/Server/Infrastructure/Postgres/SchemaMigrations/1791700000000-AddMacAddressToNetworkDevice.ts +25 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +2 -0
- package/Server/Infrastructure/Redis.ts +8 -8
- package/Server/Infrastructure/Status.ts +10 -4
- package/Server/Services/DatabaseService.ts +65 -13
- package/Server/Services/InventoryItemService.ts +31 -1
- package/Server/Services/MonitorTemplateService.ts +140 -19
- package/Server/Services/NetworkDeviceAutoImportRuleEngineService.ts +349 -41
- package/Server/Services/NetworkDeviceDiscoveryScanService.ts +87 -2
- package/Server/Services/NetworkDeviceService.ts +69 -0
- package/Server/Services/UserNotificationRuleService.ts +76 -25
- package/Server/Types/Database/Permissions/ReadPermission.ts +45 -5
- package/Server/Types/Database/QueryUtil.ts +56 -0
- package/Server/Types/Markdown.ts +93 -1
- package/Server/Utils/Dashboard/PublicDashboardResourceListPolicy.ts +82 -17
- package/Server/Utils/EmailRollup/EmailRollupFlushRunner.ts +10 -1
- package/Server/Utils/EmailRollup/EmailRollupRenderer.ts +2 -2
- package/Server/Utils/Monitor/Criteria/CompareCriteria.ts +82 -35
- package/Server/Utils/Monitor/Criteria/MetricMonitorCriteria.ts +31 -5
- package/Server/Utils/Monitor/MonitorCriteriaEvaluator.ts +202 -37
- package/Server/Utils/Monitor/MonitorCriteriaExpectationBuilder.ts +82 -9
- package/Server/Utils/Monitor/MonitorCriteriaMessageBuilder.ts +16 -7
- package/Server/Utils/Monitor/MonitorCriteriaMessageFormatter.ts +29 -17
- package/Server/Utils/Monitor/MonitorCriteriaObservationBuilder.ts +107 -48
- package/Server/Utils/Monitor/NetworkDeviceMacLearningUtil.ts +158 -0
- package/Server/Utils/Monitor/NetworkInventoryUtil.ts +27 -0
- package/Server/Utils/Telemetry/EntityRegistry.ts +11 -1
- package/Server/Utils/Telemetry/TelemetryEntity.ts +83 -9
- package/Tests/App/Dashboard/AddNeighborToMonitoringModal.test.tsx +32 -0
- package/Tests/App/Dashboard/AdoptedDeviceDrawer.test.tsx +374 -0
- package/Tests/App/Dashboard/DashboardLabelVariables.test.tsx +580 -0
- package/Tests/App/Dashboard/DashboardMonitorLabelVariable.test.tsx +438 -0
- package/Tests/App/Dashboard/DashboardVariableAllContract.test.tsx +5 -2
- package/Tests/App/Dashboard/DeviceAttachmentCard.test.tsx +273 -0
- package/Tests/App/Dashboard/DiscoveryReviewInventoryRefresh.test.tsx +505 -0
- package/Tests/App/Dashboard/EntityDetailPanel.test.tsx +163 -0
- package/Tests/App/Dashboard/InfrastructureExplorer.test.tsx +401 -0
- package/Tests/App/Dashboard/InfrastructureGraph.test.tsx +232 -0
- package/Tests/App/Dashboard/InventoryItems.test.tsx +201 -0
- package/Tests/App/Dashboard/InventoryTypeAndStatusFacets.test.tsx +798 -0
- package/Tests/App/Dashboard/NetworkTopologyLiveView.test.tsx +320 -0
- package/Tests/App/Dashboard/NetworkTopologyToolbar.test.tsx +275 -0
- package/Tests/App/Dashboard/OnCallCalendarFeedEmptyState.test.tsx +975 -0
- package/Tests/App/Dashboard/OnCallCalendarFeedPlanGate.test.tsx +63 -0
- package/Tests/App/Dashboard/ServiceMapGraph.test.tsx +626 -0
- package/Tests/App/Dashboard/TopologyDataLoading.test.tsx +348 -0
- package/Tests/App/Dashboard/TopologyPageNavigation.test.tsx +331 -0
- package/Tests/App/Dashboard/UserSettingsEmailPreferences.test.tsx +603 -0
- package/Tests/App/Dashboard/UserSettingsNotificationSettings.test.tsx +324 -0
- package/Tests/App/PublicDashboard/DashboardVariableSelector.test.tsx +13 -4
- package/Tests/App/StatusPage/StatusPageOidcOrigin.test.tsx +223 -0
- package/Tests/Models/InventoryItemStatus.test.ts +147 -0
- package/Tests/Models/NetworkDeviceMacAddressColumn.test.ts +294 -0
- package/Tests/Server/API/DashboardPublicResourceListAPI.test.ts +129 -0
- package/Tests/Server/EnvironmentConfigValkey.test.ts +227 -0
- package/Tests/Server/Infrastructure/Postgres/AddMacAddressToNetworkDeviceMigration.test.ts +365 -0
- package/Tests/Server/Infrastructure/Postgres/CustomFieldValueMappingMigration.test.ts +62 -23
- package/Tests/Server/Infrastructure/ValkeyDeploymentConfig.test.ts +265 -0
- package/Tests/Server/Middleware/HttpMetricsMiddleware.test.ts +382 -0
- package/Tests/Server/Middleware/SCIMAuthorization.test.ts +525 -0
- package/Tests/Server/Services/DatabaseServiceAggregateBy.test.ts +291 -56
- package/Tests/Server/Services/DatabaseServiceSortTiebreaker.test.ts +151 -0
- package/Tests/Server/Services/InventoryItemManualCreate.test.ts +105 -0
- package/Tests/Server/Services/InventoryItemPromotionGate.test.ts +178 -0
- package/Tests/Server/Services/MonitorTemplateServiceCustomFieldSync.test.ts +502 -0
- package/Tests/Server/Services/NetworkDeviceAutoImportRuleEngineService.test.ts +1133 -81
- package/Tests/Server/Services/NetworkDeviceDiscoveryScanRegistration.test.ts +520 -0
- package/Tests/Server/Services/NetworkDeviceMacAddressNormalization.test.ts +572 -0
- package/Tests/Server/Types/Database/InventoryStatusPostgres.test.ts +368 -0
- package/Tests/Server/Types/Database/Permissions/ReadBlockPermission.test.ts +261 -14
- package/Tests/Server/Types/Database/QueryUtilIncludesAnyOfGroups.test.ts +169 -0
- package/Tests/Server/Types/Database/QueryUtilIncludesAnyOfGroupsPostgres.test.ts +297 -0
- package/Tests/Server/Types/Markdown.test.ts +194 -1
- package/Tests/Server/Types/Workflow/Components/IncomingWebhookUtils.test.ts +279 -0
- package/Tests/Server/Types/Workflow/Components/TextToJson.test.ts +212 -0
- package/Tests/Server/Utils/CustomField/CustomFieldMappingRegistry.test.ts +436 -0
- package/Tests/Server/Utils/Dashboard/PublicDashboardResourceListPolicy.test.ts +214 -0
- package/Tests/Server/Utils/EmailRollup/EmailRollupFlushRunnerBehaviour.test.ts +1 -1
- package/Tests/Server/Utils/EmailRollup/EmailRollupRenderer.test.ts +10 -3
- package/Tests/Server/Utils/EventLoop.test.ts +359 -0
- package/Tests/Server/Utils/JsonWebToken.test.ts +30 -0
- package/Tests/Server/Utils/Monitor/Criteria/CompareCriteria.test.ts +242 -0
- package/Tests/Server/Utils/Monitor/Criteria/CompareCriteriaAggregation.test.ts +13 -7
- package/Tests/Server/Utils/Monitor/Criteria/DatabaseMonitorCriteria.test.ts +29 -0
- package/Tests/Server/Utils/Monitor/Criteria/MetricMonitorCriteria.test.ts +30 -6
- package/Tests/Server/Utils/Monitor/Criteria/MetricMonitorCriteriaAnomalyUnits.test.ts +246 -0
- package/Tests/Server/Utils/Monitor/MonitorCriteriaEmailEvalLogAgreement.test.ts +280 -0
- package/Tests/Server/Utils/Monitor/MonitorCriteriaEvaluator.test.ts +224 -10
- package/Tests/Server/Utils/Monitor/MonitorCriteriaEvaluatorMetricUnits.test.ts +570 -0
- package/Tests/Server/Utils/Monitor/MonitorCriteriaExpectationBuilderUnits.test.ts +30 -5
- package/Tests/Server/Utils/Monitor/MonitorCriteriaMessageBuilderUnits.test.ts +68 -21
- package/Tests/Server/Utils/Monitor/MonitorCriteriaObservationBuilderUnits.test.ts +36 -19
- package/Tests/Server/Utils/Monitor/NetworkDeviceMacLearningUtil.test.ts +573 -0
- package/Tests/Server/Utils/Monitor/NetworkInventoryUtil.test.ts +317 -0
- package/Tests/Server/Utils/Telemetry/ContextSpanProcessor.test.ts +281 -0
- package/Tests/Server/Utils/Telemetry/InventoryDuplicateIdentity.test.ts +316 -0
- package/Tests/Server/Utils/Telemetry/TelemetryEntity.test.ts +111 -8
- package/Tests/Types/Database/IncludesAnyOfGroups.test.ts +106 -0
- package/Tests/Types/JSONFunctions.test.ts +40 -0
- package/Tests/Types/NetworkAutomation/AutoImportRunMerge.test.ts +235 -0
- package/Tests/Types/NetworkAutomation/RuleRunResult.test.ts +66 -0
- package/Tests/Types/NetworkAutomation/RuleRunResultDescribe.test.ts +309 -1
- package/Tests/Types/Telemetry/InventoryLiveness.test.ts +99 -0
- package/Tests/UI/Components/CustomFields/CustomFieldsDetail.test.tsx +160 -0
- package/Tests/UI/ReactRouterSingletonBuild.test.ts +133 -0
- package/Tests/UI/Rum/ReplayHeader.test.tsx +10 -2
- package/Tests/UI/Rum/ReplayPlayerChrome.test.tsx +514 -0
- package/Tests/UI/Rum/ReplayTimeFormat.test.ts +94 -0
- package/Tests/UI/Rum/ReplayUi.test.tsx +559 -0
- package/Tests/UI/Utils/Breadcrumb/fixtures/RealBreadcrumbTrails.ts +5 -0
- package/Tests/UI/Utils/Breadcrumb/fixtures/RealRoutePatterns.ts +1 -0
- package/Tests/Utils/Dashboard/Components/DashboardMonitorListComponent.test.ts +11 -1
- package/Tests/Utils/Dashboard/LabelVariable.test.ts +257 -0
- package/Tests/Utils/Dashboard/VariableUrlState.test.ts +144 -14
- package/Tests/Utils/MetricUnitUtil.test.ts +81 -0
- package/Tests/Utils/Monitor/DeviceMacLearningUtil.test.ts +497 -0
- package/Tests/Utils/Monitor/MetricValueFormatter.test.ts +546 -0
- package/Tests/Utils/Monitor/MonitorTemplateCustomFieldUtil.test.ts +218 -0
- package/Tests/Utils/Monitor/NetworkTopologyEndpointAdoption.test.ts +1755 -0
- package/Tests/Utils/NetworkAutomation/AutoImportRunChain.test.ts +320 -0
- package/Types/BaseDatabase/IncludesAnyOfGroups.ts +77 -0
- package/Types/Dashboard/DashboardComponents/ComponentArgument.ts +1 -0
- package/Types/Dashboard/DashboardComponents/DashboardMonitorListComponent.ts +1 -0
- package/Types/Dashboard/DashboardVariable.ts +8 -0
- package/Types/JSON.ts +4 -0
- package/Types/JSONFunctions.ts +16 -0
- package/Types/Monitor/SnmpMonitor/NetworkTopology.ts +13 -0
- package/Types/NetworkAutomation/RuleRunResult.ts +402 -13
- package/Types/SerializableObjectDictionary.ts +4 -0
- package/Types/Telemetry/InventoryLiveness.ts +56 -0
- package/UI/Components/CSVFileUpload/CSVFileUpload.tsx +9 -2
- package/UI/Components/CustomFields/CustomFieldsDetail.tsx +46 -21
- package/UI/Components/Dashboard/DashboardVariableControl.tsx +285 -0
- package/UI/esbuild-config.js +6 -0
- package/Utils/Dashboard/Components/DashboardMonitorListComponent.ts +12 -1
- package/Utils/Dashboard/LabelVariable.ts +152 -0
- package/Utils/Dashboard/VariableUrlState.ts +27 -5
- package/Utils/MetricUnitUtil.ts +34 -0
- package/Utils/Monitor/DeviceMacLearningUtil.ts +177 -0
- package/Utils/Monitor/MetricValueFormatter.ts +342 -0
- package/Utils/Monitor/MonitorTemplateCustomFieldUtil.ts +124 -0
- package/Utils/Monitor/NetworkDeviceMonitorTemplateUtil.ts +7 -2
- package/Utils/Monitor/NetworkTopologyUtil.ts +693 -0
- package/Utils/NetworkAutomation/AutoImportRunChain.ts +138 -0
- package/build/dist/Models/DatabaseModels/GlobalConfig.js +12 -12
- package/build/dist/Models/DatabaseModels/GlobalConfig.js.map +1 -1
- package/build/dist/Models/DatabaseModels/InventoryItem.js +34 -1
- package/build/dist/Models/DatabaseModels/InventoryItem.js.map +1 -1
- package/build/dist/Models/DatabaseModels/NetworkDevice.js +128 -0
- package/build/dist/Models/DatabaseModels/NetworkDevice.js.map +1 -1
- package/build/dist/Server/EnvironmentConfig.js +44 -12
- package/build/dist/Server/EnvironmentConfig.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1791700000000-AddMacAddressToNetworkDevice.js +14 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1791700000000-AddMacAddressToNetworkDevice.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +2 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Infrastructure/Redis.js +8 -8
- package/build/dist/Server/Infrastructure/Redis.js.map +1 -1
- package/build/dist/Server/Infrastructure/Status.js +10 -4
- package/build/dist/Server/Infrastructure/Status.js.map +1 -1
- package/build/dist/Server/Services/DatabaseService.js +58 -13
- package/build/dist/Server/Services/DatabaseService.js.map +1 -1
- package/build/dist/Server/Services/InventoryItemService.js +28 -1
- package/build/dist/Server/Services/InventoryItemService.js.map +1 -1
- package/build/dist/Server/Services/MonitorTemplateService.js +116 -17
- package/build/dist/Server/Services/MonitorTemplateService.js.map +1 -1
- package/build/dist/Server/Services/NetworkDeviceAutoImportRuleEngineService.js +270 -37
- package/build/dist/Server/Services/NetworkDeviceAutoImportRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/NetworkDeviceDiscoveryScanService.js +65 -0
- package/build/dist/Server/Services/NetworkDeviceDiscoveryScanService.js.map +1 -1
- package/build/dist/Server/Services/NetworkDeviceService.js +54 -0
- package/build/dist/Server/Services/NetworkDeviceService.js.map +1 -1
- package/build/dist/Server/Services/UserNotificationRuleService.js +60 -25
- package/build/dist/Server/Services/UserNotificationRuleService.js.map +1 -1
- package/build/dist/Server/Types/Database/Permissions/ReadPermission.js +29 -4
- package/build/dist/Server/Types/Database/Permissions/ReadPermission.js.map +1 -1
- package/build/dist/Server/Types/Database/QueryUtil.js +36 -0
- package/build/dist/Server/Types/Database/QueryUtil.js.map +1 -1
- package/build/dist/Server/Types/Markdown.js +75 -0
- package/build/dist/Server/Types/Markdown.js.map +1 -1
- package/build/dist/Server/Utils/Dashboard/PublicDashboardResourceListPolicy.js +53 -18
- package/build/dist/Server/Utils/Dashboard/PublicDashboardResourceListPolicy.js.map +1 -1
- package/build/dist/Server/Utils/EmailRollup/EmailRollupFlushRunner.js +10 -1
- package/build/dist/Server/Utils/EmailRollup/EmailRollupFlushRunner.js.map +1 -1
- package/build/dist/Server/Utils/EmailRollup/EmailRollupRenderer.js +2 -2
- package/build/dist/Server/Utils/EmailRollup/EmailRollupRenderer.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/Criteria/CompareCriteria.js +58 -35
- package/build/dist/Server/Utils/Monitor/Criteria/CompareCriteria.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/Criteria/MetricMonitorCriteria.js +29 -5
- package/build/dist/Server/Utils/Monitor/Criteria/MetricMonitorCriteria.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaEvaluator.js +166 -35
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaEvaluator.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaExpectationBuilder.js +58 -9
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaExpectationBuilder.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaMessageBuilder.js +9 -3
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaMessageBuilder.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaMessageFormatter.js +26 -12
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaMessageFormatter.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaObservationBuilder.js +74 -33
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaObservationBuilder.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/NetworkDeviceMacLearningUtil.js +114 -0
- package/build/dist/Server/Utils/Monitor/NetworkDeviceMacLearningUtil.js.map +1 -0
- package/build/dist/Server/Utils/Monitor/NetworkInventoryUtil.js +25 -0
- package/build/dist/Server/Utils/Monitor/NetworkInventoryUtil.js.map +1 -1
- package/build/dist/Server/Utils/Telemetry/EntityRegistry.js +9 -1
- package/build/dist/Server/Utils/Telemetry/EntityRegistry.js.map +1 -1
- package/build/dist/Server/Utils/Telemetry/TelemetryEntity.js +70 -13
- package/build/dist/Server/Utils/Telemetry/TelemetryEntity.js.map +1 -1
- package/build/dist/Types/BaseDatabase/IncludesAnyOfGroups.js +54 -0
- package/build/dist/Types/BaseDatabase/IncludesAnyOfGroups.js.map +1 -0
- package/build/dist/Types/Dashboard/DashboardComponents/ComponentArgument.js +1 -0
- package/build/dist/Types/Dashboard/DashboardComponents/ComponentArgument.js.map +1 -1
- package/build/dist/Types/Dashboard/DashboardVariable.js +1 -0
- package/build/dist/Types/Dashboard/DashboardVariable.js.map +1 -1
- package/build/dist/Types/JSON.js +1 -0
- package/build/dist/Types/JSON.js.map +1 -1
- package/build/dist/Types/JSONFunctions.js +13 -0
- package/build/dist/Types/JSONFunctions.js.map +1 -1
- package/build/dist/Types/NetworkAutomation/RuleRunResult.js +291 -6
- package/build/dist/Types/NetworkAutomation/RuleRunResult.js.map +1 -1
- package/build/dist/Types/SerializableObjectDictionary.js +4 -0
- package/build/dist/Types/SerializableObjectDictionary.js.map +1 -1
- package/build/dist/Types/Telemetry/InventoryLiveness.js +37 -0
- package/build/dist/Types/Telemetry/InventoryLiveness.js.map +1 -0
- package/build/dist/UI/Components/CSVFileUpload/CSVFileUpload.js +7 -0
- package/build/dist/UI/Components/CSVFileUpload/CSVFileUpload.js.map +1 -1
- package/build/dist/UI/Components/CustomFields/CustomFieldsDetail.js +9 -2
- package/build/dist/UI/Components/CustomFields/CustomFieldsDetail.js.map +1 -1
- package/build/dist/UI/Components/Dashboard/DashboardVariableControl.js +137 -0
- package/build/dist/UI/Components/Dashboard/DashboardVariableControl.js.map +1 -0
- package/build/dist/Utils/Dashboard/Components/DashboardMonitorListComponent.js +9 -1
- package/build/dist/Utils/Dashboard/Components/DashboardMonitorListComponent.js.map +1 -1
- package/build/dist/Utils/Dashboard/LabelVariable.js +96 -0
- package/build/dist/Utils/Dashboard/LabelVariable.js.map +1 -0
- package/build/dist/Utils/Dashboard/VariableUrlState.js +19 -4
- package/build/dist/Utils/Dashboard/VariableUrlState.js.map +1 -1
- package/build/dist/Utils/MetricUnitUtil.js +26 -0
- package/build/dist/Utils/MetricUnitUtil.js.map +1 -1
- package/build/dist/Utils/Monitor/DeviceMacLearningUtil.js +112 -0
- package/build/dist/Utils/Monitor/DeviceMacLearningUtil.js.map +1 -0
- package/build/dist/Utils/Monitor/MetricValueFormatter.js +276 -0
- package/build/dist/Utils/Monitor/MetricValueFormatter.js.map +1 -0
- package/build/dist/Utils/Monitor/MonitorTemplateCustomFieldUtil.js +101 -0
- package/build/dist/Utils/Monitor/MonitorTemplateCustomFieldUtil.js.map +1 -0
- package/build/dist/Utils/Monitor/NetworkDeviceMonitorTemplateUtil.js +7 -2
- package/build/dist/Utils/Monitor/NetworkDeviceMonitorTemplateUtil.js.map +1 -1
- package/build/dist/Utils/Monitor/NetworkTopologyUtil.js +484 -0
- package/build/dist/Utils/Monitor/NetworkTopologyUtil.js.map +1 -1
- package/build/dist/Utils/NetworkAutomation/AutoImportRunChain.js +59 -0
- package/build/dist/Utils/NetworkAutomation/AutoImportRunChain.js.map +1 -0
- package/jest.config.json +2 -0
- package/package.json +1 -1
- package/test-setup.sh +9 -9
- package/tsconfig.json +51 -11
- package/Tests/App/Dashboard/NotificationEmailPreferences.test.tsx +0 -399
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
import "@testing-library/jest-dom";
|
|
2
|
+
import React, { act } from "react";
|
|
3
|
+
import {
|
|
4
|
+
cleanup,
|
|
5
|
+
fireEvent,
|
|
6
|
+
render,
|
|
7
|
+
screen,
|
|
8
|
+
waitFor,
|
|
9
|
+
} from "@testing-library/react";
|
|
10
|
+
import DashboardMonitorListComponentElement, {
|
|
11
|
+
ComponentProps,
|
|
12
|
+
} from "../../../../App/FeatureSet/Dashboard/src/Components/Dashboard/Components/DashboardMonitorListComponent";
|
|
13
|
+
import DashboardVariableSelector from "../../../../App/FeatureSet/Dashboard/src/Components/Dashboard/Toolbar/DashboardVariableSelector";
|
|
14
|
+
import { setPublicDashboardContext } from "../../../../App/FeatureSet/Dashboard/src/Components/Dashboard/Utils/PublicDashboardContext";
|
|
15
|
+
import DashboardMonitorListComponentUtil from "../../../Utils/Dashboard/Components/DashboardMonitorListComponent";
|
|
16
|
+
import DashboardVariable, {
|
|
17
|
+
DashboardVariableType,
|
|
18
|
+
} from "../../../Types/Dashboard/DashboardVariable";
|
|
19
|
+
import DashboardViewConfig from "../../../Types/Dashboard/DashboardViewConfig";
|
|
20
|
+
import Includes from "../../../Types/BaseDatabase/Includes";
|
|
21
|
+
import IncludesAnyOfGroups from "../../../Types/BaseDatabase/IncludesAnyOfGroups";
|
|
22
|
+
import SortOrder from "../../../Types/BaseDatabase/SortOrder";
|
|
23
|
+
import { ObjectType } from "../../../Types/JSON";
|
|
24
|
+
import ObjectID from "../../../Types/ObjectID";
|
|
25
|
+
import TimeRange from "../../../Types/Time/TimeRange";
|
|
26
|
+
import URL from "../../../Types/API/URL";
|
|
27
|
+
import { VariableValueChange } from "../../../UI/Components/Dashboard/DashboardVariableControl";
|
|
28
|
+
|
|
29
|
+
const listMock: jest.Mock = jest.fn();
|
|
30
|
+
const PROJECT_ID: ObjectID = new ObjectID(
|
|
31
|
+
"44444444-4444-4444-8444-444444444444",
|
|
32
|
+
);
|
|
33
|
+
const DASHBOARD_ID: ObjectID = new ObjectID(
|
|
34
|
+
"22222222-2222-4222-8222-222222222222",
|
|
35
|
+
);
|
|
36
|
+
const UNIT_660: string = "06600000-0000-4000-8000-000000000000";
|
|
37
|
+
const UNIT_661: string = "06610000-0000-4000-8000-000000000000";
|
|
38
|
+
const NETWORK: string = "00000000-0000-4000-8000-000000000001";
|
|
39
|
+
|
|
40
|
+
jest.mock("../../../UI/Utils/ModelAPI/ModelAPI", () => {
|
|
41
|
+
return {
|
|
42
|
+
__esModule: true,
|
|
43
|
+
default: {
|
|
44
|
+
getList: (...args: Array<unknown>) => {
|
|
45
|
+
return listMock(...args);
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
jest.mock("../../../UI/Utils/Project", () => {
|
|
51
|
+
return {
|
|
52
|
+
__esModule: true,
|
|
53
|
+
default: {
|
|
54
|
+
getCurrentProjectId: () => {
|
|
55
|
+
return PROJECT_ID;
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
jest.mock("../../../UI/Utils/API/API", () => {
|
|
61
|
+
return {
|
|
62
|
+
__esModule: true,
|
|
63
|
+
default: {
|
|
64
|
+
getFriendlyErrorMessage: (error: Error) => {
|
|
65
|
+
return error.message;
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
jest.mock(
|
|
71
|
+
"../../../../App/FeatureSet/Dashboard/src/Components/AppLink/AppLink",
|
|
72
|
+
() => {
|
|
73
|
+
return {
|
|
74
|
+
__esModule: true,
|
|
75
|
+
default: (props: { children: React.ReactNode }) => {
|
|
76
|
+
return <span>{props.children}</span>;
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
},
|
|
80
|
+
);
|
|
81
|
+
jest.mock("../../../../App/FeatureSet/Dashboard/src/Utils/RouteMap", () => {
|
|
82
|
+
return {
|
|
83
|
+
__esModule: true,
|
|
84
|
+
default: {},
|
|
85
|
+
RouteUtil: {
|
|
86
|
+
populateRouteParams: () => {
|
|
87
|
+
return {
|
|
88
|
+
toString: () => {
|
|
89
|
+
return "/monitor";
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
});
|
|
96
|
+
jest.mock(
|
|
97
|
+
"../../../../App/FeatureSet/Dashboard/src/Components/Metrics/Utils/Metrics",
|
|
98
|
+
() => {
|
|
99
|
+
return {
|
|
100
|
+
__esModule: true,
|
|
101
|
+
default: {
|
|
102
|
+
getTelemetryAttributeValues: () => {
|
|
103
|
+
return Promise.resolve([]);
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
},
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
function variable(
|
|
111
|
+
overrides: Partial<DashboardVariable> = {},
|
|
112
|
+
): DashboardVariable {
|
|
113
|
+
return {
|
|
114
|
+
id: "unit",
|
|
115
|
+
name: "UNIT",
|
|
116
|
+
type: DashboardVariableType.ProjectLabel,
|
|
117
|
+
labelOptions: [
|
|
118
|
+
{ label: "0660", value: UNIT_660 },
|
|
119
|
+
{ label: "0661", value: UNIT_661 },
|
|
120
|
+
],
|
|
121
|
+
...overrides,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const dashboardViewConfig: DashboardViewConfig = {
|
|
126
|
+
_type: ObjectType.DashboardViewConfig,
|
|
127
|
+
components: [],
|
|
128
|
+
heightInDashboardUnits: 12,
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
function props(overrides: Partial<ComponentProps> = {}): ComponentProps {
|
|
132
|
+
const component: ComponentProps["component"] =
|
|
133
|
+
DashboardMonitorListComponentUtil.getDefaultComponent();
|
|
134
|
+
component.arguments = {
|
|
135
|
+
title: "{{UNIT}} NETWORK",
|
|
136
|
+
labelVariableId: "unit",
|
|
137
|
+
maxRows: 25,
|
|
138
|
+
};
|
|
139
|
+
return {
|
|
140
|
+
component,
|
|
141
|
+
componentId: component.componentId,
|
|
142
|
+
key: "monitors",
|
|
143
|
+
isEditMode: false,
|
|
144
|
+
isSelected: false,
|
|
145
|
+
onComponentUpdate: () => {},
|
|
146
|
+
totalCurrentDashboardWidthInPx: 1200,
|
|
147
|
+
dashboardCanvasTopInPx: 0,
|
|
148
|
+
dashboardCanvasLeftInPx: 0,
|
|
149
|
+
dashboardCanvasWidthInPx: 1200,
|
|
150
|
+
dashboardCanvasHeightInPx: 800,
|
|
151
|
+
dashboardComponentHeightInPx: 320,
|
|
152
|
+
dashboardComponentWidthInPx: 480,
|
|
153
|
+
dashboardViewConfig,
|
|
154
|
+
dashboardStartAndEndDate: { range: TimeRange.PAST_ONE_HOUR },
|
|
155
|
+
metricTypes: [],
|
|
156
|
+
refreshTick: 0,
|
|
157
|
+
variables: [variable()],
|
|
158
|
+
...overrides,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function response(name: string): {
|
|
163
|
+
data: Array<Record<string, unknown>>;
|
|
164
|
+
count: number;
|
|
165
|
+
} {
|
|
166
|
+
return {
|
|
167
|
+
data: [
|
|
168
|
+
{
|
|
169
|
+
_id: UNIT_660,
|
|
170
|
+
name,
|
|
171
|
+
monitorType: "Manual",
|
|
172
|
+
currentMonitorStatus: { name: "Operational" },
|
|
173
|
+
},
|
|
174
|
+
],
|
|
175
|
+
count: 1,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
beforeEach(() => {
|
|
180
|
+
listMock.mockReset();
|
|
181
|
+
listMock.mockResolvedValue(response("All unit monitors"));
|
|
182
|
+
setPublicDashboardContext(null);
|
|
183
|
+
});
|
|
184
|
+
afterEach(() => {
|
|
185
|
+
cleanup();
|
|
186
|
+
setPublicDashboardContext(null);
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
describe("MonitorList project label variables", () => {
|
|
190
|
+
test("changing the real UNIT selector changes the query, rows and title without a refresh tick", async () => {
|
|
191
|
+
const initial: ComponentProps = props();
|
|
192
|
+
function Dashboard(): React.ReactElement {
|
|
193
|
+
const [variables, setVariables] = React.useState<
|
|
194
|
+
Array<DashboardVariable>
|
|
195
|
+
>([variable()]);
|
|
196
|
+
return (
|
|
197
|
+
<>
|
|
198
|
+
<DashboardVariableSelector
|
|
199
|
+
variables={variables}
|
|
200
|
+
onVariableValueChange={(
|
|
201
|
+
_id: string,
|
|
202
|
+
change: VariableValueChange,
|
|
203
|
+
) => {
|
|
204
|
+
return setVariables([
|
|
205
|
+
{ ...(variables[0] as DashboardVariable), ...change },
|
|
206
|
+
]);
|
|
207
|
+
}}
|
|
208
|
+
/>
|
|
209
|
+
<DashboardMonitorListComponentElement
|
|
210
|
+
{...initial}
|
|
211
|
+
variables={variables}
|
|
212
|
+
/>
|
|
213
|
+
</>
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
render(<Dashboard />);
|
|
217
|
+
expect(await screen.findByText("All unit monitors")).toBeInTheDocument();
|
|
218
|
+
expect(screen.getByText("All NETWORK")).toBeInTheDocument();
|
|
219
|
+
|
|
220
|
+
listMock.mockResolvedValue(response("0660 router"));
|
|
221
|
+
fireEvent.change(screen.getByRole("combobox"), {
|
|
222
|
+
target: { value: UNIT_660 },
|
|
223
|
+
});
|
|
224
|
+
expect(await screen.findByText("0660 router")).toBeInTheDocument();
|
|
225
|
+
expect(screen.queryByText("All unit monitors")).not.toBeInTheDocument();
|
|
226
|
+
expect(screen.getByText("0660 NETWORK")).toBeInTheDocument();
|
|
227
|
+
expect(listMock.mock.calls[1][0].query.labels).toEqual(
|
|
228
|
+
new Includes([UNIT_660]),
|
|
229
|
+
);
|
|
230
|
+
|
|
231
|
+
listMock.mockResolvedValue(response("0661 switch"));
|
|
232
|
+
fireEvent.change(screen.getByRole("combobox"), {
|
|
233
|
+
target: { value: UNIT_661 },
|
|
234
|
+
});
|
|
235
|
+
expect(await screen.findByText("0661 switch")).toBeInTheDocument();
|
|
236
|
+
expect(screen.queryByText("0660 router")).not.toBeInTheDocument();
|
|
237
|
+
expect(listMock.mock.calls[2][0].query.labels).toEqual(
|
|
238
|
+
new Includes([UNIT_661]),
|
|
239
|
+
);
|
|
240
|
+
|
|
241
|
+
listMock.mockResolvedValue(response("All unit monitors"));
|
|
242
|
+
fireEvent.change(screen.getByRole("combobox"), { target: { value: "" } });
|
|
243
|
+
expect(await screen.findByText("All unit monitors")).toBeInTheDocument();
|
|
244
|
+
expect(listMock.mock.calls[3][0].query.labels).toBeUndefined();
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
test("retains project, fixed labels, status, monitor type and row limit", async () => {
|
|
248
|
+
const input: ComponentProps = props({
|
|
249
|
+
variables: [variable({ selectedValue: UNIT_660 })],
|
|
250
|
+
});
|
|
251
|
+
input.component.arguments = {
|
|
252
|
+
...input.component.arguments,
|
|
253
|
+
labelIds: [NETWORK],
|
|
254
|
+
statusFilter: "operational",
|
|
255
|
+
monitorStatusIds: [NETWORK],
|
|
256
|
+
monitorTypes: ["Manual"],
|
|
257
|
+
maxRows: 7,
|
|
258
|
+
};
|
|
259
|
+
render(<DashboardMonitorListComponentElement {...input} />);
|
|
260
|
+
await waitFor(() => {
|
|
261
|
+
return expect(listMock).toHaveBeenCalledTimes(1);
|
|
262
|
+
});
|
|
263
|
+
expect(listMock.mock.calls[0][0]).toMatchObject({
|
|
264
|
+
query: {
|
|
265
|
+
projectId: PROJECT_ID,
|
|
266
|
+
labels: new IncludesAnyOfGroups([[NETWORK], [UNIT_660]]),
|
|
267
|
+
currentMonitorStatus: { isOperationalState: true },
|
|
268
|
+
currentMonitorStatusId: new Includes([NETWORK]),
|
|
269
|
+
monitorType: new Includes(["Manual"]),
|
|
270
|
+
},
|
|
271
|
+
limit: 7,
|
|
272
|
+
skip: 0,
|
|
273
|
+
sort: { name: SortOrder.Ascending },
|
|
274
|
+
});
|
|
275
|
+
expect(await screen.findByText("0660 NETWORK")).toBeInTheDocument();
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
test("All retains fixed labels even when a default is configured", async () => {
|
|
279
|
+
const input: ComponentProps = props({
|
|
280
|
+
variables: [variable({ selectedValue: "", defaultValue: UNIT_660 })],
|
|
281
|
+
});
|
|
282
|
+
input.component.arguments.labelIds = [NETWORK];
|
|
283
|
+
render(<DashboardMonitorListComponentElement {...input} />);
|
|
284
|
+
await screen.findByText("All NETWORK");
|
|
285
|
+
expect(listMock.mock.calls[0][0].query.labels).toEqual(
|
|
286
|
+
new Includes([NETWORK]),
|
|
287
|
+
);
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
test("a deleted label returns the ordinary empty state", async () => {
|
|
291
|
+
listMock.mockResolvedValue({ data: [], count: 0 });
|
|
292
|
+
render(
|
|
293
|
+
<DashboardMonitorListComponentElement
|
|
294
|
+
{...props({ variables: [variable({ selectedValue: UNIT_660 })] })}
|
|
295
|
+
/>,
|
|
296
|
+
);
|
|
297
|
+
expect(await screen.findByText("No monitors found")).toBeInTheDocument();
|
|
298
|
+
expect(listMock.mock.calls[0][0].query.labels).toEqual(
|
|
299
|
+
new Includes([UNIT_660]),
|
|
300
|
+
);
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
test("a removed binding produces a configuration error without fetching all monitors", async () => {
|
|
304
|
+
render(
|
|
305
|
+
<DashboardMonitorListComponentElement {...props({ variables: [] })} />,
|
|
306
|
+
);
|
|
307
|
+
expect(
|
|
308
|
+
await screen.findByText(/label variable is missing/),
|
|
309
|
+
).toBeInTheDocument();
|
|
310
|
+
expect(listMock).not.toHaveBeenCalled();
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
test("a selection absent from published options is an error", async () => {
|
|
314
|
+
render(
|
|
315
|
+
<DashboardMonitorListComponentElement
|
|
316
|
+
{...props({ variables: [variable({ selectedValue: NETWORK })] })}
|
|
317
|
+
/>,
|
|
318
|
+
);
|
|
319
|
+
expect(
|
|
320
|
+
await screen.findByText(/offered by this dashboard variable/),
|
|
321
|
+
).toBeInTheDocument();
|
|
322
|
+
expect(listMock).not.toHaveBeenCalled();
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
test("late responses for the previous unit cannot replace the latest results", async () => {
|
|
326
|
+
let resolvePrevious: (
|
|
327
|
+
result: ReturnType<typeof response>,
|
|
328
|
+
) => void = () => {};
|
|
329
|
+
listMock.mockImplementationOnce(() => {
|
|
330
|
+
return new Promise<ReturnType<typeof response>>(
|
|
331
|
+
(
|
|
332
|
+
resolve: (
|
|
333
|
+
result:
|
|
334
|
+
| ReturnType<typeof response>
|
|
335
|
+
| PromiseLike<ReturnType<typeof response>>,
|
|
336
|
+
) => void,
|
|
337
|
+
) => {
|
|
338
|
+
resolvePrevious = resolve;
|
|
339
|
+
},
|
|
340
|
+
);
|
|
341
|
+
});
|
|
342
|
+
const initial: ComponentProps = props({
|
|
343
|
+
variables: [variable({ selectedValue: UNIT_660 })],
|
|
344
|
+
});
|
|
345
|
+
const view: ReturnType<typeof render> = render(
|
|
346
|
+
<DashboardMonitorListComponentElement {...initial} />,
|
|
347
|
+
);
|
|
348
|
+
await waitFor(() => {
|
|
349
|
+
return expect(listMock).toHaveBeenCalledTimes(1);
|
|
350
|
+
});
|
|
351
|
+
listMock.mockResolvedValue(response("0661 switch"));
|
|
352
|
+
view.rerender(
|
|
353
|
+
<DashboardMonitorListComponentElement
|
|
354
|
+
{...initial}
|
|
355
|
+
variables={[variable({ selectedValue: UNIT_661 })]}
|
|
356
|
+
/>,
|
|
357
|
+
);
|
|
358
|
+
expect(await screen.findByText("0661 switch")).toBeInTheDocument();
|
|
359
|
+
await act(async () => {
|
|
360
|
+
resolvePrevious(response("0660 router"));
|
|
361
|
+
});
|
|
362
|
+
expect(screen.queryByText("0660 router")).not.toBeInTheDocument();
|
|
363
|
+
expect(screen.getByText("0661 switch")).toBeInTheDocument();
|
|
364
|
+
expect(screen.getByText("0661 NETWORK")).toBeInTheDocument();
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
test("late errors for a previous selection do not hide the latest rows", async () => {
|
|
368
|
+
let rejectPrevious: (error: Error) => void = () => {};
|
|
369
|
+
listMock.mockImplementationOnce(() => {
|
|
370
|
+
return new Promise<ReturnType<typeof response>>(
|
|
371
|
+
(
|
|
372
|
+
_resolve: (
|
|
373
|
+
result:
|
|
374
|
+
| ReturnType<typeof response>
|
|
375
|
+
| PromiseLike<ReturnType<typeof response>>,
|
|
376
|
+
) => void,
|
|
377
|
+
reject: (error?: unknown) => void,
|
|
378
|
+
) => {
|
|
379
|
+
rejectPrevious = reject;
|
|
380
|
+
},
|
|
381
|
+
);
|
|
382
|
+
});
|
|
383
|
+
const initial: ComponentProps = props({
|
|
384
|
+
variables: [variable({ selectedValue: UNIT_660 })],
|
|
385
|
+
});
|
|
386
|
+
const view: ReturnType<typeof render> = render(
|
|
387
|
+
<DashboardMonitorListComponentElement {...initial} />,
|
|
388
|
+
);
|
|
389
|
+
await waitFor(() => {
|
|
390
|
+
return expect(listMock).toHaveBeenCalledTimes(1);
|
|
391
|
+
});
|
|
392
|
+
listMock.mockResolvedValue(response("0661 switch"));
|
|
393
|
+
view.rerender(
|
|
394
|
+
<DashboardMonitorListComponentElement
|
|
395
|
+
{...initial}
|
|
396
|
+
variables={[variable({ selectedValue: UNIT_661 })]}
|
|
397
|
+
/>,
|
|
398
|
+
);
|
|
399
|
+
await screen.findByText("0661 switch");
|
|
400
|
+
await act(async () => {
|
|
401
|
+
rejectPrevious(new Error("Old request failed"));
|
|
402
|
+
});
|
|
403
|
+
expect(screen.queryByText("Old request failed")).not.toBeInTheDocument();
|
|
404
|
+
expect(screen.getByText("0661 switch")).toBeInTheDocument();
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
test("public requests send component identity and selection IDs to the dashboard endpoint", async () => {
|
|
408
|
+
setPublicDashboardContext({
|
|
409
|
+
dashboardId: DASHBOARD_ID,
|
|
410
|
+
apiUrl: URL.fromString("https://dev.oneuptime.com/public-dashboard-api"),
|
|
411
|
+
postJSON: async () => {
|
|
412
|
+
throw new Error("Unexpected public request");
|
|
413
|
+
},
|
|
414
|
+
});
|
|
415
|
+
const input: ComponentProps = props({
|
|
416
|
+
variables: [
|
|
417
|
+
variable({ isMultiSelect: true, selectedValues: [UNIT_660, UNIT_661] }),
|
|
418
|
+
],
|
|
419
|
+
});
|
|
420
|
+
render(<DashboardMonitorListComponentElement {...input} />);
|
|
421
|
+
await screen.findByText("0660, 0661 NETWORK");
|
|
422
|
+
const options: Record<string, any> =
|
|
423
|
+
listMock.mock.calls[0][0].requestOptions;
|
|
424
|
+
expect(options["overrideRequestUrl"].toString()).toContain(
|
|
425
|
+
`/resource-list/${DASHBOARD_ID.toString()}/monitor`,
|
|
426
|
+
);
|
|
427
|
+
expect(options["additionalRequestBody"]).toEqual({
|
|
428
|
+
componentId: input.componentId.toString(),
|
|
429
|
+
variables: [
|
|
430
|
+
{
|
|
431
|
+
id: "unit",
|
|
432
|
+
selectedValue: null,
|
|
433
|
+
selectedValues: [UNIT_660, UNIT_661],
|
|
434
|
+
},
|
|
435
|
+
],
|
|
436
|
+
});
|
|
437
|
+
});
|
|
438
|
+
});
|
|
@@ -439,8 +439,11 @@ describe("dashboard variable All contract", () => {
|
|
|
439
439
|
React.createElement(PublicDashboardVariableSelector, {
|
|
440
440
|
variables: [variable],
|
|
441
441
|
dashboardId: new ObjectID("11111111-1111-4111-8111-111111111111"),
|
|
442
|
-
onVariableValueChange: (
|
|
443
|
-
|
|
442
|
+
onVariableValueChange: (
|
|
443
|
+
_id: string,
|
|
444
|
+
change: VariableValueChange,
|
|
445
|
+
): void => {
|
|
446
|
+
values.push(change.selectedValue || "");
|
|
444
447
|
},
|
|
445
448
|
}),
|
|
446
449
|
);
|