@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,996 @@
|
|
|
1
|
+
import { describe, expect, test } from "@jest/globals";
|
|
2
|
+
import ScheduleTimelineLayout, {
|
|
3
|
+
PositionedInterval,
|
|
4
|
+
TimeInterval,
|
|
5
|
+
TimelineDay,
|
|
6
|
+
TimelineRange,
|
|
7
|
+
TimelineViewMode,
|
|
8
|
+
} from "../../../Types/OnCallDutyPolicy/ScheduleTimelineLayout";
|
|
9
|
+
import { at, tzInstant } from "./CalendarFeedTestFixtures";
|
|
10
|
+
|
|
11
|
+
/*
|
|
12
|
+
* The schedule timeline's geometry. Every range here is built in an explicit
|
|
13
|
+
* IANA zone so the results do not depend on the zone the test runs in, and
|
|
14
|
+
* the DST cases pin the property the whole layout exists for: a bar that
|
|
15
|
+
* ends at local midnight ends exactly on a gridline, even on a 23- or 25-hour
|
|
16
|
+
* day.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
const NEW_YORK: string = "America/New_York";
|
|
20
|
+
const TOKYO: string = "Asia/Tokyo";
|
|
21
|
+
const LONDON: string = "Europe/London";
|
|
22
|
+
const UTC: string = "UTC";
|
|
23
|
+
const BERLIN: string = "Europe/Berlin";
|
|
24
|
+
const SANTIAGO: string = "America/Santiago";
|
|
25
|
+
const CAIRO: string = "Africa/Cairo";
|
|
26
|
+
const HAVANA: string = "America/Havana";
|
|
27
|
+
|
|
28
|
+
function week(anchor: Date, timezone: string): TimelineRange {
|
|
29
|
+
return ScheduleTimelineLayout.getRange({
|
|
30
|
+
mode: TimelineViewMode.Week,
|
|
31
|
+
anchor,
|
|
32
|
+
timezone,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function month(anchor: Date, timezone: string): TimelineRange {
|
|
37
|
+
return ScheduleTimelineLayout.getRange({
|
|
38
|
+
mode: TimelineViewMode.Month,
|
|
39
|
+
anchor,
|
|
40
|
+
timezone,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function keys(range: TimelineRange): Array<string> {
|
|
45
|
+
return range.days.map((day: TimelineDay) => {
|
|
46
|
+
return day.key;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function interval(start: string, end: string): TimeInterval {
|
|
51
|
+
return { start: at(start), end: at(end) };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
describe("getRange: week", () => {
|
|
55
|
+
test("is the ISO week (Monday first) containing the anchor", () => {
|
|
56
|
+
const range: TimelineRange = week(at("2026-09-17T12:00:00Z"), UTC);
|
|
57
|
+
|
|
58
|
+
expect(keys(range)).toEqual([
|
|
59
|
+
"2026-09-14",
|
|
60
|
+
"2026-09-15",
|
|
61
|
+
"2026-09-16",
|
|
62
|
+
"2026-09-17",
|
|
63
|
+
"2026-09-18",
|
|
64
|
+
"2026-09-19",
|
|
65
|
+
"2026-09-20",
|
|
66
|
+
]);
|
|
67
|
+
expect(range.start.toISOString()).toBe("2026-09-14T00:00:00.000Z");
|
|
68
|
+
expect(range.end.toISOString()).toBe("2026-09-21T00:00:00.000Z");
|
|
69
|
+
expect(range.mode).toBe(TimelineViewMode.Week);
|
|
70
|
+
expect(range.timezone).toBe(UTC);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test("a Sunday anchor belongs to the week that started the Monday before", () => {
|
|
74
|
+
const range: TimelineRange = week(at("2026-09-20T23:59:00Z"), UTC);
|
|
75
|
+
|
|
76
|
+
expect(range.days[0]?.key).toBe("2026-09-14");
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
test("a Monday 00:00 anchor starts its own week", () => {
|
|
80
|
+
const range: TimelineRange = week(at("2026-09-21T00:00:00Z"), UTC);
|
|
81
|
+
|
|
82
|
+
expect(range.days[0]?.key).toBe("2026-09-21");
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test("the same instant is a different week in a different zone", () => {
|
|
86
|
+
// Monday 08:00 in Tokyo is still Sunday 19:00 in New York.
|
|
87
|
+
const instant: Date = tzInstant("2026-09-21 08:00", TOKYO);
|
|
88
|
+
|
|
89
|
+
expect(week(instant, TOKYO).days[0]?.key).toBe("2026-09-21");
|
|
90
|
+
expect(week(instant, NEW_YORK).days[0]?.key).toBe("2026-09-14");
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
test("day edges are local midnights in the view zone", () => {
|
|
94
|
+
const range: TimelineRange = week(at("2026-09-17T12:00:00Z"), NEW_YORK);
|
|
95
|
+
|
|
96
|
+
// EDT is UTC-4 in September.
|
|
97
|
+
expect(range.start.toISOString()).toBe("2026-09-14T04:00:00.000Z");
|
|
98
|
+
expect(range.days[1]?.start.toISOString()).toBe("2026-09-15T04:00:00.000Z");
|
|
99
|
+
expect(range.end.toISOString()).toBe("2026-09-21T04:00:00.000Z");
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
test("each day's end is the next day's start, across a DST change", () => {
|
|
103
|
+
const range: TimelineRange = week(at("2026-03-05T12:00:00Z"), NEW_YORK);
|
|
104
|
+
|
|
105
|
+
for (let index: number = 0; index < range.days.length - 1; index++) {
|
|
106
|
+
expect(range.days[index]?.end.getTime()).toBe(
|
|
107
|
+
range.days[index + 1]?.start.getTime(),
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
expect(range.days[range.days.length - 1]?.end.getTime()).toBe(
|
|
112
|
+
range.end.getTime(),
|
|
113
|
+
);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
test("weekend, labels and first-of-month flags", () => {
|
|
117
|
+
const range: TimelineRange = week(at("2026-09-30T12:00:00Z"), UTC);
|
|
118
|
+
|
|
119
|
+
expect(
|
|
120
|
+
range.days.map((day: TimelineDay) => {
|
|
121
|
+
return [day.weekdayShort, day.weekdayNarrow, day.isWeekend];
|
|
122
|
+
}),
|
|
123
|
+
).toEqual([
|
|
124
|
+
["Mon", "M", false],
|
|
125
|
+
["Tue", "T", false],
|
|
126
|
+
["Wed", "W", false],
|
|
127
|
+
["Thu", "T", false],
|
|
128
|
+
["Fri", "F", false],
|
|
129
|
+
["Sat", "S", true],
|
|
130
|
+
["Sun", "S", true],
|
|
131
|
+
]);
|
|
132
|
+
|
|
133
|
+
const october: TimelineDay | undefined = range.days.find(
|
|
134
|
+
(day: TimelineDay) => {
|
|
135
|
+
return day.isFirstOfMonth;
|
|
136
|
+
},
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
expect(october?.key).toBe("2026-10-01");
|
|
140
|
+
expect(october?.monthShort).toBe("Oct");
|
|
141
|
+
expect(october?.dayOfMonth).toBe(1);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
test("a week across a year boundary", () => {
|
|
145
|
+
const range: TimelineRange = week(at("2026-12-31T12:00:00Z"), UTC);
|
|
146
|
+
|
|
147
|
+
expect(keys(range)).toEqual([
|
|
148
|
+
"2026-12-28",
|
|
149
|
+
"2026-12-29",
|
|
150
|
+
"2026-12-30",
|
|
151
|
+
"2026-12-31",
|
|
152
|
+
"2027-01-01",
|
|
153
|
+
"2027-01-02",
|
|
154
|
+
"2027-01-03",
|
|
155
|
+
]);
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
describe("getRange: month", () => {
|
|
160
|
+
test("is the calendar month containing the anchor", () => {
|
|
161
|
+
const range: TimelineRange = month(at("2026-09-17T12:00:00Z"), UTC);
|
|
162
|
+
|
|
163
|
+
expect(range.days).toHaveLength(30);
|
|
164
|
+
expect(range.days[0]?.key).toBe("2026-09-01");
|
|
165
|
+
expect(range.days[29]?.key).toBe("2026-09-30");
|
|
166
|
+
expect(range.end.toISOString()).toBe("2026-10-01T00:00:00.000Z");
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
test.each([
|
|
170
|
+
["2026-01-15T12:00:00Z", 31],
|
|
171
|
+
["2026-02-15T12:00:00Z", 28],
|
|
172
|
+
["2028-02-15T12:00:00Z", 29],
|
|
173
|
+
["2026-04-15T12:00:00Z", 30],
|
|
174
|
+
["2026-12-15T12:00:00Z", 31],
|
|
175
|
+
])("%s has %i days", (anchor: string, count: number) => {
|
|
176
|
+
expect(month(at(anchor), UTC).days).toHaveLength(count);
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
test("the month is the view zone's month", () => {
|
|
180
|
+
// 1 Oct 02:00 in Tokyo is still 30 Sep in UTC.
|
|
181
|
+
const instant: Date = tzInstant("2026-10-01 02:00", TOKYO);
|
|
182
|
+
|
|
183
|
+
expect(month(instant, TOKYO).days[0]?.key).toBe("2026-10-01");
|
|
184
|
+
expect(month(instant, UTC).days[0]?.key).toBe("2026-09-01");
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
describe("DST", () => {
|
|
189
|
+
// US DST starts Sunday 8 March 2026 (02:00 -> 03:00): a 23-hour day.
|
|
190
|
+
const springWeek: TimelineRange = week(at("2026-03-05T12:00:00Z"), NEW_YORK);
|
|
191
|
+
|
|
192
|
+
test("the spring-forward day is 23 hours, the rest 24", () => {
|
|
193
|
+
const hours: Array<number> = springWeek.days.map((day: TimelineDay) => {
|
|
194
|
+
return (day.end.getTime() - day.start.getTime()) / 3600000;
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
expect(springWeek.days[6]?.key).toBe("2026-03-08");
|
|
198
|
+
expect(hours).toEqual([24, 24, 24, 24, 24, 24, 23]);
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
test("every local midnight lands exactly on a gridline", () => {
|
|
202
|
+
springWeek.days.forEach((day: TimelineDay, index: number) => {
|
|
203
|
+
expect(ScheduleTimelineLayout.getFraction(day.start, springWeek)).toBe(
|
|
204
|
+
index / 7,
|
|
205
|
+
);
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
test("local noon on the short day is still the middle of its column", () => {
|
|
210
|
+
const noon: Date = tzInstant("2026-03-08 12:00", NEW_YORK);
|
|
211
|
+
const fraction: number = ScheduleTimelineLayout.getFraction(
|
|
212
|
+
noon,
|
|
213
|
+
springWeek,
|
|
214
|
+
);
|
|
215
|
+
|
|
216
|
+
// 11 of the day's 23 hours have elapsed at local noon.
|
|
217
|
+
expect(fraction).toBeCloseTo((6 + 11 / 23) / 7, 10);
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
test("the fall-back day is 25 hours", () => {
|
|
221
|
+
// US DST ends Sunday 1 November 2026.
|
|
222
|
+
const fallWeek: TimelineRange = week(at("2026-10-28T12:00:00Z"), NEW_YORK);
|
|
223
|
+
const sunday: TimelineDay | undefined = fallWeek.days[6];
|
|
224
|
+
|
|
225
|
+
expect(sunday?.key).toBe("2026-11-01");
|
|
226
|
+
expect(
|
|
227
|
+
((sunday?.end.getTime() || 0) - (sunday?.start.getTime() || 0)) / 3600000,
|
|
228
|
+
).toBe(25);
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
test("a London week across the October change keeps seven columns", () => {
|
|
232
|
+
const range: TimelineRange = week(at("2026-10-22T12:00:00Z"), LONDON);
|
|
233
|
+
|
|
234
|
+
expect(range.days).toHaveLength(7);
|
|
235
|
+
expect(range.days[6]?.key).toBe("2026-10-25");
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
describe("DST gap at local midnight", () => {
|
|
240
|
+
/*
|
|
241
|
+
* In these zones the clocks jump from 24:00 straight to 01:00, so the change
|
|
242
|
+
* day has no 00:00. Each day must still start at its first real instant and
|
|
243
|
+
* the days must still tile the range end to start.
|
|
244
|
+
*/
|
|
245
|
+
function expectTiled(range: TimelineRange): void {
|
|
246
|
+
for (let index: number = 0; index < range.days.length - 1; index++) {
|
|
247
|
+
expect(range.days[index]?.end.getTime()).toBe(
|
|
248
|
+
range.days[index + 1]?.start.getTime(),
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
expect(range.days[0]?.start.getTime()).toBe(range.start.getTime());
|
|
253
|
+
expect(range.days[range.days.length - 1]?.end.getTime()).toBe(
|
|
254
|
+
range.end.getTime(),
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
test("America/Santiago, week of 31 August 2026", () => {
|
|
259
|
+
const range: TimelineRange = week(at("2026-09-02T15:00:00Z"), SANTIAGO);
|
|
260
|
+
|
|
261
|
+
expectTiled(range);
|
|
262
|
+
expect(range.days[5]?.key).toBe("2026-09-05");
|
|
263
|
+
expect(range.days[5]?.end.toISOString()).toBe("2026-09-06T04:00:00.000Z");
|
|
264
|
+
expect(range.days[6]?.key).toBe("2026-09-06");
|
|
265
|
+
expect(range.days[6]?.start.toISOString()).toBe("2026-09-06T04:00:00.000Z");
|
|
266
|
+
expect(range.end.toISOString()).toBe("2026-09-07T03:00:00.000Z");
|
|
267
|
+
|
|
268
|
+
const hours: Array<number> = range.days.map((day: TimelineDay) => {
|
|
269
|
+
return (day.end.getTime() - day.start.getTime()) / 3600000;
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
expect(hours).toEqual([24, 24, 24, 24, 24, 24, 23]);
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
test("Santiago: the Saturday/Sunday hand-off lands exactly on the gridline", () => {
|
|
276
|
+
const range: TimelineRange = week(at("2026-09-02T15:00:00Z"), SANTIAGO);
|
|
277
|
+
|
|
278
|
+
expect(
|
|
279
|
+
ScheduleTimelineLayout.getFraction(at("2026-09-06T04:00:00Z"), range),
|
|
280
|
+
).toBe(6 / 7);
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
test("Africa/Cairo, week of 20 April 2026 (the Friday has no midnight)", () => {
|
|
284
|
+
const range: TimelineRange = week(at("2026-04-22T10:00:00Z"), CAIRO);
|
|
285
|
+
|
|
286
|
+
expectTiled(range);
|
|
287
|
+
expect(range.days[4]?.key).toBe("2026-04-24");
|
|
288
|
+
expect(range.days[4]?.start.toISOString()).toBe("2026-04-23T22:00:00.000Z");
|
|
289
|
+
expect(range.days[4]?.end.toISOString()).toBe("2026-04-24T21:00:00.000Z");
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
test("America/Havana, the whole of March 2026", () => {
|
|
293
|
+
const range: TimelineRange = month(at("2026-03-15T15:00:00Z"), HAVANA);
|
|
294
|
+
|
|
295
|
+
expect(range.days).toHaveLength(31);
|
|
296
|
+
expectTiled(range);
|
|
297
|
+
expect(range.days[7]?.key).toBe("2026-03-08");
|
|
298
|
+
expect(range.days[7]?.start.toISOString()).toBe("2026-03-08T05:00:00.000Z");
|
|
299
|
+
expect(range.days[8]?.start.toISOString()).toBe("2026-03-09T04:00:00.000Z");
|
|
300
|
+
});
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
describe("moveAnchorToTimezone", () => {
|
|
304
|
+
test("keeps the wall clock, so the same dates stay on screen", () => {
|
|
305
|
+
// Next from Berlin puts the anchor on Monday 21 September, local noon.
|
|
306
|
+
const anchor: Date = ScheduleTimelineLayout.shiftAnchor({
|
|
307
|
+
mode: TimelineViewMode.Week,
|
|
308
|
+
anchor: tzInstant("2026-09-17 09:00", BERLIN),
|
|
309
|
+
timezone: BERLIN,
|
|
310
|
+
direction: 1,
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
for (const zone of [
|
|
314
|
+
UTC,
|
|
315
|
+
NEW_YORK,
|
|
316
|
+
TOKYO,
|
|
317
|
+
"Pacific/Kiritimati",
|
|
318
|
+
"Pacific/Pago_Pago",
|
|
319
|
+
]) {
|
|
320
|
+
const moved: Date = ScheduleTimelineLayout.moveAnchorToTimezone({
|
|
321
|
+
anchor,
|
|
322
|
+
fromTimezone: BERLIN,
|
|
323
|
+
toTimezone: zone,
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
expect({ zone, first: week(moved, zone).days[0]?.key }).toEqual({
|
|
327
|
+
zone,
|
|
328
|
+
first: "2026-09-21",
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
test("a month stays the same month", () => {
|
|
334
|
+
const anchor: Date = ScheduleTimelineLayout.shiftAnchor({
|
|
335
|
+
mode: TimelineViewMode.Month,
|
|
336
|
+
anchor: tzInstant("2026-09-17 09:00", TOKYO),
|
|
337
|
+
timezone: TOKYO,
|
|
338
|
+
direction: 1,
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
const moved: Date = ScheduleTimelineLayout.moveAnchorToTimezone({
|
|
342
|
+
anchor,
|
|
343
|
+
fromTimezone: TOKYO,
|
|
344
|
+
toTimezone: "America/Los_Angeles",
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
expect(month(moved, "America/Los_Angeles").days[0]?.key).toBe("2026-10-01");
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
test("the same zone is a no-op", () => {
|
|
351
|
+
const anchor: Date = at("2026-09-17T12:34:56Z");
|
|
352
|
+
|
|
353
|
+
expect(
|
|
354
|
+
ScheduleTimelineLayout.moveAnchorToTimezone({
|
|
355
|
+
anchor,
|
|
356
|
+
fromTimezone: NEW_YORK,
|
|
357
|
+
toTimezone: NEW_YORK,
|
|
358
|
+
}).toISOString(),
|
|
359
|
+
).toBe(anchor.toISOString());
|
|
360
|
+
});
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
describe("shiftAnchor", () => {
|
|
364
|
+
test("weeks move by seven days", () => {
|
|
365
|
+
const anchor: Date = at("2026-09-17T12:00:00Z");
|
|
366
|
+
|
|
367
|
+
const next: Date = ScheduleTimelineLayout.shiftAnchor({
|
|
368
|
+
mode: TimelineViewMode.Week,
|
|
369
|
+
anchor,
|
|
370
|
+
timezone: UTC,
|
|
371
|
+
direction: 1,
|
|
372
|
+
});
|
|
373
|
+
const previous: Date = ScheduleTimelineLayout.shiftAnchor({
|
|
374
|
+
mode: TimelineViewMode.Week,
|
|
375
|
+
anchor,
|
|
376
|
+
timezone: UTC,
|
|
377
|
+
direction: -1,
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
expect(week(next, UTC).days[0]?.key).toBe("2026-09-21");
|
|
381
|
+
expect(week(previous, UTC).days[0]?.key).toBe("2026-09-07");
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
test("the new anchor is local noon of the target period's first day, across DST too", () => {
|
|
385
|
+
const next: Date = ScheduleTimelineLayout.shiftAnchor({
|
|
386
|
+
mode: TimelineViewMode.Week,
|
|
387
|
+
anchor: tzInstant("2026-03-04 12:00", NEW_YORK),
|
|
388
|
+
timezone: NEW_YORK,
|
|
389
|
+
direction: 1,
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
expect(next.toISOString()).toBe(
|
|
393
|
+
tzInstant("2026-03-09 12:00", NEW_YORK).toISOString(),
|
|
394
|
+
);
|
|
395
|
+
|
|
396
|
+
const nextMonth: Date = ScheduleTimelineLayout.shiftAnchor({
|
|
397
|
+
mode: TimelineViewMode.Month,
|
|
398
|
+
anchor: tzInstant("2026-03-31 23:30", NEW_YORK),
|
|
399
|
+
timezone: NEW_YORK,
|
|
400
|
+
direction: 1,
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
expect(nextMonth.toISOString()).toBe(
|
|
404
|
+
tzInstant("2026-04-01 12:00", NEW_YORK).toISOString(),
|
|
405
|
+
);
|
|
406
|
+
});
|
|
407
|
+
|
|
408
|
+
test("a week step onto a DST gap at midnight still lands in the right week", () => {
|
|
409
|
+
// Santiago skips 00:00 on Sunday 6 September 2026.
|
|
410
|
+
const next: Date = ScheduleTimelineLayout.shiftAnchor({
|
|
411
|
+
mode: TimelineViewMode.Week,
|
|
412
|
+
anchor: tzInstant("2026-08-26 09:00", SANTIAGO),
|
|
413
|
+
timezone: SANTIAGO,
|
|
414
|
+
direction: 1,
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
expect(week(next, SANTIAGO).days[0]?.key).toBe("2026-08-31");
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
test("months move by calendar month, even from the 31st", () => {
|
|
421
|
+
const next: Date = ScheduleTimelineLayout.shiftAnchor({
|
|
422
|
+
mode: TimelineViewMode.Month,
|
|
423
|
+
anchor: at("2026-01-31T12:00:00Z"),
|
|
424
|
+
timezone: UTC,
|
|
425
|
+
direction: 1,
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
expect(month(next, UTC).days[0]?.key).toBe("2026-02-01");
|
|
429
|
+
|
|
430
|
+
const back: Date = ScheduleTimelineLayout.shiftAnchor({
|
|
431
|
+
mode: TimelineViewMode.Month,
|
|
432
|
+
anchor: at("2026-03-31T12:00:00Z"),
|
|
433
|
+
timezone: UTC,
|
|
434
|
+
direction: -1,
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
expect(month(back, UTC).days[0]?.key).toBe("2026-02-01");
|
|
438
|
+
});
|
|
439
|
+
|
|
440
|
+
test("twelve steps forward is the same month next year", () => {
|
|
441
|
+
let anchor: Date = at("2026-09-17T12:00:00Z");
|
|
442
|
+
|
|
443
|
+
for (let step: number = 0; step < 12; step++) {
|
|
444
|
+
anchor = ScheduleTimelineLayout.shiftAnchor({
|
|
445
|
+
mode: TimelineViewMode.Month,
|
|
446
|
+
anchor,
|
|
447
|
+
timezone: NEW_YORK,
|
|
448
|
+
direction: 1,
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
expect(month(anchor, NEW_YORK).days[0]?.key).toBe("2027-09-01");
|
|
453
|
+
});
|
|
454
|
+
});
|
|
455
|
+
|
|
456
|
+
describe("getRangeLabel", () => {
|
|
457
|
+
test("a week inside one month", () => {
|
|
458
|
+
expect(
|
|
459
|
+
ScheduleTimelineLayout.getRangeLabel(
|
|
460
|
+
week(at("2026-09-17T12:00:00Z"), UTC),
|
|
461
|
+
),
|
|
462
|
+
).toBe("September 14 – 20, 2026");
|
|
463
|
+
});
|
|
464
|
+
|
|
465
|
+
test("a week across two months", () => {
|
|
466
|
+
expect(
|
|
467
|
+
ScheduleTimelineLayout.getRangeLabel(
|
|
468
|
+
week(at("2026-09-30T12:00:00Z"), UTC),
|
|
469
|
+
),
|
|
470
|
+
).toBe("Sep 28 – Oct 4, 2026");
|
|
471
|
+
});
|
|
472
|
+
|
|
473
|
+
test("a week across two years", () => {
|
|
474
|
+
expect(
|
|
475
|
+
ScheduleTimelineLayout.getRangeLabel(
|
|
476
|
+
week(at("2026-12-31T12:00:00Z"), UTC),
|
|
477
|
+
),
|
|
478
|
+
).toBe("Dec 28, 2026 – Jan 3, 2027");
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
test("a month", () => {
|
|
482
|
+
expect(
|
|
483
|
+
ScheduleTimelineLayout.getRangeLabel(
|
|
484
|
+
month(at("2026-09-17T12:00:00Z"), UTC),
|
|
485
|
+
),
|
|
486
|
+
).toBe("September 2026");
|
|
487
|
+
});
|
|
488
|
+
});
|
|
489
|
+
|
|
490
|
+
describe("getFraction", () => {
|
|
491
|
+
const range: TimelineRange = week(at("2026-09-17T12:00:00Z"), UTC);
|
|
492
|
+
|
|
493
|
+
test("clamps before and after the range", () => {
|
|
494
|
+
expect(
|
|
495
|
+
ScheduleTimelineLayout.getFraction(at("2026-09-01T00:00:00Z"), range),
|
|
496
|
+
).toBe(0);
|
|
497
|
+
expect(
|
|
498
|
+
ScheduleTimelineLayout.getFraction(at("2026-10-01T00:00:00Z"), range),
|
|
499
|
+
).toBe(1);
|
|
500
|
+
expect(ScheduleTimelineLayout.getFraction(range.end, range)).toBe(1);
|
|
501
|
+
expect(ScheduleTimelineLayout.getFraction(range.start, range)).toBe(0);
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
test("an instant is placed within its own day's column", () => {
|
|
505
|
+
// Thursday 12:00 = 3.5 days into the week.
|
|
506
|
+
expect(
|
|
507
|
+
ScheduleTimelineLayout.getFraction(at("2026-09-17T12:00:00Z"), range),
|
|
508
|
+
).toBeCloseTo(3.5 / 7, 12);
|
|
509
|
+
|
|
510
|
+
// Saturday 06:00 = 5.25 days.
|
|
511
|
+
expect(
|
|
512
|
+
ScheduleTimelineLayout.getFraction(at("2026-09-19T06:00:00Z"), range),
|
|
513
|
+
).toBeCloseTo(5.25 / 7, 12);
|
|
514
|
+
});
|
|
515
|
+
|
|
516
|
+
test("is monotonic across a month", () => {
|
|
517
|
+
const monthRange: TimelineRange = month(
|
|
518
|
+
at("2026-03-15T12:00:00Z"),
|
|
519
|
+
NEW_YORK,
|
|
520
|
+
);
|
|
521
|
+
|
|
522
|
+
let previous: number = -1;
|
|
523
|
+
|
|
524
|
+
for (
|
|
525
|
+
let time: number = monthRange.start.getTime();
|
|
526
|
+
time <= monthRange.end.getTime();
|
|
527
|
+
time += 3600 * 1000
|
|
528
|
+
) {
|
|
529
|
+
const fraction: number = ScheduleTimelineLayout.getFraction(
|
|
530
|
+
new Date(time),
|
|
531
|
+
monthRange,
|
|
532
|
+
);
|
|
533
|
+
|
|
534
|
+
expect(fraction).toBeGreaterThanOrEqual(previous);
|
|
535
|
+
expect(fraction).toBeGreaterThanOrEqual(0);
|
|
536
|
+
expect(fraction).toBeLessThanOrEqual(1);
|
|
537
|
+
previous = fraction;
|
|
538
|
+
}
|
|
539
|
+
});
|
|
540
|
+
|
|
541
|
+
test("an empty range places everything at 0", () => {
|
|
542
|
+
expect(
|
|
543
|
+
ScheduleTimelineLayout.getFraction(at("2026-09-17T12:00:00Z"), {
|
|
544
|
+
...range,
|
|
545
|
+
days: [],
|
|
546
|
+
}),
|
|
547
|
+
).toBe(0);
|
|
548
|
+
});
|
|
549
|
+
});
|
|
550
|
+
|
|
551
|
+
describe("positionIntervals", () => {
|
|
552
|
+
const range: TimelineRange = week(at("2026-09-17T12:00:00Z"), UTC);
|
|
553
|
+
|
|
554
|
+
test("drops intervals that do not overlap the range", () => {
|
|
555
|
+
const placed: Array<PositionedInterval<TimeInterval>> =
|
|
556
|
+
ScheduleTimelineLayout.positionIntervals(
|
|
557
|
+
[
|
|
558
|
+
interval("2026-09-01T00:00:00Z", "2026-09-14T00:00:00Z"),
|
|
559
|
+
interval("2026-09-21T00:00:00Z", "2026-09-22T00:00:00Z"),
|
|
560
|
+
],
|
|
561
|
+
range,
|
|
562
|
+
);
|
|
563
|
+
|
|
564
|
+
expect(placed).toEqual([]);
|
|
565
|
+
});
|
|
566
|
+
|
|
567
|
+
test("a whole-day interval is exactly one column wide", () => {
|
|
568
|
+
const placed: Array<PositionedInterval<TimeInterval>> =
|
|
569
|
+
ScheduleTimelineLayout.positionIntervals(
|
|
570
|
+
[interval("2026-09-15T00:00:00Z", "2026-09-16T00:00:00Z")],
|
|
571
|
+
range,
|
|
572
|
+
);
|
|
573
|
+
|
|
574
|
+
expect(placed[0]?.left).toBeCloseTo(100 / 7, 10);
|
|
575
|
+
expect(placed[0]?.width).toBeCloseTo(100 / 7, 10);
|
|
576
|
+
expect(placed[0]?.continuesBefore).toBe(false);
|
|
577
|
+
expect(placed[0]?.continuesAfter).toBe(false);
|
|
578
|
+
});
|
|
579
|
+
|
|
580
|
+
test("intervals running past an edge are cut there and say so", () => {
|
|
581
|
+
const placed: Array<PositionedInterval<TimeInterval>> =
|
|
582
|
+
ScheduleTimelineLayout.positionIntervals(
|
|
583
|
+
[
|
|
584
|
+
interval("2026-09-10T09:00:00Z", "2026-09-15T00:00:00Z"),
|
|
585
|
+
interval("2026-09-20T00:00:00Z", "2026-09-25T00:00:00Z"),
|
|
586
|
+
interval("2026-09-01T00:00:00Z", "2026-10-01T00:00:00Z"),
|
|
587
|
+
],
|
|
588
|
+
range,
|
|
589
|
+
);
|
|
590
|
+
|
|
591
|
+
expect(placed[0]).toMatchObject({
|
|
592
|
+
left: 0,
|
|
593
|
+
continuesBefore: true,
|
|
594
|
+
continuesAfter: false,
|
|
595
|
+
});
|
|
596
|
+
expect(placed[0]?.width).toBeCloseTo(100 / 7, 10);
|
|
597
|
+
|
|
598
|
+
expect(placed[1]?.left).toBeCloseTo((6 * 100) / 7, 10);
|
|
599
|
+
expect((placed[1]?.left || 0) + (placed[1]?.width || 0)).toBeCloseTo(
|
|
600
|
+
100,
|
|
601
|
+
10,
|
|
602
|
+
);
|
|
603
|
+
expect(placed[1]?.continuesAfter).toBe(true);
|
|
604
|
+
|
|
605
|
+
expect(placed[2]).toMatchObject({
|
|
606
|
+
left: 0,
|
|
607
|
+
width: 100,
|
|
608
|
+
continuesBefore: true,
|
|
609
|
+
continuesAfter: true,
|
|
610
|
+
});
|
|
611
|
+
});
|
|
612
|
+
|
|
613
|
+
test("the original item is carried through", () => {
|
|
614
|
+
const item: TimeInterval & { name: string } = {
|
|
615
|
+
...interval("2026-09-15T09:00:00Z", "2026-09-15T17:00:00Z"),
|
|
616
|
+
name: "Alice",
|
|
617
|
+
};
|
|
618
|
+
|
|
619
|
+
const placed: Array<PositionedInterval<TimeInterval & { name: string }>> =
|
|
620
|
+
ScheduleTimelineLayout.positionIntervals([item], range);
|
|
621
|
+
|
|
622
|
+
expect(placed[0]?.item).toBe(item);
|
|
623
|
+
});
|
|
624
|
+
|
|
625
|
+
test("back-to-back intervals tile without overlap", () => {
|
|
626
|
+
const placed: Array<PositionedInterval<TimeInterval>> =
|
|
627
|
+
ScheduleTimelineLayout.positionIntervals(
|
|
628
|
+
[
|
|
629
|
+
interval("2026-09-14T00:00:00Z", "2026-09-16T09:00:00Z"),
|
|
630
|
+
interval("2026-09-16T09:00:00Z", "2026-09-21T00:00:00Z"),
|
|
631
|
+
],
|
|
632
|
+
range,
|
|
633
|
+
);
|
|
634
|
+
|
|
635
|
+
expect(placed[0]!.left + placed[0]!.width).toBeCloseTo(placed[1]!.left, 10);
|
|
636
|
+
expect(placed[0]!.width + placed[1]!.width).toBeCloseTo(100, 10);
|
|
637
|
+
});
|
|
638
|
+
});
|
|
639
|
+
|
|
640
|
+
describe("computeGaps", () => {
|
|
641
|
+
const start: Date = at("2026-09-14T00:00:00Z");
|
|
642
|
+
const end: Date = at("2026-09-21T00:00:00Z");
|
|
643
|
+
|
|
644
|
+
test("no intervals: the whole window is a gap", () => {
|
|
645
|
+
expect(ScheduleTimelineLayout.computeGaps([], start, end)).toEqual([
|
|
646
|
+
{ start, end },
|
|
647
|
+
]);
|
|
648
|
+
});
|
|
649
|
+
|
|
650
|
+
test("full coverage: no gaps", () => {
|
|
651
|
+
expect(
|
|
652
|
+
ScheduleTimelineLayout.computeGaps(
|
|
653
|
+
[interval("2026-09-01T00:00:00Z", "2026-10-01T00:00:00Z")],
|
|
654
|
+
start,
|
|
655
|
+
end,
|
|
656
|
+
),
|
|
657
|
+
).toEqual([]);
|
|
658
|
+
});
|
|
659
|
+
|
|
660
|
+
test("holes between, before and after intervals", () => {
|
|
661
|
+
const gaps: Array<TimeInterval> = ScheduleTimelineLayout.computeGaps(
|
|
662
|
+
[
|
|
663
|
+
interval("2026-09-15T00:00:00Z", "2026-09-16T00:00:00Z"),
|
|
664
|
+
interval("2026-09-17T00:00:00Z", "2026-09-18T00:00:00Z"),
|
|
665
|
+
],
|
|
666
|
+
start,
|
|
667
|
+
end,
|
|
668
|
+
);
|
|
669
|
+
|
|
670
|
+
expect(
|
|
671
|
+
gaps.map((gap: TimeInterval) => {
|
|
672
|
+
return [gap.start.toISOString(), gap.end.toISOString()];
|
|
673
|
+
}),
|
|
674
|
+
).toEqual([
|
|
675
|
+
["2026-09-14T00:00:00.000Z", "2026-09-15T00:00:00.000Z"],
|
|
676
|
+
["2026-09-16T00:00:00.000Z", "2026-09-17T00:00:00.000Z"],
|
|
677
|
+
["2026-09-18T00:00:00.000Z", "2026-09-21T00:00:00.000Z"],
|
|
678
|
+
]);
|
|
679
|
+
});
|
|
680
|
+
|
|
681
|
+
test("unsorted and overlapping input is merged", () => {
|
|
682
|
+
const gaps: Array<TimeInterval> = ScheduleTimelineLayout.computeGaps(
|
|
683
|
+
[
|
|
684
|
+
interval("2026-09-18T00:00:00Z", "2026-09-21T00:00:00Z"),
|
|
685
|
+
interval("2026-09-14T00:00:00Z", "2026-09-16T00:00:00Z"),
|
|
686
|
+
interval("2026-09-15T00:00:00Z", "2026-09-17T00:00:00Z"),
|
|
687
|
+
],
|
|
688
|
+
start,
|
|
689
|
+
end,
|
|
690
|
+
);
|
|
691
|
+
|
|
692
|
+
expect(gaps).toHaveLength(1);
|
|
693
|
+
expect(gaps[0]?.start.toISOString()).toBe("2026-09-17T00:00:00.000Z");
|
|
694
|
+
expect(gaps[0]?.end.toISOString()).toBe("2026-09-18T00:00:00.000Z");
|
|
695
|
+
});
|
|
696
|
+
|
|
697
|
+
test("holes shorter than the minimum are ignored", () => {
|
|
698
|
+
const gaps: Array<TimeInterval> = ScheduleTimelineLayout.computeGaps(
|
|
699
|
+
[
|
|
700
|
+
interval("2026-09-14T00:00:00Z", "2026-09-16T09:00:00Z"),
|
|
701
|
+
// The engine's one-second seam.
|
|
702
|
+
interval("2026-09-16T09:00:01Z", "2026-09-21T00:00:00Z"),
|
|
703
|
+
],
|
|
704
|
+
start,
|
|
705
|
+
end,
|
|
706
|
+
);
|
|
707
|
+
|
|
708
|
+
expect(gaps).toEqual([]);
|
|
709
|
+
});
|
|
710
|
+
|
|
711
|
+
test("a custom minimum", () => {
|
|
712
|
+
const gaps: Array<TimeInterval> = ScheduleTimelineLayout.computeGaps(
|
|
713
|
+
[
|
|
714
|
+
interval("2026-09-14T00:00:00Z", "2026-09-16T09:00:00Z"),
|
|
715
|
+
interval("2026-09-16T09:30:00Z", "2026-09-21T00:00:00Z"),
|
|
716
|
+
],
|
|
717
|
+
start,
|
|
718
|
+
end,
|
|
719
|
+
60 * 60 * 1000,
|
|
720
|
+
);
|
|
721
|
+
|
|
722
|
+
expect(gaps).toEqual([]);
|
|
723
|
+
});
|
|
724
|
+
|
|
725
|
+
test("empty and zero-length intervals are ignored", () => {
|
|
726
|
+
const gaps: Array<TimeInterval> = ScheduleTimelineLayout.computeGaps(
|
|
727
|
+
[
|
|
728
|
+
interval("2026-09-15T00:00:00Z", "2026-09-15T00:00:00Z"),
|
|
729
|
+
interval("2026-09-16T00:00:00Z", "2026-09-15T00:00:00Z"),
|
|
730
|
+
],
|
|
731
|
+
start,
|
|
732
|
+
end,
|
|
733
|
+
);
|
|
734
|
+
|
|
735
|
+
expect(gaps).toEqual([{ start, end }]);
|
|
736
|
+
});
|
|
737
|
+
|
|
738
|
+
test("an inverted window has no gaps", () => {
|
|
739
|
+
expect(ScheduleTimelineLayout.computeGaps([], end, start)).toEqual([]);
|
|
740
|
+
});
|
|
741
|
+
});
|
|
742
|
+
|
|
743
|
+
describe("findActive", () => {
|
|
744
|
+
const shifts: Array<TimeInterval & { id: string }> = [
|
|
745
|
+
{ id: "a", ...interval("2026-09-14T00:00:00Z", "2026-09-15T00:00:00Z") },
|
|
746
|
+
{ id: "b", ...interval("2026-09-15T00:00:00Z", "2026-09-16T00:00:00Z") },
|
|
747
|
+
];
|
|
748
|
+
|
|
749
|
+
test("returns the interval containing now; end is exclusive", () => {
|
|
750
|
+
expect(
|
|
751
|
+
ScheduleTimelineLayout.findActive(shifts, at("2026-09-14T12:00:00Z"))?.id,
|
|
752
|
+
).toBe("a");
|
|
753
|
+
expect(
|
|
754
|
+
ScheduleTimelineLayout.findActive(shifts, at("2026-09-15T00:00:00Z"))?.id,
|
|
755
|
+
).toBe("b");
|
|
756
|
+
});
|
|
757
|
+
|
|
758
|
+
test("returns null in a hole", () => {
|
|
759
|
+
expect(
|
|
760
|
+
ScheduleTimelineLayout.findActive(shifts, at("2026-09-17T00:00:00Z")),
|
|
761
|
+
).toBeNull();
|
|
762
|
+
});
|
|
763
|
+
});
|
|
764
|
+
|
|
765
|
+
describe("formatInterval", () => {
|
|
766
|
+
test("same day, 24-hour clock", () => {
|
|
767
|
+
expect(
|
|
768
|
+
ScheduleTimelineLayout.formatInterval({
|
|
769
|
+
start: at("2026-09-15T09:00:00Z"),
|
|
770
|
+
end: at("2026-09-15T17:30:00Z"),
|
|
771
|
+
timezone: UTC,
|
|
772
|
+
use12HourFormat: false,
|
|
773
|
+
}),
|
|
774
|
+
).toBe("Tue, Sep 15, 09:00 – 17:30");
|
|
775
|
+
});
|
|
776
|
+
|
|
777
|
+
test("across days", () => {
|
|
778
|
+
expect(
|
|
779
|
+
ScheduleTimelineLayout.formatInterval({
|
|
780
|
+
start: at("2026-09-14T09:00:00Z"),
|
|
781
|
+
end: at("2026-09-21T09:00:00Z"),
|
|
782
|
+
timezone: UTC,
|
|
783
|
+
use12HourFormat: false,
|
|
784
|
+
}),
|
|
785
|
+
).toBe("Mon, Sep 14, 09:00 → Mon, Sep 21, 09:00");
|
|
786
|
+
});
|
|
787
|
+
|
|
788
|
+
test("across years names the end's year", () => {
|
|
789
|
+
expect(
|
|
790
|
+
ScheduleTimelineLayout.formatInterval({
|
|
791
|
+
start: at("2026-12-31T20:00:00Z"),
|
|
792
|
+
end: at("2027-01-01T08:00:00Z"),
|
|
793
|
+
timezone: UTC,
|
|
794
|
+
use12HourFormat: false,
|
|
795
|
+
}),
|
|
796
|
+
).toBe("Thu, Dec 31, 20:00 → Fri, Jan 1, 2027, 08:00");
|
|
797
|
+
});
|
|
798
|
+
|
|
799
|
+
test("12-hour clock", () => {
|
|
800
|
+
expect(
|
|
801
|
+
ScheduleTimelineLayout.formatInterval({
|
|
802
|
+
start: at("2026-09-15T09:00:00Z"),
|
|
803
|
+
end: at("2026-09-15T17:00:00Z"),
|
|
804
|
+
timezone: UTC,
|
|
805
|
+
use12HourFormat: true,
|
|
806
|
+
}),
|
|
807
|
+
).toBe("Tue, Sep 15, 9:00 AM – 5:00 PM");
|
|
808
|
+
});
|
|
809
|
+
|
|
810
|
+
test("is written in the view zone", () => {
|
|
811
|
+
expect(
|
|
812
|
+
ScheduleTimelineLayout.formatInterval({
|
|
813
|
+
start: at("2026-09-15T09:00:00Z"),
|
|
814
|
+
end: at("2026-09-15T17:00:00Z"),
|
|
815
|
+
timezone: TOKYO,
|
|
816
|
+
use12HourFormat: false,
|
|
817
|
+
}),
|
|
818
|
+
).toBe("Tue, Sep 15, 18:00 → Wed, Sep 16, 02:00");
|
|
819
|
+
});
|
|
820
|
+
});
|
|
821
|
+
|
|
822
|
+
describe("formatDuration", () => {
|
|
823
|
+
test.each([
|
|
824
|
+
[0, "<1m"],
|
|
825
|
+
[59 * 1000, "<1m"],
|
|
826
|
+
[Number.NaN, "<1m"],
|
|
827
|
+
[45 * 60 * 1000, "45m"],
|
|
828
|
+
[8 * 3600 * 1000, "8h"],
|
|
829
|
+
[(8 * 60 + 30) * 60 * 1000, "8h 30m"],
|
|
830
|
+
[24 * 3600 * 1000, "1d"],
|
|
831
|
+
[(3 * 24 + 12) * 3600 * 1000, "3d 12h"],
|
|
832
|
+
[7 * 24 * 3600 * 1000, "7d"],
|
|
833
|
+
])("%p ms -> %s", (milliseconds: number, expected: string) => {
|
|
834
|
+
expect(ScheduleTimelineLayout.formatDuration(milliseconds)).toBe(expected);
|
|
835
|
+
});
|
|
836
|
+
});
|
|
837
|
+
|
|
838
|
+
describe("sumWithin", () => {
|
|
839
|
+
test("clips each interval to the window and adds them up", () => {
|
|
840
|
+
const total: number = ScheduleTimelineLayout.sumWithin(
|
|
841
|
+
[
|
|
842
|
+
interval("2026-09-13T00:00:00Z", "2026-09-15T00:00:00Z"),
|
|
843
|
+
interval("2026-09-16T00:00:00Z", "2026-09-16T12:00:00Z"),
|
|
844
|
+
interval("2026-09-20T00:00:00Z", "2026-09-23T00:00:00Z"),
|
|
845
|
+
interval("2026-10-01T00:00:00Z", "2026-10-02T00:00:00Z"),
|
|
846
|
+
],
|
|
847
|
+
interval("2026-09-14T00:00:00Z", "2026-09-21T00:00:00Z"),
|
|
848
|
+
);
|
|
849
|
+
|
|
850
|
+
expect(total).toBe((24 + 12 + 24) * 3600 * 1000);
|
|
851
|
+
});
|
|
852
|
+
|
|
853
|
+
test("overlaps are counted twice (load, not presence)", () => {
|
|
854
|
+
const total: number = ScheduleTimelineLayout.sumWithin(
|
|
855
|
+
[
|
|
856
|
+
interval("2026-09-14T00:00:00Z", "2026-09-15T00:00:00Z"),
|
|
857
|
+
interval("2026-09-14T00:00:00Z", "2026-09-15T00:00:00Z"),
|
|
858
|
+
],
|
|
859
|
+
interval("2026-09-14T00:00:00Z", "2026-09-21T00:00:00Z"),
|
|
860
|
+
);
|
|
861
|
+
|
|
862
|
+
expect(total).toBe(48 * 3600 * 1000);
|
|
863
|
+
});
|
|
864
|
+
});
|
|
865
|
+
|
|
866
|
+
describe("getNavigability", () => {
|
|
867
|
+
const addressable: TimeInterval = interval(
|
|
868
|
+
"2026-03-21T12:00:00Z",
|
|
869
|
+
"2027-09-17T12:00:00Z",
|
|
870
|
+
);
|
|
871
|
+
|
|
872
|
+
test("free movement in the middle", () => {
|
|
873
|
+
expect(
|
|
874
|
+
ScheduleTimelineLayout.getNavigability({
|
|
875
|
+
mode: TimelineViewMode.Week,
|
|
876
|
+
anchor: at("2026-09-17T12:00:00Z"),
|
|
877
|
+
timezone: UTC,
|
|
878
|
+
addressable,
|
|
879
|
+
}),
|
|
880
|
+
).toEqual({ canGoBack: true, canGoForward: true });
|
|
881
|
+
});
|
|
882
|
+
|
|
883
|
+
test("cannot go back once the previous week is wholly out of range", () => {
|
|
884
|
+
/*
|
|
885
|
+
* The week of 2026-03-23; the previous week ends 2026-03-23 00:00, which
|
|
886
|
+
* is after the earliest instant, so it is still reachable...
|
|
887
|
+
*/
|
|
888
|
+
expect(
|
|
889
|
+
ScheduleTimelineLayout.getNavigability({
|
|
890
|
+
mode: TimelineViewMode.Week,
|
|
891
|
+
anchor: at("2026-03-25T12:00:00Z"),
|
|
892
|
+
timezone: UTC,
|
|
893
|
+
addressable,
|
|
894
|
+
}).canGoBack,
|
|
895
|
+
).toBe(true);
|
|
896
|
+
|
|
897
|
+
/*
|
|
898
|
+
* ...but from the week of 2026-03-16 the previous one ends 2026-03-16,
|
|
899
|
+
* before the earliest instant.
|
|
900
|
+
*/
|
|
901
|
+
expect(
|
|
902
|
+
ScheduleTimelineLayout.getNavigability({
|
|
903
|
+
mode: TimelineViewMode.Week,
|
|
904
|
+
anchor: at("2026-03-18T12:00:00Z"),
|
|
905
|
+
timezone: UTC,
|
|
906
|
+
addressable,
|
|
907
|
+
}).canGoBack,
|
|
908
|
+
).toBe(false);
|
|
909
|
+
});
|
|
910
|
+
|
|
911
|
+
test("cannot go forward once the next month starts after the limit", () => {
|
|
912
|
+
expect(
|
|
913
|
+
ScheduleTimelineLayout.getNavigability({
|
|
914
|
+
mode: TimelineViewMode.Month,
|
|
915
|
+
anchor: at("2027-08-15T12:00:00Z"),
|
|
916
|
+
timezone: UTC,
|
|
917
|
+
addressable,
|
|
918
|
+
}).canGoForward,
|
|
919
|
+
).toBe(true);
|
|
920
|
+
|
|
921
|
+
expect(
|
|
922
|
+
ScheduleTimelineLayout.getNavigability({
|
|
923
|
+
mode: TimelineViewMode.Month,
|
|
924
|
+
anchor: at("2027-09-15T12:00:00Z"),
|
|
925
|
+
timezone: UTC,
|
|
926
|
+
addressable,
|
|
927
|
+
}).canGoForward,
|
|
928
|
+
).toBe(false);
|
|
929
|
+
});
|
|
930
|
+
});
|
|
931
|
+
|
|
932
|
+
describe("colours", () => {
|
|
933
|
+
test("withAlpha converts #rrggbb and #rgb", () => {
|
|
934
|
+
expect(ScheduleTimelineLayout.withAlpha("#6366f1", 0.2)).toBe(
|
|
935
|
+
"rgba(99, 102, 241, 0.2)",
|
|
936
|
+
);
|
|
937
|
+
expect(ScheduleTimelineLayout.withAlpha("#fff", 1)).toBe(
|
|
938
|
+
"rgba(255, 255, 255, 1)",
|
|
939
|
+
);
|
|
940
|
+
expect(ScheduleTimelineLayout.withAlpha(" #000000 ", 0.5)).toBe(
|
|
941
|
+
"rgba(0, 0, 0, 0.5)",
|
|
942
|
+
);
|
|
943
|
+
});
|
|
944
|
+
|
|
945
|
+
test("withAlpha clamps alpha and leaves non-hex colours alone", () => {
|
|
946
|
+
expect(ScheduleTimelineLayout.withAlpha("#000000", 4)).toBe(
|
|
947
|
+
"rgba(0, 0, 0, 1)",
|
|
948
|
+
);
|
|
949
|
+
expect(ScheduleTimelineLayout.withAlpha("#000000", -1)).toBe(
|
|
950
|
+
"rgba(0, 0, 0, 0)",
|
|
951
|
+
);
|
|
952
|
+
expect(ScheduleTimelineLayout.withAlpha("red", 0.5)).toBe("red");
|
|
953
|
+
expect(ScheduleTimelineLayout.withAlpha("#12345", 0.5)).toBe("#12345");
|
|
954
|
+
});
|
|
955
|
+
|
|
956
|
+
test("getContrastTextColor picks dark text on light colours", () => {
|
|
957
|
+
expect(ScheduleTimelineLayout.getContrastTextColor("#ffbf53")).toBe(
|
|
958
|
+
"#111827",
|
|
959
|
+
);
|
|
960
|
+
expect(ScheduleTimelineLayout.getContrastTextColor("#84cc16")).toBe(
|
|
961
|
+
"#111827",
|
|
962
|
+
);
|
|
963
|
+
expect(ScheduleTimelineLayout.getContrastTextColor("#000000")).toBe(
|
|
964
|
+
"#ffffff",
|
|
965
|
+
);
|
|
966
|
+
expect(ScheduleTimelineLayout.getContrastTextColor("#6366f1")).toBe(
|
|
967
|
+
"#ffffff",
|
|
968
|
+
);
|
|
969
|
+
expect(ScheduleTimelineLayout.getContrastTextColor("nonsense")).toBe(
|
|
970
|
+
"#ffffff",
|
|
971
|
+
);
|
|
972
|
+
});
|
|
973
|
+
});
|
|
974
|
+
|
|
975
|
+
describe("getDayKey / isWithinRange", () => {
|
|
976
|
+
test("the day key is the view zone's date", () => {
|
|
977
|
+
const instant: Date = at("2026-09-17T23:30:00Z");
|
|
978
|
+
|
|
979
|
+
expect(ScheduleTimelineLayout.getDayKey(instant, UTC)).toBe("2026-09-17");
|
|
980
|
+
expect(ScheduleTimelineLayout.getDayKey(instant, TOKYO)).toBe("2026-09-18");
|
|
981
|
+
});
|
|
982
|
+
|
|
983
|
+
test("the range end is exclusive", () => {
|
|
984
|
+
const range: TimeInterval = interval(
|
|
985
|
+
"2026-09-14T00:00:00Z",
|
|
986
|
+
"2026-09-21T00:00:00Z",
|
|
987
|
+
);
|
|
988
|
+
|
|
989
|
+
expect(
|
|
990
|
+
ScheduleTimelineLayout.isWithinRange(at("2026-09-14T00:00:00Z"), range),
|
|
991
|
+
).toBe(true);
|
|
992
|
+
expect(
|
|
993
|
+
ScheduleTimelineLayout.isWithinRange(at("2026-09-21T00:00:00Z"), range),
|
|
994
|
+
).toBe(false);
|
|
995
|
+
});
|
|
996
|
+
});
|