@oneuptime/common 13.0.7 → 13.0.8
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/OnCallDutyPolicyScheduleCalendarFeed.ts +1 -1
- package/Models/DatabaseModels/ProjectOnCallCalendarFeed.ts +1 -1
- package/Models/DatabaseModels/UserOnCallCalendarFeed.ts +1 -1
- package/Server/API/AIBillingAPI.ts +1 -0
- package/Server/API/AIInsightAPI.ts +1 -4
- package/Server/API/AIInvestigationAPI.ts +1 -4
- package/Server/API/AIReadinessAPI.ts +4 -5
- package/Server/API/AlertAPI.ts +1 -0
- package/Server/API/AutoRemediationAPI.ts +1 -4
- package/Server/API/BaseAPI.ts +13 -0
- package/Server/API/BaseAnalyticsAPI.ts +80 -9
- package/Server/API/BillingAPI.ts +2 -0
- package/Server/API/BillingInvoiceAPI.ts +1 -0
- package/Server/API/BillingPaymentMethodAPI.ts +2 -0
- package/Server/API/CodeFixRunAPI.ts +1 -3
- package/Server/API/CommonAPI.ts +68 -4
- package/Server/API/DashboardAPI.ts +12 -12
- package/Server/API/GlobalConfigAPI.ts +17 -0
- package/Server/API/IncidentAPI.ts +2 -0
- package/Server/API/IncidentEpisodeAPI.ts +1 -0
- package/Server/API/NotificationAPI.ts +1 -0
- package/Server/API/OnCallCalendarAPI.ts +4 -5
- package/Server/API/OnCallDutyPolicyAPI.ts +7 -0
- package/Server/API/OnCallReadinessAPI.ts +4 -1
- package/Server/API/OnCallScheduleTimelineAPI.ts +731 -0
- package/Server/API/ProjectAPI.ts +1 -0
- package/Server/API/ScheduledMaintenanceAPI.ts +1 -0
- package/Server/API/StatusPageAPI.ts +161 -32
- package/Server/API/TeamMemberAPI.ts +3 -0
- package/Server/API/UserCallAPI.ts +2 -0
- package/Server/API/UserEmailAPI.ts +2 -0
- package/Server/API/UserIncomingCallNumberAPI.ts +2 -0
- package/Server/API/UserMicrosoftTeamsAPI.ts +1 -0
- package/Server/API/UserSlackAPI.ts +1 -0
- package/Server/API/UserSmsAPI.ts +2 -0
- package/Server/API/UserTotpAuthAPI.ts +1 -0
- package/Server/API/UserWebAuthnAPI.ts +2 -0
- package/Server/API/UserWebhookAPI.ts +1 -0
- package/Server/API/UserWhatsAppAPI.ts +2 -0
- package/Server/Middleware/MasterAdminAuthorization.ts +13 -2
- package/Server/Middleware/UserAuthorization.ts +79 -5
- package/Server/Services/ApiKeyPermissionService.ts +101 -4
- package/Server/Services/DatabaseService.ts +245 -0
- package/Server/Services/DetectionRuleService.ts +5 -4
- package/Server/Services/OnCallDutyPolicyChildService.ts +261 -0
- package/Server/Services/OnCallDutyPolicyEscalationRuleScheduleService.ts +2 -2
- package/Server/Services/OnCallDutyPolicyEscalationRuleService.ts +2 -2
- package/Server/Services/OnCallDutyPolicyEscalationRuleTeamService.ts +2 -2
- package/Server/Services/OnCallDutyPolicyEscalationRuleUserService.ts +2 -2
- package/Server/Services/PayAsYouGoBillingService.ts +23 -28
- package/Server/Services/ProjectService.ts +18 -0
- package/Server/Services/RumSessionPinService.ts +274 -22
- package/Server/Services/TeamPermissionService.ts +120 -26
- package/Server/Services/ThreatIntelFeedService.ts +6 -3
- package/Server/Types/Database/Permissions/BasePermission.ts +9 -7
- package/Server/Types/Database/Permissions/Index.ts +75 -11
- package/Server/Types/Database/Permissions/TablePermission.ts +24 -28
- package/Server/Utils/AI/AIChatPrivacyFilter.ts +8 -0
- package/Server/Utils/AI/AIRunPrivacyFilter.ts +8 -0
- package/Server/Utils/MasterAdminPageAccess.ts +61 -0
- package/Server/Utils/Monitor/MonitorAlert.ts +3 -1
- package/Server/Utils/Monitor/MonitorIncident.ts +3 -1
- package/Server/Utils/OnCall/OnCallCalendarFeedRenderer.ts +1 -1
- package/Server/Utils/Realtime.ts +163 -45
- package/Server/Utils/SecurityEvent/DetectionRuleEvaluator.ts +11 -28
- package/Server/Utils/SecurityEvent/GoogleSecOpsSeverityRepair.ts +170 -0
- package/Server/Utils/SecurityEvent/Sigma/SigmaClickhouseCompiler.ts +1 -1
- package/Server/Utils/SecurityEvent/ThreatIntel/ThreatIntelFeedPoller.ts +6 -2
- package/Server/Utils/SecurityEvent/ThreatIntel/ThreatIntelMatcher.ts +10 -9
- package/Tests/App/Dashboard/AffectedResourcesPicker.test.tsx +1059 -0
- package/Tests/App/Dashboard/AffectedResourcesPickerEditForm.test.tsx +376 -0
- package/Tests/App/Dashboard/AffectedResourcesPickerHiddenTypes.test.tsx +757 -0
- package/Tests/App/Dashboard/AffectedResourcesSummaryStep.test.tsx +307 -0
- package/Tests/App/Dashboard/ArgumentsFormGroupByUnlistedAttributes.test.tsx +131 -0
- package/Tests/App/Dashboard/DashboardHeaderRequests.test.tsx +1 -1
- package/Tests/App/Dashboard/DashboardMonitorLabelVariable.test.tsx +9 -1
- package/Tests/App/Dashboard/DashboardVariableAllContract.test.tsx +24 -0
- package/Tests/App/Dashboard/DashboardVariableSelector.test.tsx +162 -8
- package/Tests/App/Dashboard/EntityFilterDropdownArchivedSlos.test.tsx +105 -6
- package/Tests/App/Dashboard/EntityFilterDropdownUnlistedSelection.test.tsx +434 -0
- package/Tests/App/Dashboard/EscalationRuleReadiness.test.tsx +276 -1
- package/Tests/App/Dashboard/OnCallCalendarFeedSideMenus.test.tsx +9 -1
- package/Tests/App/Dashboard/PayAsYouGoConsentGate.test.tsx +58 -42
- package/Tests/App/Dashboard/PayAsYouGoNotices.test.tsx +42 -5
- package/Tests/App/Dashboard/ResourceAuditLogsSideMenus.test.tsx +34 -23
- package/Tests/App/Dashboard/ScheduleTimeline.test.tsx +1580 -0
- package/Tests/App/Dashboard/ScheduleTimelineAPI.test.ts +280 -0
- package/Tests/App/Dashboard/ScheduleTimelineModel.test.ts +673 -0
- package/Tests/App/Dashboard/SecurityEventConnectionDiagnostics.test.tsx +95 -68
- package/Tests/App/Dashboard/SecurityEventsDetectionRulesPage.test.tsx +86 -3
- package/Tests/App/Dashboard/SecurityEventsEmptyState.test.tsx +28 -3
- package/Tests/App/Dashboard/SecurityEventsExplorer.test.tsx +761 -0
- package/Tests/App/Dashboard/SecurityEventsGuideContent.test.ts +1313 -0
- package/Tests/App/Dashboard/SecurityEventsHowItWorksCard.test.tsx +536 -0
- package/Tests/App/Dashboard/SecurityEventsNoResults.test.tsx +222 -0
- package/Tests/App/Dashboard/SecurityEventsThreatIntelPage.test.tsx +199 -0
- package/Tests/App/Dashboard/SecurityEventsVolumeChart.test.tsx +321 -0
- package/Tests/App/Dashboard/SloOverviewHero.test.tsx +171 -36
- package/Tests/App/Dashboard/SloViewSideMenu.test.tsx +215 -0
- package/Tests/App/Dashboard/SloViewSideMenuCounts.test.tsx +40 -3
- package/Tests/App/PublicDashboard/DashboardVariableSelector.test.tsx +12 -4
- package/Tests/App/PublicDashboard/PublicDashboardWidgetListAuth.test.tsx +623 -0
- package/Tests/Models/OnCallCalendarFeedModels.test.ts +23 -1
- package/Tests/Server/API/AIChatRouteAuthorization.test.ts +138 -5
- package/Tests/Server/API/AIGenerationProjectAIToggle.test.ts +187 -0
- package/Tests/Server/API/AIInvestigationAvailabilityAuthorization.test.ts +51 -3
- package/Tests/Server/API/AIInvestigationEvidenceAPI.test.ts +55 -2
- package/Tests/Server/API/BaseAnalyticsAPIAggregateCache.test.ts +729 -0
- package/Tests/Server/API/BillingPayAsYouGoStatus.test.ts +93 -7
- package/Tests/Server/API/BillingPaymentMethodAPI.test.ts +36 -3
- package/Tests/Server/API/CommonAPIAuthGuard.test.ts +1003 -24
- package/Tests/Server/API/DashboardPublicRateLimit.test.ts +6 -3
- package/Tests/Server/API/ExpiredSessionAIRoutes.test.ts +708 -0
- package/Tests/Server/API/ExpiredSessionCustomRoutes.test.ts +928 -0
- package/Tests/Server/API/ExpiredSessionMonitorTemplate.test.ts +319 -0
- package/Tests/Server/API/ExpiredSessionOnCallDutyPolicy.test.ts +336 -0
- package/Tests/Server/API/ExpiredSessionRouteGuards.test.ts +820 -0
- package/Tests/Server/API/GlobalConfigLicense.test.ts +140 -0
- package/Tests/Server/API/NotificationChannelVerificationAPI.test.ts +115 -12
- package/Tests/Server/API/OnCallCalendarAPI.test.ts +375 -8
- package/Tests/Server/API/OnCallReadinessAPI.test.ts +175 -17
- package/Tests/Server/API/OnCallScheduleTimelineAPI.test.ts +1513 -0
- package/Tests/Server/API/OnCallSetupReminderAPI.test.ts +119 -7
- package/Tests/Server/API/ProjectScopedCustomRouteAuth.test.ts +111 -4
- package/Tests/Server/API/PublicRouteInvalidAccessToken.test.ts +615 -0
- package/Tests/Server/API/SecurityEventAttributesAPI.test.ts +89 -2
- package/Tests/Server/API/SessionReplayAPI.test.ts +121 -0
- package/Tests/Server/API/StatusPageMasterPasswordRateLimit.test.ts +4 -2
- package/Tests/Server/API/StatusPagePostmortemVisibility.test.ts +441 -0
- package/Tests/Server/API/StatusPageTestEmailReportAuth.test.ts +664 -0
- package/Tests/Server/API/TeamMemberRemoveUserFromProjectAPI.test.ts +7 -0
- package/Tests/Server/API/UserIncomingCallNumberApi.test.ts +6 -0
- package/Tests/Server/API/UserNotificationSettingAPI.test.ts +65 -4
- package/Tests/Server/API/UserProjectsAPI.test.ts +63 -3
- package/Tests/Server/API/UserTotpAuthAPI.test.ts +48 -2
- package/Tests/Server/API/UserWebAuthnAuthenticationOptionsRoute.test.ts +11 -2
- package/Tests/Server/API/UserWebAuthnBackupCodeMinting.test.ts +46 -3
- package/Tests/Server/API/UserWebAuthnPasskeyAPI.test.ts +18 -2
- package/Tests/Server/API/ZZVerifyChatsAuth.test.ts +24 -7
- package/Tests/Server/Middleware/ExpiredSessionUserMiddleware.test.ts +563 -0
- package/Tests/Server/Middleware/MasterAdminAuthorization.test.ts +299 -19
- package/Tests/Server/Middleware/PublicRouteUserMiddleware.test.ts +453 -0
- package/Tests/Server/Services/AIChatPrivacyPin.test.ts +24 -0
- package/Tests/Server/Services/ApiKeyPermissionSecurity.test.ts +2 -0
- package/Tests/Server/Services/ApiKeyPermissionService.test.ts +3 -3
- package/Tests/Server/Services/DatabaseServiceCreateSuppliedId.test.ts +147 -0
- package/Tests/Server/Services/DatabaseServiceLoginBeforeHooks.test.ts +1078 -0
- package/Tests/Server/Services/DatabaseServiceTenantRelationGuard.test.ts +259 -0
- package/Tests/Server/Services/DatabaseServiceWriteOperatorValues.test.ts +147 -0
- package/Tests/Server/Services/MonitorPayAsYouGoBilling.test.ts +115 -1
- package/Tests/Server/Services/OnCallChildCreateAuthorizationPostgres.test.ts +711 -0
- package/Tests/Server/Services/OnCallDutyPolicyChildService.test.ts +733 -0
- package/Tests/Server/Services/PayAsYouGoBillingService.test.ts +190 -140
- package/Tests/Server/Services/PayAsYouGoStripeRateLimitBudget.test.ts +4 -9
- package/Tests/Server/Services/PermissionBlockDeletion.test.ts +780 -0
- package/Tests/Server/Services/PermissionBlockDeletionPostgres.test.ts +628 -0
- package/Tests/Server/Services/ProjectServiceCreateSubscriptionStarted.test.ts +77 -1
- package/Tests/Server/Services/RumSessionPinCreatePermission.test.ts +715 -0
- package/Tests/Server/Services/TeamMemberMultiTenantReadPostgres.test.ts +394 -0
- package/Tests/Server/Services/TeamPrivilegeEscalation.test.ts +6 -0
- package/Tests/Server/Services/TelemetryPayAsYouGoBilling.test.ts +131 -0
- package/Tests/Server/Services/UserNotificationRuleAdminGuards.test.ts +13 -2
- package/Tests/Server/Types/Database/Permissions/ModelPermissionAnonymousRefusal.test.ts +518 -0
- package/Tests/Server/Types/Database/Permissions/MultiTenantPermissions.test.ts +350 -0
- package/Tests/Server/Types/Database/Permissions/OnCallCalendarFeedPermissions.test.ts +282 -25
- package/Tests/Server/Types/Database/Permissions/TableLevelBlockPermission.test.ts +459 -0
- package/Tests/Server/Utils/AI/AIRunPrivacyFilter.test.ts +101 -9
- package/Tests/Server/Utils/AI/ChatAgentHelpers.test.ts +88 -4
- package/Tests/Server/Utils/AI/Toolbox/ExceptionTools.test.ts +459 -0
- package/Tests/Server/Utils/AI/Toolbox/LogTools.test.ts +794 -0
- package/Tests/Server/Utils/AI/Toolbox/RecentChangesTools.test.ts +574 -0
- package/Tests/Server/Utils/AI/Toolbox/SecurityEventTools.test.ts +596 -0
- package/Tests/Server/Utils/CaptchaRequestAndLogging.test.ts +395 -0
- package/Tests/Server/Utils/MasterAdminPageAccess.test.ts +251 -0
- package/Tests/Server/Utils/Monitor/MonitorActionTimestamps.test.ts +616 -0
- package/Tests/Server/Utils/Realtime.test.ts +502 -0
- package/Tests/Server/Utils/SecurityEvent/Connectors/GoogleSecOps/GoogleSecOpsConnectorSeverity.test.ts +216 -0
- package/Tests/Server/Utils/SecurityEvent/DetectionRuleEvaluator.test.ts +142 -0
- package/Tests/Server/Utils/SecurityEvent/GoogleSecOpsSeverityRepair.test.ts +140 -0
- package/Tests/Server/Utils/SecurityEvent/GoogleSecOpsSeverityRepairClickhouseIntegration.test.ts +542 -0
- package/Tests/Server/Utils/Telemetry/ChangeEventRow.test.ts +743 -0
- package/Tests/Server/Utils/Telemetry/RuntimeMetrics.test.ts +465 -0
- package/Tests/Server/Utils/Workspace/MicrosoftTeams/Messages/Alert.test.ts +202 -0
- package/Tests/Server/Utils/Workspace/MicrosoftTeams/Messages/Incident.test.ts +194 -0
- package/Tests/Server/Utils/Workspace/MicrosoftTeams/Messages/ScheduledMaintenance.test.ts +231 -0
- package/Tests/Server/Utils/Workspace/Slack/Messages/Alert.test.ts +194 -0
- package/Tests/Server/Utils/Workspace/Slack/Messages/AlertEpisode.test.ts +194 -0
- package/Tests/Server/Utils/Workspace/Slack/Messages/Incident.test.ts +194 -0
- package/Tests/Server/Utils/Workspace/Slack/Messages/IncidentEpisode.test.ts +194 -0
- package/Tests/Server/Utils/Workspace/Slack/Messages/ScheduledMaintenance.test.ts +247 -0
- package/Tests/Types/AI/AIInsightEvidence.test.ts +206 -0
- package/Tests/Types/BaseDatabase/DatabaseCommonInteractionPropsUtilAnonymous.test.ts +144 -0
- package/Tests/Types/Call/CallProvider.test.ts +528 -0
- package/Tests/Types/Kubernetes/KubernetesCostIngest.test.ts +236 -0
- package/Tests/Types/OnCallDutyPolicy/ScheduleTimeline.test.ts +736 -0
- package/Tests/Types/OnCallDutyPolicy/ScheduleTimelineLayout.test.ts +996 -0
- package/Tests/Types/SecurityEvent/SigmaRule.test.ts +142 -0
- package/Tests/Types/Workflow/Components/JSON.test.ts +182 -0
- package/Tests/UI/Components/BasicFormDropdownNormalization.test.tsx +116 -1
- package/Tests/UI/Components/Dropdown/DropdownAsyncOptions.test.tsx +81 -0
- package/Tests/UI/Components/EditionLabelLicenseRefresh.test.tsx +89 -1
- package/Tests/UI/Components/EventAttachmentList.test.tsx +174 -0
- package/Tests/UI/Components/Forms/BasicFormBurnRateTemplateDefaults.test.tsx +395 -0
- package/Tests/UI/Components/Forms/BasicFormCollapsibleSections.test.tsx +286 -0
- package/Tests/UI/Components/Forms/FormSummary.test.tsx +128 -0
- package/Tests/UI/Components/ModelTable/BaseModelTableQueryChange.test.tsx +365 -0
- package/Tests/UI/Components/OpenAuthenticatedUrl.test.ts +358 -0
- package/Tests/UI/Components/SessionAwareImage.test.tsx +496 -0
- package/Tests/UI/Components/TelemetryHistogramZeroBuckets.test.tsx +190 -0
- package/Tests/UI/Components/TooltipInteractive.test.tsx +97 -0
- package/Tests/UI/MicrosoftTeams/MicrosoftTeamsChatsCardInstallGuidance.test.tsx +1 -1
- package/Tests/UI/Monitor/EvaluationLogListTimestamps.test.tsx +367 -0
- package/Tests/UI/Utils/API/BaseAPIRefreshSession.test.ts +1087 -0
- package/Tests/UI/Utils/API/DashboardHost.ts +12 -0
- package/Tests/UI/Utils/API/FakeAxiosServer.ts +183 -0
- package/Tests/UI/Utils/Breadcrumb/fixtures/RealBreadcrumbTrails.ts +10 -0
- package/Tests/UI/Utils/Breadcrumb/fixtures/RealRoutePatterns.ts +2 -0
- package/Tests/UI/Utils/Cookie.test.ts +440 -0
- package/Tests/UI/Utils/ModelAPIRequestClient.test.ts +278 -0
- package/Tests/UI/Utils/Navigation.test.ts +33 -0
- package/Tests/UI/Utils/PricingPlan.test.ts +295 -0
- package/Tests/UI/Utils/Realtime.test.ts +759 -0
- package/Tests/UI/Utils/Telemetry/Telemetry.test.ts +500 -0
- package/Tests/Utils/APIInstanceDispatch.test.ts +311 -0
- package/Tests/Utils/SecurityEvent/GoogleSecOpsAlertNormalizerSeverity.test.ts +565 -0
- package/Types/BaseDatabase/DatabaseCommonInteractionPropsUtil.ts +40 -0
- package/Types/Monitor/MonitorEvaluationSummary.ts +3 -0
- package/Types/OnCallDutyPolicy/ScheduleTimeline.ts +507 -0
- package/Types/OnCallDutyPolicy/ScheduleTimelineLayout.ts +589 -0
- package/Types/Realtime/EventName.ts +11 -0
- package/Types/SecurityEvent/DetectionFindingConstants.ts +14 -0
- package/Types/SecurityEvent/OcsfSeverity.ts +31 -26
- package/Types/SecurityEvent/SigmaRule.ts +51 -0
- package/Types/SecurityEvent/ThreatIntelConstants.ts +18 -0
- package/UI/Components/AttachmentList/EventAttachmentList.tsx +30 -2
- package/UI/Components/Dashboard/DashboardVariableControl.tsx +12 -2
- package/UI/Components/Dropdown/Dropdown.tsx +6 -1
- package/UI/Components/EditionLabel/EditionLabel.tsx +12 -0
- package/UI/Components/EventItem/EventItem.tsx +12 -1
- package/UI/Components/Forms/BasicForm.tsx +151 -126
- package/UI/Components/Forms/CollapsibleFormSection.tsx +63 -0
- package/UI/Components/Forms/Fields/FormField.tsx +10 -4
- package/UI/Components/Forms/FormSummary.tsx +7 -0
- package/UI/Components/Forms/Types/Field.ts +10 -0
- package/UI/Components/Markdown.tsx/MarkdownViewer.tsx +2 -1
- package/UI/Components/Markdown.tsx/SessionAwareImage.tsx +122 -0
- package/UI/Components/ModelTable/BaseModelTable.tsx +34 -5
- package/UI/Components/ModelTable/TableView.tsx +1 -1
- package/UI/Components/TelemetryViewer/components/TelemetryHistogram.tsx +8 -1
- package/UI/Components/Tooltip/Tooltip.tsx +8 -1
- package/UI/Utils/API/API.ts +173 -12
- package/UI/Utils/API/RequestOptions.ts +11 -0
- package/UI/Utils/AnalyticsModelAPI/AnalyticsModelAPI.ts +31 -7
- package/UI/Utils/ModelAPI/ModelAPI.ts +30 -9
- package/UI/Utils/Navigation.ts +9 -0
- package/UI/Utils/OpenAuthenticatedUrl.ts +154 -0
- package/UI/Utils/Realtime.ts +176 -30
- package/Utils/API.ts +14 -5
- package/Utils/SecurityEvent/GoogleSecOpsAlertNormalizer.ts +157 -7
- package/Utils/SecurityEvent/Sigma/SigmaRuleParser.ts +9 -17
- package/Utils/Slo/SloBurnRateTemplate.ts +2 -2
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyScheduleCalendarFeed.js +1 -1
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyScheduleCalendarFeed.js.map +1 -1
- package/build/dist/Models/DatabaseModels/ProjectOnCallCalendarFeed.js +1 -1
- package/build/dist/Models/DatabaseModels/ProjectOnCallCalendarFeed.js.map +1 -1
- package/build/dist/Models/DatabaseModels/UserOnCallCalendarFeed.js +1 -1
- package/build/dist/Models/DatabaseModels/UserOnCallCalendarFeed.js.map +1 -1
- package/build/dist/Server/API/AIBillingAPI.js +1 -1
- package/build/dist/Server/API/AIBillingAPI.js.map +1 -1
- package/build/dist/Server/API/AIInsightAPI.js +1 -4
- package/build/dist/Server/API/AIInsightAPI.js.map +1 -1
- package/build/dist/Server/API/AIInvestigationAPI.js +1 -4
- package/build/dist/Server/API/AIInvestigationAPI.js.map +1 -1
- package/build/dist/Server/API/AIReadinessAPI.js +1 -3
- package/build/dist/Server/API/AIReadinessAPI.js.map +1 -1
- package/build/dist/Server/API/AlertAPI.js +1 -1
- package/build/dist/Server/API/AlertAPI.js.map +1 -1
- package/build/dist/Server/API/AutoRemediationAPI.js +1 -4
- package/build/dist/Server/API/AutoRemediationAPI.js.map +1 -1
- package/build/dist/Server/API/BaseAPI.js +12 -0
- package/build/dist/Server/API/BaseAPI.js.map +1 -1
- package/build/dist/Server/API/BaseAnalyticsAPI.js +55 -10
- package/build/dist/Server/API/BaseAnalyticsAPI.js.map +1 -1
- package/build/dist/Server/API/BillingAPI.js +2 -2
- package/build/dist/Server/API/BillingAPI.js.map +1 -1
- package/build/dist/Server/API/BillingInvoiceAPI.js +1 -1
- package/build/dist/Server/API/BillingInvoiceAPI.js.map +1 -1
- package/build/dist/Server/API/BillingPaymentMethodAPI.js +2 -2
- package/build/dist/Server/API/BillingPaymentMethodAPI.js.map +1 -1
- package/build/dist/Server/API/CodeFixRunAPI.js +1 -3
- package/build/dist/Server/API/CodeFixRunAPI.js.map +1 -1
- package/build/dist/Server/API/CommonAPI.js +50 -5
- package/build/dist/Server/API/CommonAPI.js.map +1 -1
- package/build/dist/Server/API/DashboardAPI.js +12 -12
- package/build/dist/Server/API/DashboardAPI.js.map +1 -1
- package/build/dist/Server/API/GlobalConfigAPI.js +12 -0
- package/build/dist/Server/API/GlobalConfigAPI.js.map +1 -1
- package/build/dist/Server/API/IncidentAPI.js +2 -2
- package/build/dist/Server/API/IncidentAPI.js.map +1 -1
- package/build/dist/Server/API/IncidentEpisodeAPI.js +1 -1
- package/build/dist/Server/API/IncidentEpisodeAPI.js.map +1 -1
- package/build/dist/Server/API/NotificationAPI.js +1 -1
- package/build/dist/Server/API/NotificationAPI.js.map +1 -1
- package/build/dist/Server/API/OnCallCalendarAPI.js +1 -4
- package/build/dist/Server/API/OnCallCalendarAPI.js.map +1 -1
- package/build/dist/Server/API/OnCallDutyPolicyAPI.js +6 -0
- package/build/dist/Server/API/OnCallDutyPolicyAPI.js.map +1 -1
- package/build/dist/Server/API/OnCallReadinessAPI.js +4 -1
- package/build/dist/Server/API/OnCallReadinessAPI.js.map +1 -1
- package/build/dist/Server/API/OnCallScheduleTimelineAPI.js +494 -0
- package/build/dist/Server/API/OnCallScheduleTimelineAPI.js.map +1 -0
- package/build/dist/Server/API/ProjectAPI.js +1 -1
- package/build/dist/Server/API/ProjectAPI.js.map +1 -1
- package/build/dist/Server/API/ScheduledMaintenanceAPI.js +1 -1
- package/build/dist/Server/API/ScheduledMaintenanceAPI.js.map +1 -1
- package/build/dist/Server/API/StatusPageAPI.js +125 -33
- package/build/dist/Server/API/StatusPageAPI.js.map +1 -1
- package/build/dist/Server/API/TeamMemberAPI.js +3 -3
- package/build/dist/Server/API/TeamMemberAPI.js.map +1 -1
- package/build/dist/Server/API/UserCallAPI.js +2 -2
- package/build/dist/Server/API/UserCallAPI.js.map +1 -1
- package/build/dist/Server/API/UserEmailAPI.js +2 -2
- package/build/dist/Server/API/UserEmailAPI.js.map +1 -1
- package/build/dist/Server/API/UserIncomingCallNumberAPI.js +2 -2
- package/build/dist/Server/API/UserIncomingCallNumberAPI.js.map +1 -1
- package/build/dist/Server/API/UserMicrosoftTeamsAPI.js +1 -1
- package/build/dist/Server/API/UserMicrosoftTeamsAPI.js.map +1 -1
- package/build/dist/Server/API/UserSlackAPI.js +1 -1
- package/build/dist/Server/API/UserSlackAPI.js.map +1 -1
- package/build/dist/Server/API/UserSmsAPI.js +2 -2
- package/build/dist/Server/API/UserSmsAPI.js.map +1 -1
- package/build/dist/Server/API/UserTotpAuthAPI.js +1 -1
- package/build/dist/Server/API/UserTotpAuthAPI.js.map +1 -1
- package/build/dist/Server/API/UserWebAuthnAPI.js +2 -2
- package/build/dist/Server/API/UserWebAuthnAPI.js.map +1 -1
- package/build/dist/Server/API/UserWebhookAPI.js +1 -1
- package/build/dist/Server/API/UserWebhookAPI.js.map +1 -1
- package/build/dist/Server/API/UserWhatsAppAPI.js +2 -2
- package/build/dist/Server/API/UserWhatsAppAPI.js.map +1 -1
- package/build/dist/Server/Middleware/MasterAdminAuthorization.js +11 -2
- package/build/dist/Server/Middleware/MasterAdminAuthorization.js.map +1 -1
- package/build/dist/Server/Middleware/UserAuthorization.js +64 -4
- package/build/dist/Server/Middleware/UserAuthorization.js.map +1 -1
- package/build/dist/Server/Services/ApiKeyPermissionService.js +80 -4
- package/build/dist/Server/Services/ApiKeyPermissionService.js.map +1 -1
- package/build/dist/Server/Services/DatabaseService.js +171 -0
- package/build/dist/Server/Services/DatabaseService.js.map +1 -1
- package/build/dist/Server/Services/DetectionRuleService.js +4 -4
- package/build/dist/Server/Services/DetectionRuleService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyChildService.js +170 -0
- package/build/dist/Server/Services/OnCallDutyPolicyChildService.js.map +1 -0
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleScheduleService.js +2 -2
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleScheduleService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleService.js +2 -2
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleTeamService.js +2 -2
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleTeamService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleUserService.js +2 -2
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleUserService.js.map +1 -1
- package/build/dist/Server/Services/PayAsYouGoBillingService.js +20 -27
- package/build/dist/Server/Services/PayAsYouGoBillingService.js.map +1 -1
- package/build/dist/Server/Services/ProjectService.js +17 -0
- package/build/dist/Server/Services/ProjectService.js.map +1 -1
- package/build/dist/Server/Services/RumSessionPinService.js +180 -16
- package/build/dist/Server/Services/RumSessionPinService.js.map +1 -1
- package/build/dist/Server/Services/TeamPermissionService.js +89 -27
- package/build/dist/Server/Services/TeamPermissionService.js.map +1 -1
- package/build/dist/Server/Services/ThreatIntelFeedService.js +5 -4
- package/build/dist/Server/Services/ThreatIntelFeedService.js.map +1 -1
- package/build/dist/Server/Types/Database/Permissions/BasePermission.js +9 -6
- package/build/dist/Server/Types/Database/Permissions/BasePermission.js.map +1 -1
- package/build/dist/Server/Types/Database/Permissions/Index.js +60 -6
- package/build/dist/Server/Types/Database/Permissions/Index.js.map +1 -1
- package/build/dist/Server/Types/Database/Permissions/TablePermission.js +14 -13
- package/build/dist/Server/Types/Database/Permissions/TablePermission.js.map +1 -1
- package/build/dist/Server/Utils/AI/AIChatPrivacyFilter.js +7 -0
- package/build/dist/Server/Utils/AI/AIChatPrivacyFilter.js.map +1 -1
- package/build/dist/Server/Utils/AI/AIRunPrivacyFilter.js +7 -0
- package/build/dist/Server/Utils/AI/AIRunPrivacyFilter.js.map +1 -1
- package/build/dist/Server/Utils/MasterAdminPageAccess.js +39 -0
- package/build/dist/Server/Utils/MasterAdminPageAccess.js.map +1 -0
- package/build/dist/Server/Utils/Monitor/MonitorAlert.js +3 -1
- package/build/dist/Server/Utils/Monitor/MonitorAlert.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorIncident.js +3 -1
- package/build/dist/Server/Utils/Monitor/MonitorIncident.js.map +1 -1
- package/build/dist/Server/Utils/Realtime.js +126 -37
- package/build/dist/Server/Utils/Realtime.js.map +1 -1
- package/build/dist/Server/Utils/SecurityEvent/DetectionRuleEvaluator.js +7 -25
- package/build/dist/Server/Utils/SecurityEvent/DetectionRuleEvaluator.js.map +1 -1
- package/build/dist/Server/Utils/SecurityEvent/GoogleSecOpsSeverityRepair.js +127 -0
- package/build/dist/Server/Utils/SecurityEvent/GoogleSecOpsSeverityRepair.js.map +1 -0
- package/build/dist/Server/Utils/SecurityEvent/Sigma/SigmaClickhouseCompiler.js +1 -1
- package/build/dist/Server/Utils/SecurityEvent/Sigma/SigmaClickhouseCompiler.js.map +1 -1
- package/build/dist/Server/Utils/SecurityEvent/ThreatIntel/ThreatIntelFeedPoller.js +3 -2
- package/build/dist/Server/Utils/SecurityEvent/ThreatIntel/ThreatIntelFeedPoller.js.map +1 -1
- package/build/dist/Server/Utils/SecurityEvent/ThreatIntel/ThreatIntelMatcher.js +4 -8
- package/build/dist/Server/Utils/SecurityEvent/ThreatIntel/ThreatIntelMatcher.js.map +1 -1
- package/build/dist/Types/BaseDatabase/DatabaseCommonInteractionPropsUtil.js +31 -1
- package/build/dist/Types/BaseDatabase/DatabaseCommonInteractionPropsUtil.js.map +1 -1
- package/build/dist/Types/OnCallDutyPolicy/ScheduleTimeline.js +321 -0
- package/build/dist/Types/OnCallDutyPolicy/ScheduleTimeline.js.map +1 -0
- package/build/dist/Types/OnCallDutyPolicy/ScheduleTimelineLayout.js +372 -0
- package/build/dist/Types/OnCallDutyPolicy/ScheduleTimelineLayout.js.map +1 -0
- package/build/dist/Types/Realtime/EventName.js +10 -0
- package/build/dist/Types/Realtime/EventName.js.map +1 -1
- package/build/dist/Types/SecurityEvent/DetectionFindingConstants.js +11 -0
- package/build/dist/Types/SecurityEvent/DetectionFindingConstants.js.map +1 -1
- package/build/dist/Types/SecurityEvent/OcsfSeverity.js +30 -25
- package/build/dist/Types/SecurityEvent/OcsfSeverity.js.map +1 -1
- package/build/dist/Types/SecurityEvent/SigmaRule.js +47 -0
- package/build/dist/Types/SecurityEvent/SigmaRule.js.map +1 -1
- package/build/dist/Types/SecurityEvent/ThreatIntelConstants.js +14 -0
- package/build/dist/Types/SecurityEvent/ThreatIntelConstants.js.map +1 -1
- package/build/dist/UI/Components/AttachmentList/EventAttachmentList.js +9 -4
- package/build/dist/UI/Components/AttachmentList/EventAttachmentList.js.map +1 -1
- package/build/dist/UI/Components/Dashboard/DashboardVariableControl.js +10 -2
- package/build/dist/UI/Components/Dashboard/DashboardVariableControl.js.map +1 -1
- package/build/dist/UI/Components/Dropdown/Dropdown.js +5 -1
- package/build/dist/UI/Components/Dropdown/Dropdown.js.map +1 -1
- package/build/dist/UI/Components/EditionLabel/EditionLabel.js +11 -0
- package/build/dist/UI/Components/EditionLabel/EditionLabel.js.map +1 -1
- package/build/dist/UI/Components/EventItem/EventItem.js +2 -2
- package/build/dist/UI/Components/EventItem/EventItem.js.map +1 -1
- package/build/dist/UI/Components/Forms/BasicForm.js +70 -64
- package/build/dist/UI/Components/Forms/BasicForm.js.map +1 -1
- package/build/dist/UI/Components/Forms/CollapsibleFormSection.js +27 -0
- package/build/dist/UI/Components/Forms/CollapsibleFormSection.js.map +1 -0
- package/build/dist/UI/Components/Forms/Fields/FormField.js +10 -7
- package/build/dist/UI/Components/Forms/Fields/FormField.js.map +1 -1
- package/build/dist/UI/Components/Forms/FormSummary.js +7 -0
- package/build/dist/UI/Components/Forms/FormSummary.js.map +1 -1
- package/build/dist/UI/Components/Markdown.tsx/MarkdownViewer.js +2 -1
- package/build/dist/UI/Components/Markdown.tsx/MarkdownViewer.js.map +1 -1
- package/build/dist/UI/Components/Markdown.tsx/SessionAwareImage.js +84 -0
- package/build/dist/UI/Components/Markdown.tsx/SessionAwareImage.js.map +1 -0
- package/build/dist/UI/Components/ModelTable/BaseModelTable.js +14 -1
- package/build/dist/UI/Components/ModelTable/BaseModelTable.js.map +1 -1
- package/build/dist/UI/Components/ModelTable/TableView.js +1 -1
- package/build/dist/UI/Components/ModelTable/TableView.js.map +1 -1
- package/build/dist/UI/Components/TelemetryViewer/components/TelemetryHistogram.js +8 -1
- package/build/dist/UI/Components/TelemetryViewer/components/TelemetryHistogram.js.map +1 -1
- package/build/dist/UI/Components/Tooltip/Tooltip.js +2 -1
- package/build/dist/UI/Components/Tooltip/Tooltip.js.map +1 -1
- package/build/dist/UI/Utils/API/API.js +143 -19
- package/build/dist/UI/Utils/API/API.js.map +1 -1
- package/build/dist/UI/Utils/AnalyticsModelAPI/AnalyticsModelAPI.js +21 -7
- package/build/dist/UI/Utils/AnalyticsModelAPI/AnalyticsModelAPI.js.map +1 -1
- package/build/dist/UI/Utils/ModelAPI/ModelAPI.js +26 -9
- package/build/dist/UI/Utils/ModelAPI/ModelAPI.js.map +1 -1
- package/build/dist/UI/Utils/Navigation.js +8 -0
- package/build/dist/UI/Utils/Navigation.js.map +1 -1
- package/build/dist/UI/Utils/OpenAuthenticatedUrl.js +92 -0
- package/build/dist/UI/Utils/OpenAuthenticatedUrl.js.map +1 -0
- package/build/dist/UI/Utils/Realtime.js +120 -15
- package/build/dist/UI/Utils/Realtime.js.map +1 -1
- package/build/dist/Utils/API.js +13 -5
- package/build/dist/Utils/API.js.map +1 -1
- package/build/dist/Utils/SecurityEvent/GoogleSecOpsAlertNormalizer.js +123 -6
- package/build/dist/Utils/SecurityEvent/GoogleSecOpsAlertNormalizer.js.map +1 -1
- package/build/dist/Utils/SecurityEvent/Sigma/SigmaRuleParser.js +4 -18
- package/build/dist/Utils/SecurityEvent/Sigma/SigmaRuleParser.js.map +1 -1
- package/build/dist/Utils/Slo/SloBurnRateTemplate.js +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,496 @@
|
|
|
1
|
+
import SessionAwareImage, {
|
|
2
|
+
enablePrivateImageSessionRefresh,
|
|
3
|
+
isPrivateImageUrl,
|
|
4
|
+
PRIVATE_IMAGE_ROUTE_SEGMENT,
|
|
5
|
+
withCacheBuster,
|
|
6
|
+
} from "../../../UI/Components/Markdown.tsx/SessionAwareImage";
|
|
7
|
+
import API from "../../../UI/Utils/API/API";
|
|
8
|
+
import UserUtil from "../../../UI/Utils/User";
|
|
9
|
+
import "@testing-library/jest-dom";
|
|
10
|
+
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
|
|
11
|
+
import React from "react";
|
|
12
|
+
import { afterEach, beforeEach, describe, expect, it } from "@jest/globals";
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
* Private inline images (pasted into incident notes, postmortems, runbooks)
|
|
16
|
+
* are served from /image/access-token/ and only to a request that carries a
|
|
17
|
+
* session. The dashboard's access-token cookie expires with the 15-minute JWT
|
|
18
|
+
* inside it, and an <img> cannot refresh a session the way a request through
|
|
19
|
+
* the API class does - so once the cookie lapsed, every private image in the
|
|
20
|
+
* markdown came back broken and stayed broken.
|
|
21
|
+
*
|
|
22
|
+
* SessionAwareImage (MarkdownViewer's img renderer) refreshes once on the
|
|
23
|
+
* first failure of a private image and loads it again with a cache-busted src.
|
|
24
|
+
* These tests pin every branch: when it retries, when it gives up, that it
|
|
25
|
+
* retries at most once per image, and that it leaves status-page readers
|
|
26
|
+
* (never signed in to the dashboard) alone.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/*
|
|
30
|
+
* Factories, not automocks: the real modules drag in LocalStorage, Navigation
|
|
31
|
+
* and the whole HTTP client, none of which the component touches beyond these
|
|
32
|
+
* two functions. The defaults are used only by the tests that omit the
|
|
33
|
+
* isSignedIn / refreshSession props.
|
|
34
|
+
*/
|
|
35
|
+
jest.mock("../../../UI/Utils/User", () => {
|
|
36
|
+
return {
|
|
37
|
+
__esModule: true,
|
|
38
|
+
default: {
|
|
39
|
+
isLoggedIn: jest.fn(),
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
jest.mock("../../../UI/Utils/API/API", () => {
|
|
45
|
+
return {
|
|
46
|
+
__esModule: true,
|
|
47
|
+
default: {
|
|
48
|
+
refreshSession: jest.fn(),
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const PRIVATE_SRC: string =
|
|
54
|
+
"https://oneuptime.example/api/file/image/access-token/6a1f1c1e-img";
|
|
55
|
+
const OTHER_PRIVATE_SRC: string =
|
|
56
|
+
"https://oneuptime.example/api/file/image/access-token/7b2e2d2f-img";
|
|
57
|
+
const PUBLIC_SRC: string = "https://cdn.example.com/diagram.png";
|
|
58
|
+
const NOW: number = 1767225600000;
|
|
59
|
+
const ALT: string = "architecture diagram";
|
|
60
|
+
|
|
61
|
+
type RefreshMock = jest.Mock<Promise<boolean>, []>;
|
|
62
|
+
type BooleanMock = jest.Mock<boolean, []>;
|
|
63
|
+
type ErrorHandlerMock = jest.Mock<
|
|
64
|
+
void,
|
|
65
|
+
[React.SyntheticEvent<HTMLImageElement>]
|
|
66
|
+
>;
|
|
67
|
+
|
|
68
|
+
type ImageElementFunction = () => HTMLImageElement;
|
|
69
|
+
|
|
70
|
+
const image: ImageElementFunction = (): HTMLImageElement => {
|
|
71
|
+
return screen.getByAltText(ALT) as HTMLImageElement;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
type FlushFunction = () => Promise<void>;
|
|
75
|
+
|
|
76
|
+
// Lets a settled refresh promise run its .then/.catch before asserting.
|
|
77
|
+
const flushPromises: FlushFunction = async (): Promise<void> => {
|
|
78
|
+
await new Promise<void>((resolve: () => void) => {
|
|
79
|
+
setTimeout(resolve, 0);
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
describe("isPrivateImageUrl", () => {
|
|
84
|
+
it("names the private image route", () => {
|
|
85
|
+
expect(PRIVATE_IMAGE_ROUTE_SEGMENT).toBe("/image/access-token/");
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it.each([
|
|
89
|
+
[PRIVATE_SRC],
|
|
90
|
+
["/api/file/image/access-token/abc"],
|
|
91
|
+
[`${PRIVATE_SRC}?sessionRetry=1`],
|
|
92
|
+
])("is true for %s", (src: string) => {
|
|
93
|
+
expect(isPrivateImageUrl(src)).toBe(true);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it.each([
|
|
97
|
+
["a public CDN url", PUBLIC_SRC],
|
|
98
|
+
["a different file route", "https://oneuptime.example/api/file/image/abc"],
|
|
99
|
+
["an empty string", ""],
|
|
100
|
+
["undefined", undefined],
|
|
101
|
+
["null", null],
|
|
102
|
+
["a number", 42],
|
|
103
|
+
[
|
|
104
|
+
"an object that merely mentions the route",
|
|
105
|
+
{
|
|
106
|
+
toString: (): string => {
|
|
107
|
+
return PRIVATE_SRC;
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
])("is false for %s", (_label: string, src: unknown) => {
|
|
112
|
+
expect(isPrivateImageUrl(src)).toBe(false);
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
describe("withCacheBuster", () => {
|
|
117
|
+
it("starts a query string when there is none", () => {
|
|
118
|
+
expect(withCacheBuster(PRIVATE_SRC, "123")).toBe(
|
|
119
|
+
`${PRIVATE_SRC}?sessionRetry=123`,
|
|
120
|
+
);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it("appends to an existing query string", () => {
|
|
124
|
+
expect(withCacheBuster(`${PRIVATE_SRC}?width=200`, "123")).toBe(
|
|
125
|
+
`${PRIVATE_SRC}?width=200&sessionRetry=123`,
|
|
126
|
+
);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it("encodes the value", () => {
|
|
130
|
+
expect(withCacheBuster(PRIVATE_SRC, "a b&c")).toBe(
|
|
131
|
+
`${PRIVATE_SRC}?sessionRetry=a%20b%26c`,
|
|
132
|
+
);
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
describe("SessionAwareImage", () => {
|
|
137
|
+
let refreshSession: RefreshMock;
|
|
138
|
+
let isSignedIn: BooleanMock;
|
|
139
|
+
let onError: ErrorHandlerMock;
|
|
140
|
+
let dateNowSpy: jest.SpyInstance<number, []>;
|
|
141
|
+
|
|
142
|
+
beforeEach(() => {
|
|
143
|
+
jest.clearAllMocks();
|
|
144
|
+
|
|
145
|
+
refreshSession = jest.fn<Promise<boolean>, []>().mockResolvedValue(true);
|
|
146
|
+
isSignedIn = jest.fn<boolean, []>().mockReturnValue(true);
|
|
147
|
+
onError = jest.fn<void, [React.SyntheticEvent<HTMLImageElement>]>();
|
|
148
|
+
|
|
149
|
+
dateNowSpy = jest.spyOn(Date, "now").mockReturnValue(NOW);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
afterEach(() => {
|
|
153
|
+
dateNowSpy.mockRestore();
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
type RenderImageFunction = (
|
|
157
|
+
props?: Partial<React.ComponentProps<typeof SessionAwareImage>>,
|
|
158
|
+
) => ReturnType<typeof render>;
|
|
159
|
+
|
|
160
|
+
const renderImage: RenderImageFunction = (
|
|
161
|
+
props?: Partial<React.ComponentProps<typeof SessionAwareImage>>,
|
|
162
|
+
): ReturnType<typeof render> => {
|
|
163
|
+
return render(
|
|
164
|
+
<SessionAwareImage
|
|
165
|
+
src={PRIVATE_SRC}
|
|
166
|
+
alt={ALT}
|
|
167
|
+
refreshSession={refreshSession}
|
|
168
|
+
isSignedIn={isSignedIn}
|
|
169
|
+
onError={onError}
|
|
170
|
+
{...props}
|
|
171
|
+
/>,
|
|
172
|
+
);
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
it("renders a plain <img> with the src and the other image props", () => {
|
|
176
|
+
renderImage({ className: "max-w-full", loading: "lazy" });
|
|
177
|
+
|
|
178
|
+
expect(image().tagName).toBe("IMG");
|
|
179
|
+
expect(image()).toHaveAttribute("src", PRIVATE_SRC);
|
|
180
|
+
expect(image()).toHaveAttribute("class", "max-w-full");
|
|
181
|
+
expect(image()).toHaveAttribute("loading", "lazy");
|
|
182
|
+
// The component's own props are not leaked onto the DOM element.
|
|
183
|
+
expect(image()).not.toHaveAttribute("refreshSession");
|
|
184
|
+
expect(image()).not.toHaveAttribute("isSignedIn");
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it("does nothing until the image actually fails", () => {
|
|
188
|
+
renderImage();
|
|
189
|
+
|
|
190
|
+
expect(refreshSession).not.toHaveBeenCalled();
|
|
191
|
+
expect(onError).not.toHaveBeenCalled();
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
describe("a private image failing while signed in", () => {
|
|
195
|
+
it("refreshes the session once and reloads the image with a cache-busted src", async () => {
|
|
196
|
+
renderImage();
|
|
197
|
+
|
|
198
|
+
fireEvent.error(image());
|
|
199
|
+
|
|
200
|
+
await waitFor(() => {
|
|
201
|
+
expect(image()).toHaveAttribute(
|
|
202
|
+
"src",
|
|
203
|
+
`${PRIVATE_SRC}?sessionRetry=${NOW}`,
|
|
204
|
+
);
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
expect(refreshSession).toHaveBeenCalledTimes(1);
|
|
208
|
+
expect(onError).not.toHaveBeenCalled();
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
it("keeps an existing query string when cache-busting", async () => {
|
|
212
|
+
renderImage({ src: `${PRIVATE_SRC}?w=200` });
|
|
213
|
+
|
|
214
|
+
fireEvent.error(image());
|
|
215
|
+
|
|
216
|
+
await waitFor(() => {
|
|
217
|
+
expect(image()).toHaveAttribute(
|
|
218
|
+
"src",
|
|
219
|
+
`${PRIVATE_SRC}?w=200&sessionRetry=${NOW}`,
|
|
220
|
+
);
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
it("gives up after one retry: a second failure goes to onError", async () => {
|
|
225
|
+
renderImage();
|
|
226
|
+
|
|
227
|
+
fireEvent.error(image());
|
|
228
|
+
|
|
229
|
+
await waitFor(() => {
|
|
230
|
+
expect(image().getAttribute("src")).toContain("sessionRetry=");
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
fireEvent.error(image());
|
|
234
|
+
await flushPromises();
|
|
235
|
+
|
|
236
|
+
expect(refreshSession).toHaveBeenCalledTimes(1);
|
|
237
|
+
expect(onError).toHaveBeenCalledTimes(1);
|
|
238
|
+
expect(image()).toHaveAttribute(
|
|
239
|
+
"src",
|
|
240
|
+
`${PRIVATE_SRC}?sessionRetry=${NOW}`,
|
|
241
|
+
);
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
it("calls onError and does not retry when the refresh fails", async () => {
|
|
245
|
+
refreshSession.mockResolvedValue(false);
|
|
246
|
+
|
|
247
|
+
renderImage();
|
|
248
|
+
|
|
249
|
+
fireEvent.error(image());
|
|
250
|
+
|
|
251
|
+
await waitFor(() => {
|
|
252
|
+
expect(onError).toHaveBeenCalledTimes(1);
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
expect(refreshSession).toHaveBeenCalledTimes(1);
|
|
256
|
+
expect(image()).toHaveAttribute("src", PRIVATE_SRC);
|
|
257
|
+
|
|
258
|
+
// The one retry is spent: another failure does not refresh again.
|
|
259
|
+
fireEvent.error(image());
|
|
260
|
+
await flushPromises();
|
|
261
|
+
|
|
262
|
+
expect(refreshSession).toHaveBeenCalledTimes(1);
|
|
263
|
+
expect(onError).toHaveBeenCalledTimes(2);
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
it("calls onError and does not retry when the refresh rejects", async () => {
|
|
267
|
+
refreshSession.mockRejectedValue(new Error("network down"));
|
|
268
|
+
|
|
269
|
+
renderImage();
|
|
270
|
+
|
|
271
|
+
fireEvent.error(image());
|
|
272
|
+
|
|
273
|
+
await waitFor(() => {
|
|
274
|
+
expect(onError).toHaveBeenCalledTimes(1);
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
expect(image()).toHaveAttribute("src", PRIVATE_SRC);
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
it("hands the original error event to onError", async () => {
|
|
281
|
+
refreshSession.mockResolvedValue(false);
|
|
282
|
+
|
|
283
|
+
renderImage();
|
|
284
|
+
|
|
285
|
+
fireEvent.error(image());
|
|
286
|
+
|
|
287
|
+
await waitFor(() => {
|
|
288
|
+
expect(onError).toHaveBeenCalledTimes(1);
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
const event: React.SyntheticEvent<HTMLImageElement> = onError.mock
|
|
292
|
+
.calls[0]![0] as React.SyntheticEvent<HTMLImageElement>;
|
|
293
|
+
|
|
294
|
+
expect(event.type).toBe("error");
|
|
295
|
+
});
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
describe("when it does not try at all", () => {
|
|
299
|
+
it("passes a non-private image's failure straight to onError", async () => {
|
|
300
|
+
renderImage({ src: PUBLIC_SRC });
|
|
301
|
+
|
|
302
|
+
fireEvent.error(image());
|
|
303
|
+
await flushPromises();
|
|
304
|
+
|
|
305
|
+
expect(refreshSession).not.toHaveBeenCalled();
|
|
306
|
+
expect(onError).toHaveBeenCalledTimes(1);
|
|
307
|
+
expect(image()).toHaveAttribute("src", PUBLIC_SRC);
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
/*
|
|
311
|
+
* A status page renders the same markdown for anonymous readers. They have
|
|
312
|
+
* no dashboard session to refresh, and a failed refresh would log them
|
|
313
|
+
* "out" and redirect to the login page.
|
|
314
|
+
*/
|
|
315
|
+
it("does not refresh for a reader who is not signed in", async () => {
|
|
316
|
+
isSignedIn.mockReturnValue(false);
|
|
317
|
+
|
|
318
|
+
renderImage();
|
|
319
|
+
|
|
320
|
+
fireEvent.error(image());
|
|
321
|
+
await flushPromises();
|
|
322
|
+
|
|
323
|
+
expect(isSignedIn).toHaveBeenCalled();
|
|
324
|
+
expect(refreshSession).not.toHaveBeenCalled();
|
|
325
|
+
expect(onError).toHaveBeenCalledTimes(1);
|
|
326
|
+
expect(image()).toHaveAttribute("src", PRIVATE_SRC);
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
it("tolerates a failure with no onError handler", async () => {
|
|
330
|
+
render(
|
|
331
|
+
<SessionAwareImage
|
|
332
|
+
src={PUBLIC_SRC}
|
|
333
|
+
alt={ALT}
|
|
334
|
+
refreshSession={refreshSession}
|
|
335
|
+
isSignedIn={isSignedIn}
|
|
336
|
+
/>,
|
|
337
|
+
);
|
|
338
|
+
|
|
339
|
+
expect(() => {
|
|
340
|
+
fireEvent.error(image());
|
|
341
|
+
}).not.toThrow();
|
|
342
|
+
|
|
343
|
+
await flushPromises();
|
|
344
|
+
|
|
345
|
+
expect(refreshSession).not.toHaveBeenCalled();
|
|
346
|
+
});
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
describe("a new src", () => {
|
|
350
|
+
it("is rendered, and gets its own one retry", async () => {
|
|
351
|
+
const { rerender } = renderImage();
|
|
352
|
+
|
|
353
|
+
// Spend the first image's retry entirely.
|
|
354
|
+
fireEvent.error(image());
|
|
355
|
+
await waitFor(() => {
|
|
356
|
+
expect(image().getAttribute("src")).toContain("sessionRetry=");
|
|
357
|
+
});
|
|
358
|
+
fireEvent.error(image());
|
|
359
|
+
await flushPromises();
|
|
360
|
+
|
|
361
|
+
expect(refreshSession).toHaveBeenCalledTimes(1);
|
|
362
|
+
expect(onError).toHaveBeenCalledTimes(1);
|
|
363
|
+
|
|
364
|
+
rerender(
|
|
365
|
+
<SessionAwareImage
|
|
366
|
+
src={OTHER_PRIVATE_SRC}
|
|
367
|
+
alt={ALT}
|
|
368
|
+
refreshSession={refreshSession}
|
|
369
|
+
isSignedIn={isSignedIn}
|
|
370
|
+
onError={onError}
|
|
371
|
+
/>,
|
|
372
|
+
);
|
|
373
|
+
|
|
374
|
+
await waitFor(() => {
|
|
375
|
+
expect(image()).toHaveAttribute("src", OTHER_PRIVATE_SRC);
|
|
376
|
+
});
|
|
377
|
+
|
|
378
|
+
fireEvent.error(image());
|
|
379
|
+
|
|
380
|
+
await waitFor(() => {
|
|
381
|
+
expect(image()).toHaveAttribute(
|
|
382
|
+
"src",
|
|
383
|
+
`${OTHER_PRIVATE_SRC}?sessionRetry=${NOW}`,
|
|
384
|
+
);
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
expect(refreshSession).toHaveBeenCalledTimes(2);
|
|
388
|
+
expect(onError).toHaveBeenCalledTimes(1);
|
|
389
|
+
});
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
describe("defaults", () => {
|
|
393
|
+
it("asks UserUtil.isLoggedIn when no isSignedIn is given", async () => {
|
|
394
|
+
(UserUtil.isLoggedIn as unknown as BooleanMock).mockReturnValue(false);
|
|
395
|
+
|
|
396
|
+
render(
|
|
397
|
+
<SessionAwareImage
|
|
398
|
+
src={PRIVATE_SRC}
|
|
399
|
+
alt={ALT}
|
|
400
|
+
refreshSession={refreshSession}
|
|
401
|
+
onError={onError}
|
|
402
|
+
/>,
|
|
403
|
+
);
|
|
404
|
+
|
|
405
|
+
fireEvent.error(image());
|
|
406
|
+
await flushPromises();
|
|
407
|
+
|
|
408
|
+
expect(UserUtil.isLoggedIn).toHaveBeenCalled();
|
|
409
|
+
expect(refreshSession).not.toHaveBeenCalled();
|
|
410
|
+
expect(onError).toHaveBeenCalledTimes(1);
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
/*
|
|
414
|
+
* Status pages and public dashboards render the same markdown with no
|
|
415
|
+
* dashboard session to refresh. Unless the app opted in, a broken private
|
|
416
|
+
* image stays broken rather than risking a dashboard logout.
|
|
417
|
+
*/
|
|
418
|
+
it("does not refresh anything when neither the caller nor the app supplied a refresh", async () => {
|
|
419
|
+
(UserUtil.isLoggedIn as unknown as BooleanMock).mockReturnValue(true);
|
|
420
|
+
(API.refreshSession as unknown as RefreshMock).mockResolvedValue(true);
|
|
421
|
+
|
|
422
|
+
render(
|
|
423
|
+
<SessionAwareImage src={PRIVATE_SRC} alt={ALT} onError={onError} />,
|
|
424
|
+
);
|
|
425
|
+
|
|
426
|
+
fireEvent.error(image());
|
|
427
|
+
|
|
428
|
+
expect(API.refreshSession).not.toHaveBeenCalled();
|
|
429
|
+
expect(onError).toHaveBeenCalledTimes(1);
|
|
430
|
+
expect(image()).toHaveAttribute("src", PRIVATE_SRC);
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
it("uses the refresh the app registered with enablePrivateImageSessionRefresh", async () => {
|
|
434
|
+
(UserUtil.isLoggedIn as unknown as BooleanMock).mockReturnValue(true);
|
|
435
|
+
const appRefresh: RefreshMock = jest.fn(async (): Promise<boolean> => {
|
|
436
|
+
return true;
|
|
437
|
+
}) as RefreshMock;
|
|
438
|
+
|
|
439
|
+
enablePrivateImageSessionRefresh(appRefresh);
|
|
440
|
+
|
|
441
|
+
try {
|
|
442
|
+
render(
|
|
443
|
+
<SessionAwareImage src={PRIVATE_SRC} alt={ALT} onError={onError} />,
|
|
444
|
+
);
|
|
445
|
+
|
|
446
|
+
fireEvent.error(image());
|
|
447
|
+
|
|
448
|
+
await waitFor(() => {
|
|
449
|
+
expect(image()).toHaveAttribute(
|
|
450
|
+
"src",
|
|
451
|
+
`${PRIVATE_SRC}?sessionRetry=${NOW}`,
|
|
452
|
+
);
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
expect(appRefresh).toHaveBeenCalledTimes(1);
|
|
456
|
+
expect(API.refreshSession).not.toHaveBeenCalled();
|
|
457
|
+
expect(onError).not.toHaveBeenCalled();
|
|
458
|
+
} finally {
|
|
459
|
+
enablePrivateImageSessionRefresh(null);
|
|
460
|
+
}
|
|
461
|
+
});
|
|
462
|
+
|
|
463
|
+
it("prefers the caller's refresh over the one the app registered", async () => {
|
|
464
|
+
(UserUtil.isLoggedIn as unknown as BooleanMock).mockReturnValue(true);
|
|
465
|
+
const appRefresh: RefreshMock = jest.fn(async (): Promise<boolean> => {
|
|
466
|
+
return true;
|
|
467
|
+
}) as RefreshMock;
|
|
468
|
+
const callerRefresh: RefreshMock = jest.fn(async (): Promise<boolean> => {
|
|
469
|
+
return true;
|
|
470
|
+
}) as RefreshMock;
|
|
471
|
+
|
|
472
|
+
enablePrivateImageSessionRefresh(appRefresh);
|
|
473
|
+
|
|
474
|
+
try {
|
|
475
|
+
render(
|
|
476
|
+
<SessionAwareImage
|
|
477
|
+
src={PRIVATE_SRC}
|
|
478
|
+
alt={ALT}
|
|
479
|
+
onError={onError}
|
|
480
|
+
refreshSession={callerRefresh}
|
|
481
|
+
/>,
|
|
482
|
+
);
|
|
483
|
+
|
|
484
|
+
fireEvent.error(image());
|
|
485
|
+
|
|
486
|
+
await waitFor(() => {
|
|
487
|
+
expect(callerRefresh).toHaveBeenCalledTimes(1);
|
|
488
|
+
});
|
|
489
|
+
|
|
490
|
+
expect(appRefresh).not.toHaveBeenCalled();
|
|
491
|
+
} finally {
|
|
492
|
+
enablePrivateImageSessionRefresh(null);
|
|
493
|
+
}
|
|
494
|
+
});
|
|
495
|
+
});
|
|
496
|
+
});
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/** @timezone UTC */
|
|
2
|
+
|
|
3
|
+
import "@testing-library/jest-dom";
|
|
4
|
+
import {
|
|
5
|
+
HistogramBucket,
|
|
6
|
+
HistogramSeriesOption,
|
|
7
|
+
} from "../../../UI/Components/TelemetryViewer/types";
|
|
8
|
+
import { cleanup, render, screen } from "@testing-library/react";
|
|
9
|
+
import React from "react";
|
|
10
|
+
import { afterEach, describe, expect, jest, test } from "@jest/globals";
|
|
11
|
+
|
|
12
|
+
/*
|
|
13
|
+
* A zero-count bucket is how a caller keeps a quiet stretch on the time axis:
|
|
14
|
+
* without it the bars either side of an empty hour close up and the chart
|
|
15
|
+
* lies about when things happened. Such a bucket is not a sighting of its
|
|
16
|
+
* series, though - it draws nothing, so it must not put the series in the
|
|
17
|
+
* legend (or draw a Bar for it).
|
|
18
|
+
*
|
|
19
|
+
* recharts is stood in for, as in TelemetryHistogramDragTooltip.test.tsx, so
|
|
20
|
+
* the rows the chart is handed and the Bars it declares can be read directly.
|
|
21
|
+
*/
|
|
22
|
+
jest.mock("recharts", () => {
|
|
23
|
+
const react: typeof React = jest.requireActual("react") as typeof React;
|
|
24
|
+
|
|
25
|
+
interface StubRow {
|
|
26
|
+
time: string;
|
|
27
|
+
[series: string]: number | string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
__esModule: true,
|
|
32
|
+
ResponsiveContainer: (props: { children: React.ReactNode }) => {
|
|
33
|
+
return react.createElement("div", null, props.children);
|
|
34
|
+
},
|
|
35
|
+
BarChart: (props: { data: Array<StubRow>; children?: React.ReactNode }) => {
|
|
36
|
+
return react.createElement(
|
|
37
|
+
"div",
|
|
38
|
+
{ "data-testid": "bar-chart" },
|
|
39
|
+
props.data.map((row: StubRow) => {
|
|
40
|
+
return react.createElement("div", {
|
|
41
|
+
key: row.time,
|
|
42
|
+
"data-testid": "chart-row",
|
|
43
|
+
"data-time": row.time,
|
|
44
|
+
"data-row": JSON.stringify(row),
|
|
45
|
+
});
|
|
46
|
+
}),
|
|
47
|
+
props.children,
|
|
48
|
+
);
|
|
49
|
+
},
|
|
50
|
+
Bar: (props: { dataKey: string }) => {
|
|
51
|
+
return react.createElement("div", {
|
|
52
|
+
"data-testid": "bar",
|
|
53
|
+
"data-key": props.dataKey,
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
XAxis: () => {
|
|
57
|
+
return null;
|
|
58
|
+
},
|
|
59
|
+
YAxis: () => {
|
|
60
|
+
return null;
|
|
61
|
+
},
|
|
62
|
+
Tooltip: () => {
|
|
63
|
+
return null;
|
|
64
|
+
},
|
|
65
|
+
ReferenceArea: () => {
|
|
66
|
+
return null;
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
import TelemetryHistogram from "../../../UI/Components/TelemetryViewer/components/TelemetryHistogram";
|
|
72
|
+
|
|
73
|
+
const SERIES: Array<HistogramSeriesOption> = [
|
|
74
|
+
{ key: "critical", label: "Critical", color: "#dc2626" },
|
|
75
|
+
{ key: "high", label: "High", color: "#ea580c" },
|
|
76
|
+
{ key: "low", label: "Low", color: "#3b82f6" },
|
|
77
|
+
];
|
|
78
|
+
|
|
79
|
+
function barKeys(): Array<string> {
|
|
80
|
+
return screen.queryAllByTestId("bar").map((bar: HTMLElement): string => {
|
|
81
|
+
return bar.getAttribute("data-key") || "";
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function rowTimes(): Array<string> {
|
|
86
|
+
return screen
|
|
87
|
+
.queryAllByTestId("chart-row")
|
|
88
|
+
.map((row: HTMLElement): string => {
|
|
89
|
+
return row.getAttribute("data-time") || "";
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
afterEach(() => {
|
|
94
|
+
cleanup();
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
describe("TelemetryHistogram with zero-count buckets", () => {
|
|
98
|
+
test("keeps every bucket on the time axis, empty ones included", () => {
|
|
99
|
+
const buckets: Array<HistogramBucket> = [
|
|
100
|
+
{ time: "2026-09-17T10:00:00Z", series: "high", count: 4 },
|
|
101
|
+
{ time: "2026-09-17T11:00:00Z", series: "critical", count: 0 },
|
|
102
|
+
{ time: "2026-09-17T12:00:00Z", series: "critical", count: 0 },
|
|
103
|
+
{ time: "2026-09-17T13:00:00Z", series: "low", count: 2 },
|
|
104
|
+
];
|
|
105
|
+
|
|
106
|
+
render(
|
|
107
|
+
<TelemetryHistogram
|
|
108
|
+
buckets={buckets}
|
|
109
|
+
series={SERIES}
|
|
110
|
+
isLoading={false}
|
|
111
|
+
/>,
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
expect(rowTimes()).toEqual([
|
|
115
|
+
"2026-09-17T10:00:00Z",
|
|
116
|
+
"2026-09-17T11:00:00Z",
|
|
117
|
+
"2026-09-17T12:00:00Z",
|
|
118
|
+
"2026-09-17T13:00:00Z",
|
|
119
|
+
]);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
test("a series seen only in zero-count buckets is neither legended nor drawn", () => {
|
|
123
|
+
render(
|
|
124
|
+
<TelemetryHistogram
|
|
125
|
+
buckets={[
|
|
126
|
+
{ time: "2026-09-17T10:00:00Z", series: "high", count: 4 },
|
|
127
|
+
{ time: "2026-09-17T11:00:00Z", series: "critical", count: 0 },
|
|
128
|
+
]}
|
|
129
|
+
series={SERIES}
|
|
130
|
+
isLoading={false}
|
|
131
|
+
/>,
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
expect(screen.getByText("High")).toBeInTheDocument();
|
|
135
|
+
expect(screen.queryByText("Critical")).toBeNull();
|
|
136
|
+
expect(barKeys()).toEqual(["high"]);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
test("a series with a real count somewhere is legended even if other buckets hold zero for it", () => {
|
|
140
|
+
render(
|
|
141
|
+
<TelemetryHistogram
|
|
142
|
+
buckets={[
|
|
143
|
+
{ time: "2026-09-17T10:00:00Z", series: "critical", count: 0 },
|
|
144
|
+
{ time: "2026-09-17T11:00:00Z", series: "critical", count: 1 },
|
|
145
|
+
]}
|
|
146
|
+
series={SERIES}
|
|
147
|
+
isLoading={false}
|
|
148
|
+
/>,
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
expect(screen.getByText("Critical")).toBeInTheDocument();
|
|
152
|
+
expect(barKeys()).toEqual(["critical"]);
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
test("legend and bars keep the series' declared order", () => {
|
|
156
|
+
render(
|
|
157
|
+
<TelemetryHistogram
|
|
158
|
+
buckets={[
|
|
159
|
+
{ time: "2026-09-17T10:00:00Z", series: "low", count: 1 },
|
|
160
|
+
{ time: "2026-09-17T10:00:00Z", series: "critical", count: 1 },
|
|
161
|
+
]}
|
|
162
|
+
series={SERIES}
|
|
163
|
+
isLoading={false}
|
|
164
|
+
/>,
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
expect(barKeys()).toEqual(["critical", "low"]);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
test("an all-zero window still draws its axis, with no bars and no legend", () => {
|
|
171
|
+
render(
|
|
172
|
+
<TelemetryHistogram
|
|
173
|
+
buckets={[
|
|
174
|
+
{ time: "2026-09-17T10:00:00Z", series: "critical", count: 0 },
|
|
175
|
+
{ time: "2026-09-17T11:00:00Z", series: "critical", count: 0 },
|
|
176
|
+
]}
|
|
177
|
+
series={SERIES}
|
|
178
|
+
isLoading={false}
|
|
179
|
+
title="Security Event Volume"
|
|
180
|
+
/>,
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
expect(screen.getByText("Security Event Volume")).toBeInTheDocument();
|
|
184
|
+
expect(rowTimes()).toHaveLength(2);
|
|
185
|
+
expect(barKeys()).toEqual([]);
|
|
186
|
+
for (const option of SERIES) {
|
|
187
|
+
expect(screen.queryByText(option.label)).toBeNull();
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
});
|