@oneuptime/common 14.0.7 → 14.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/Incident.ts +267 -1
- package/Models/DatabaseModels/IncidentCustomField.ts +202 -0
- package/Models/DatabaseModels/IncidentEpisode.ts +30 -0
- package/Models/DatabaseModels/IncidentTemplate.ts +126 -1
- package/Models/DatabaseModels/StatusPage.ts +55 -0
- package/Models/DatabaseModels/StatusPageSubscriber.ts +128 -0
- package/Server/API/IncidentAPI.ts +162 -0
- package/Server/API/StatusPageAPI.ts +487 -171
- package/Server/API/StatusPageSubscriberAPI.ts +63 -15
- package/Server/Infrastructure/Postgres/SchemaMigrations/1795300000000-SkipHiddenIncidentCreatedNotifications.ts +49 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1795400000000-AddIncidentStatusPageScope.ts +108 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1795500000000-AddIncidentTemplateStatusPageScopeFlag.ts +33 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1795600000000-AddStatusPageSubscriberUnsubscribeToken.ts +51 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1795700000000-AddStatusPageSubscriberIsAddedByTeam.ts +33 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1795800000000-AddIncidentCustomFieldCreateAndNotificationSettings.ts +168 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1795900000000-AddSubscriberNotificationClaimedAt.ts +44 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +14 -0
- package/Server/Infrastructure/Semaphore.ts +10 -0
- package/Server/Middleware/IdentityRateLimit.ts +108 -3
- package/Server/Middleware/SubscriberNotificationPreviewRateLimit.ts +237 -0
- package/Server/Middleware/SubscriberNotificationTestSendRateLimit.ts +304 -0
- package/Server/Services/DatabaseService.ts +93 -10
- package/Server/Services/IncidentCustomFieldService.ts +276 -1
- package/Server/Services/IncidentEpisodePublicNoteService.ts +28 -0
- package/Server/Services/IncidentEpisodeService.ts +15 -0
- package/Server/Services/IncidentEpisodeStateTimelineService.ts +27 -1
- package/Server/Services/IncidentPublicNoteService.ts +30 -1
- package/Server/Services/IncidentService.ts +1535 -65
- package/Server/Services/IncidentStateTimelineService.ts +13 -0
- package/Server/Services/IncidentTemplateService.ts +109 -0
- package/Server/Services/ScheduledMaintenancePublicNoteService.ts +30 -1
- package/Server/Services/ScheduledMaintenanceService.ts +68 -18
- package/Server/Services/SmsService.ts +10 -0
- package/Server/Services/StatusPageService.ts +65 -8
- package/Server/Services/StatusPageSubscriberNotificationTemplateService.ts +299 -37
- package/Server/Services/StatusPageSubscriberNotificationTemplateStatusPageService.ts +129 -0
- package/Server/Services/StatusPageSubscriberService.ts +1161 -64
- package/Server/Types/Markdown.ts +153 -6
- package/Server/Types/Workflow/Components/Email.ts +61 -2
- package/Server/Utils/CustomField/CustomFieldRename.ts +378 -0
- package/Server/Utils/DataSource/EgressGuard.ts +66 -21
- package/Server/Utils/Mail/PinnedSmtpSocket.ts +130 -0
- package/Server/Utils/Monitor/MonitorCriteriaObservationBuilder.ts +10 -0
- package/Server/Utils/SSRFProtection.ts +76 -16
- package/Server/Utils/StatusPage/IncidentStatusPageScope.ts +948 -0
- package/Server/Utils/StatusPage/IncidentSubscriberAudienceBuilder.ts +656 -0
- package/Server/Utils/StatusPage/IncidentTemplateVariableBuilder.ts +805 -0
- package/Server/Utils/StatusPage/StatusPageExclusion.ts +18 -0
- package/Server/Utils/StatusPage/StatusPageReadAccess.ts +125 -0
- package/Server/Utils/StatusPage/StatusPageSubscriberUnsubscribeNotice.ts +151 -0
- package/Server/Utils/StatusPage/StatusPageSubscriberUnsubscribeToken.ts +70 -0
- package/Server/Utils/StatusPage/SubscriberIncidentEmailBuilder.ts +421 -0
- package/Server/Utils/StatusPage/SubscriberNotificationClaim.ts +107 -0
- package/Server/Utils/StatusPage/SubscriberNotificationDeliveryRecord.ts +1049 -0
- package/Server/Utils/StatusPage/SubscriberNotificationFanOut.ts +180 -0
- package/Server/Utils/StatusPage/SubscriberNotificationPreviewBuilder.ts +839 -0
- package/Server/Utils/StatusPage/SubscriberNotificationResendAccess.ts +393 -0
- package/Server/Utils/StatusPage/SubscriberNotificationRunLimit.ts +246 -0
- package/Server/Utils/StatusPage/SubscriberNotificationTiming.ts +133 -0
- package/Server/Utils/StatusPage/SubscriberTemplateIncidentRecordAccess.ts +215 -0
- package/Server/Utils/StatusPageResource.ts +51 -20
- package/Server/Utils/VM/VMAPI.ts +1 -0
- package/Server/Utils/VM/VMRunner.ts +10 -0
- package/Server/Utils/Workflow/OAuth2TokenClient.ts +10 -0
- package/Server/Views/Partials/SensitiveUrlToken.ejs +8 -5
- package/Tests/App/Accounts/RegisterVerifyEmail.test.tsx +748 -0
- package/Tests/App/Accounts/ResendVerificationEmail.test.tsx +1222 -0
- package/Tests/App/Accounts/VerificationEmailResendUtils.test.ts +797 -0
- package/Tests/App/Accounts/VerifyEmailPending.test.tsx +538 -0
- package/Tests/App/Accounts/VerifyEmailResend.test.tsx +779 -0
- package/Tests/App/Dashboard/CustomFieldsSettingsIncidentOptions.test.tsx +357 -0
- package/Tests/App/Dashboard/EventNotes.test.tsx +776 -0
- package/Tests/App/Dashboard/EventNotesPages.test.tsx +119 -0
- package/Tests/App/Dashboard/EventNotesUtil.test.ts +116 -17
- package/Tests/App/Dashboard/EventOverviewPages.test.tsx +242 -5
- package/Tests/App/Dashboard/IncidentChangeStateNotifyDefault.test.tsx +91 -1
- package/Tests/App/Dashboard/IncidentCreateDetailsStep.test.tsx +643 -0
- package/Tests/App/Dashboard/IncidentCreateFromAlerts.test.tsx +8 -1
- package/Tests/App/Dashboard/IncidentCreateStatusPageScope.test.tsx +601 -0
- package/Tests/App/Dashboard/IncidentCustomFieldTemplateVariables.test.tsx +386 -0
- package/Tests/App/Dashboard/IncidentNoteTemplatePlaceholders.test.tsx +124 -0
- package/Tests/App/Dashboard/IncidentNoteTemplateVariablesLoader.test.ts +305 -0
- package/Tests/App/Dashboard/IncidentOverviewNotifyDefault.test.tsx +112 -0
- package/Tests/App/Dashboard/IncidentSettingsRenotifyOnPublish.test.tsx +674 -0
- package/Tests/App/Dashboard/IncidentSettingsStatusPageScope.test.tsx +1051 -0
- package/Tests/App/Dashboard/IncidentTemplateCustomFields.test.tsx +384 -0
- package/Tests/App/Dashboard/IncidentTemplateStatusPageScopeCard.test.tsx +215 -0
- package/Tests/App/Dashboard/PublicNotePagesNotifyDefault.test.tsx +113 -1
- package/Tests/App/Dashboard/SubscriberAudienceSummary.test.tsx +512 -0
- package/Tests/App/Dashboard/SubscriberNotificationPreviewModal.test.tsx +837 -0
- package/Tests/App/Dashboard/SubscriberNotificationStatusLabel.test.tsx +88 -0
- package/Tests/App/Dashboard/SubscriberNotificationStatusResend.test.tsx +473 -0
- package/Tests/App/Dashboard/SubscriberTemplateLivePreview.test.tsx +196 -0
- package/Tests/App/Dashboard/TeamAddedSubscribersUnsubscribedNotice.test.tsx +248 -0
- package/Tests/App/SensitiveUrlTokenBootstrap.test.ts +64 -3
- package/Tests/App/StatusPage/StatusPageUnsubscribePage.test.tsx +412 -0
- package/Tests/Models/IncidentCustomFieldApiSchemaContract.test.ts +217 -0
- package/Tests/Models/IncidentCustomFieldCreateSettingsColumns.test.ts +252 -0
- package/Tests/Models/StatusPageSubscriberUnsubscribeColumns.test.ts +218 -0
- package/Tests/Server/API/ExpiredSessionRouteGuards.test.ts +7 -0
- package/Tests/Server/API/IncidentSubscriberAudienceAPI.test.ts +1408 -0
- package/Tests/Server/API/StatusPageIncidentScope.test.ts +1868 -0
- package/Tests/Server/API/StatusPageIncidentScopePostgres.test.ts +790 -0
- package/Tests/Server/API/StatusPageManageSubscriptionRecipient.test.ts +10 -1
- package/Tests/Server/API/StatusPageManageSubscriptionTemplateVariables.test.ts +206 -18
- package/Tests/Server/API/StatusPagePostmortemVisibility.test.ts +14 -2
- package/Tests/Server/API/StatusPageSubscriberCreateResponse.test.ts +217 -0
- package/Tests/Server/API/StatusPageSubscriberOwnership.test.ts +103 -2
- package/Tests/Server/API/StatusPageUnsubscribeAPI.test.ts +396 -0
- package/Tests/Server/Infrastructure/Postgres/AddIncidentStatusPageScopeMigration.test.ts +395 -0
- package/Tests/Server/Infrastructure/Postgres/AddIncidentTemplateStatusPageScopeFlagMigration.test.ts +150 -0
- package/Tests/Server/Infrastructure/Postgres/AddSubscriberNotificationClaimedAtMigration.test.ts +156 -0
- package/Tests/Server/Infrastructure/Postgres/SkipHiddenIncidentCreatedNotificationsMigration.test.ts +410 -0
- package/Tests/Server/Middleware/IdentityRateLimit.test.ts +551 -1
- package/Tests/Server/Middleware/SubscriberNotificationPreviewRateLimit.test.ts +238 -0
- package/Tests/Server/Middleware/SubscriberNotificationTestSendRateLimit.test.ts +245 -0
- package/Tests/Server/Services/AddStatusPageSubscriberUnsubscribeTokenMigration.test.ts +152 -0
- package/Tests/Server/Services/CrossProjectRelationWriteGuard.test.ts +221 -36
- package/Tests/Server/Services/DatabaseServiceCompareAndSetColumns.test.ts +191 -0
- package/Tests/Server/Services/IncidentCreatedRenotifyOnPublish.test.ts +681 -0
- package/Tests/Server/Services/IncidentCreatedResend.test.ts +775 -0
- package/Tests/Server/Services/IncidentCustomFieldRenamePostgres.test.ts +713 -0
- package/Tests/Server/Services/IncidentCustomFieldService.test.ts +751 -0
- package/Tests/Server/Services/IncidentCustomFieldValueValidation.test.ts +556 -0
- package/Tests/Server/Services/IncidentStatusPageScope.test.ts +2971 -0
- package/Tests/Server/Services/IncidentStatusPageScopeFeed.test.ts +131 -0
- package/Tests/Server/Services/IncidentStatusPageScopePostgres.test.ts +625 -0
- package/Tests/Server/Services/IncidentTemplateCustomFieldsCopy.test.ts +311 -0
- package/Tests/Server/Services/IncidentTemplateStatusPageScope.test.ts +363 -0
- package/Tests/Server/Services/PublicNoteEditFeedEventType.test.ts +213 -0
- package/Tests/Server/Services/PublicNoteResendAccess.test.ts +994 -0
- package/Tests/Server/Services/ScheduledMaintenanceSubscriberTemplateFormats.test.ts +289 -9
- package/Tests/Server/Services/SmsServiceFailIfNotSent.test.ts +67 -0
- package/Tests/Server/Services/StatusPageReportIncidentCounts.test.ts +610 -0
- package/Tests/Server/Services/StatusPageSubscriberAudienceCounts.test.ts +201 -0
- package/Tests/Server/Services/StatusPageSubscriberAudienceCountsPostgres.test.ts +271 -0
- package/Tests/Server/Services/StatusPageSubscriberConfirmationTemplateEscaping.test.ts +200 -0
- package/Tests/Server/Services/StatusPageSubscriberNotificationLogRedaction.test.ts +54 -0
- package/Tests/Server/Services/StatusPageSubscriberNotificationTemplateCompile.test.ts +37 -0
- package/Tests/Server/Services/StatusPageSubscriberNotificationTemplateIncidentRecordAccess.test.ts +772 -0
- package/Tests/Server/Services/StatusPageSubscriberNotificationTemplateLookup.test.ts +506 -0
- package/Tests/Server/Services/StatusPageSubscriberNotificationTemplateLookupPostgres.test.ts +261 -0
- package/Tests/Server/Services/StatusPageSubscriberReport.test.ts +21 -5
- package/Tests/Server/Services/StatusPageSubscriberUnsubscribe.test.ts +1618 -0
- package/Tests/Server/Services/StatusPageSubscriberUnsubscribeLinkSenders.test.ts +373 -0
- package/Tests/Server/Services/StatusPageSubscriberUnsubscribePostgres.test.ts +388 -0
- package/Tests/Server/Services/SubscriberNotificationInFlightRequeue.test.ts +500 -0
- package/Tests/Server/Types/MarkdownEmailLinks.test.ts +320 -0
- package/Tests/Server/Types/Workflow/Components/Email.test.ts +491 -1
- package/Tests/Server/Types/Workflow/Components/EmailSmtpPinning.test.ts +398 -0
- package/Tests/Server/Utils/CustomField/CustomFieldRename.test.ts +586 -0
- package/Tests/Server/Utils/DataSource/EgressGuard.test.ts +246 -10
- package/Tests/Server/Utils/DataSource/EgressGuardDeploymentConfig.test.ts +226 -0
- package/Tests/Server/Utils/DataSource/EgressGuardPinning.test.ts +131 -0
- package/Tests/Server/Utils/DataSource/HttpFetch.test.ts +4 -0
- package/Tests/Server/Utils/EgressPolicyEnvironment.ts +45 -0
- package/Tests/Server/Utils/Mail/PinnedSmtpSocket.test.ts +409 -0
- package/Tests/Server/Utils/Monitor/MonitorCriteriaObservationBuilderUnits.test.ts +23 -0
- package/Tests/Server/Utils/SSRFProtection.test.ts +4 -0
- package/Tests/Server/Utils/SSRFProtectionCloudServiceAddresses.test.ts +4 -0
- package/Tests/Server/Utils/SSRFProtectionPrivateNetwork.test.ts +4 -0
- package/Tests/Server/Utils/SSRFProtectionResolutionDetail.test.ts +314 -0
- package/Tests/Server/Utils/StatusPage/IncidentStatusPageScope.test.ts +1699 -0
- package/Tests/Server/Utils/StatusPage/IncidentStatusPageScopeQueriesPostgres.test.ts +508 -0
- package/Tests/Server/Utils/StatusPage/IncidentSubscriberAudienceCallerPermission.test.ts +246 -0
- package/Tests/Server/Utils/StatusPage/IncidentTemplateVariableBuilder.test.ts +1348 -0
- package/Tests/Server/Utils/StatusPage/StatusPageReadAccess.test.ts +221 -0
- package/Tests/Server/Utils/StatusPage/StatusPageSubscriberUnsubscribeNotice.test.ts +132 -0
- package/Tests/Server/Utils/StatusPage/StatusPageSubscriberUnsubscribeToken.test.ts +155 -0
- package/Tests/Server/Utils/StatusPage/SubscriberIncidentEmailBuilder.test.ts +708 -0
- package/Tests/Server/Utils/StatusPage/SubscriberNotificationClaim.test.ts +255 -0
- package/Tests/Server/Utils/StatusPage/SubscriberNotificationClaimPostgres.test.ts +528 -0
- package/Tests/Server/Utils/StatusPage/SubscriberNotificationDeliveryRecord.test.ts +1238 -0
- package/Tests/Server/Utils/StatusPage/SubscriberNotificationFanOut.test.ts +472 -0
- package/Tests/Server/Utils/StatusPage/SubscriberNotificationPreviewBuilder.test.ts +1168 -0
- package/Tests/Server/Utils/StatusPage/SubscriberNotificationRunLimit.test.ts +275 -0
- package/Tests/Server/Utils/StatusPage/SubscriberNotificationTiming.test.ts +131 -0
- package/Tests/Server/Utils/StatusPageResource.test.ts +98 -0
- package/Tests/Server/Utils/VM/VMRunnerPrivateNetworkWiring.test.ts +17 -0
- package/Tests/Server/Utils/VM/VMRunnerSsrf.test.ts +75 -0
- package/Tests/Types/CustomField/CustomFieldSavedViews.test.ts +247 -0
- package/Tests/Types/CustomField/CustomFieldTemplateValues.test.ts +186 -0
- package/Tests/Types/CustomField/CustomFieldTypeCorrespondence.test.ts +48 -0
- package/Tests/Types/CustomField/CustomFieldValueFormat.test.ts +215 -0
- package/Tests/Types/CustomField/CustomFieldValueValidator.test.ts +343 -0
- package/Tests/Types/CustomField/CustomFieldVariableKey.test.ts +364 -0
- package/Tests/Types/SafeHtml.test.ts +102 -0
- package/Tests/Types/StatusPage/IncidentCreatedRenotify.test.ts +419 -0
- package/Tests/Types/StatusPage/IncidentCreatedResend.test.ts +118 -0
- package/Tests/Types/StatusPage/IncidentScopeAddedPagesNotification.test.ts +558 -0
- package/Tests/Types/StatusPage/IncidentSubscriberAudience.test.ts +284 -0
- package/Tests/Types/StatusPage/StatusPageSubscriberUnsubscribe.test.ts +341 -0
- package/Tests/Types/StatusPage/SubscriberNotificationPreview.test.ts +196 -0
- package/Tests/Types/StatusPage/SubscriberNotificationResend.test.ts +201 -0
- package/Tests/Types/StatusPage/SubscriberNotificationTemplateCompiler.test.ts +277 -0
- package/Tests/Types/StatusPage/SubscriberNotificationTemplatePreview.test.ts +179 -0
- package/Tests/Types/StatusPage/SubscriberNotificationTemplateVariables.test.ts +324 -0
- package/Tests/Types/StatusPage/SubscriberUpdateNotification.test.ts +60 -13
- package/Tests/UI/Components/CustomFields/CustomFieldFormFields.test.ts +432 -0
- package/Tests/UI/Components/CustomFields/CustomFieldModelFormFields.test.tsx +685 -0
- package/Tests/UI/Components/CustomFields/CustomFieldsDetailOrder.test.tsx +469 -0
- package/Tests/UI/Components/Forms/ModelFormCustomFieldInputs.test.tsx +325 -0
- package/Tests/UI/Components/Forms/ModelFormDropdownOptionsRefused.test.tsx +358 -0
- package/Tests/UI/Components/ModelTable/CustomFieldColumns.test.tsx +22 -0
- package/Tests/UI/Monitor/NetworkPathView.test.tsx +289 -0
- package/Tests/Utils/Incident/IncidentNoteTemplateVariables.test.ts +623 -0
- package/Tests/Utils/Markdown/MarkdownEscape.test.ts +89 -0
- package/Tests/Utils/ProbeNetworkFailureUtil.test.ts +992 -0
- package/Tests/Utils/RequestFailedDetails.test.ts +575 -0
- package/Types/CustomField/CustomFieldOrder.ts +55 -0
- package/Types/CustomField/CustomFieldSavedViews.ts +225 -0
- package/Types/CustomField/CustomFieldTemplateMerge.ts +71 -0
- package/Types/CustomField/CustomFieldType.ts +14 -0
- package/Types/CustomField/CustomFieldValueFormat.ts +161 -0
- package/Types/CustomField/CustomFieldValueValidator.ts +488 -0
- package/Types/CustomField/CustomFieldVariableKey.ts +211 -0
- package/Types/SafeHtml.ts +93 -0
- package/Types/StatusPage/IncidentCreatedRenotify.ts +224 -0
- package/Types/StatusPage/IncidentCreatedResend.ts +108 -0
- package/Types/StatusPage/IncidentScopeAddedPagesNotification.ts +343 -0
- package/Types/StatusPage/IncidentSubscriberAudience.ts +332 -0
- package/Types/StatusPage/StatusPageSubscriberUnsubscribe.ts +405 -0
- package/Types/StatusPage/SubscriberNotificationInterruption.ts +32 -0
- package/Types/StatusPage/SubscriberNotificationPreview.ts +322 -0
- package/Types/StatusPage/SubscriberNotificationResend.ts +132 -0
- package/Types/StatusPage/SubscriberNotificationTemplateCompiler.ts +180 -0
- package/Types/StatusPage/SubscriberNotificationTemplatePreview.ts +301 -0
- package/Types/StatusPage/SubscriberNotificationTemplateVariables.ts +217 -4
- package/Types/StatusPage/SubscriberUpdateNotification.ts +32 -11
- package/UI/Components/CustomFields/CustomFieldFormFields.ts +317 -0
- package/UI/Components/CustomFields/CustomFieldModelFormFields.tsx +395 -0
- package/UI/Components/CustomFields/CustomFieldsDetail.tsx +95 -55
- package/UI/Components/Forms/ModelForm.tsx +70 -8
- package/UI/Components/Forms/Validation.ts +1 -1
- package/UI/Components/ModelFormModal/ModelFormModal.tsx +2 -4
- package/UI/Components/ModelTable/AnalyticsModelTable.tsx +2 -6
- package/UI/Components/ModelTable/BaseModelTable.tsx +9 -8
- package/UI/Components/ModelTable/CustomFieldColumns.tsx +14 -1
- package/UI/Components/ModelTable/ModelTable.tsx +6 -7
- package/UI/Utils/SensitiveUrlToken.ts +10 -5
- package/Utils/API.ts +247 -2
- package/Utils/Incident/IncidentNoteTemplateVariables.ts +304 -0
- package/Utils/Markdown/MarkdownEscape.ts +65 -0
- package/Utils/ProbeNetworkFailureUtil.ts +673 -0
- package/build/dist/Models/DatabaseModels/Incident.js +267 -1
- package/build/dist/Models/DatabaseModels/Incident.js.map +1 -1
- package/build/dist/Models/DatabaseModels/IncidentCustomField.js +207 -1
- package/build/dist/Models/DatabaseModels/IncidentCustomField.js.map +1 -1
- package/build/dist/Models/DatabaseModels/IncidentEpisode.js +31 -0
- package/build/dist/Models/DatabaseModels/IncidentEpisode.js.map +1 -1
- package/build/dist/Models/DatabaseModels/IncidentTemplate.js +124 -1
- package/build/dist/Models/DatabaseModels/IncidentTemplate.js.map +1 -1
- package/build/dist/Models/DatabaseModels/StatusPage.js +56 -0
- package/build/dist/Models/DatabaseModels/StatusPage.js.map +1 -1
- package/build/dist/Models/DatabaseModels/StatusPageSubscriber.js +131 -0
- package/build/dist/Models/DatabaseModels/StatusPageSubscriber.js.map +1 -1
- package/build/dist/Server/API/IncidentAPI.js +100 -1
- package/build/dist/Server/API/IncidentAPI.js.map +1 -1
- package/build/dist/Server/API/StatusPageAPI.js +417 -176
- package/build/dist/Server/API/StatusPageAPI.js.map +1 -1
- package/build/dist/Server/API/StatusPageSubscriberAPI.js +52 -13
- package/build/dist/Server/API/StatusPageSubscriberAPI.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1795300000000-SkipHiddenIncidentCreatedNotifications.js +41 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1795300000000-SkipHiddenIncidentCreatedNotifications.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1795400000000-AddIncidentStatusPageScope.js +57 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1795400000000-AddIncidentStatusPageScope.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1795500000000-AddIncidentTemplateStatusPageScopeFlag.js +23 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1795500000000-AddIncidentTemplateStatusPageScopeFlag.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1795600000000-AddStatusPageSubscriberUnsubscribeToken.js +40 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1795600000000-AddStatusPageSubscriberUnsubscribeToken.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1795700000000-AddStatusPageSubscriberIsAddedByTeam.js +26 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1795700000000-AddStatusPageSubscriberIsAddedByTeam.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1795800000000-AddIncidentCustomFieldCreateAndNotificationSettings.js +89 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1795800000000-AddIncidentCustomFieldCreateAndNotificationSettings.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1795900000000-AddSubscriberNotificationClaimedAt.js +29 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1795900000000-AddSubscriberNotificationClaimedAt.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +14 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Infrastructure/Semaphore.js +3 -0
- package/build/dist/Server/Infrastructure/Semaphore.js.map +1 -1
- package/build/dist/Server/Middleware/IdentityRateLimit.js +89 -3
- package/build/dist/Server/Middleware/IdentityRateLimit.js.map +1 -1
- package/build/dist/Server/Middleware/SubscriberNotificationPreviewRateLimit.js +149 -0
- package/build/dist/Server/Middleware/SubscriberNotificationPreviewRateLimit.js.map +1 -0
- package/build/dist/Server/Middleware/SubscriberNotificationTestSendRateLimit.js +190 -0
- package/build/dist/Server/Middleware/SubscriberNotificationTestSendRateLimit.js.map +1 -0
- package/build/dist/Server/Services/DatabaseService.js +56 -7
- package/build/dist/Server/Services/DatabaseService.js.map +1 -1
- package/build/dist/Server/Services/IncidentCustomFieldService.js +204 -8
- package/build/dist/Server/Services/IncidentCustomFieldService.js.map +1 -1
- package/build/dist/Server/Services/IncidentEpisodePublicNoteService.js +24 -0
- package/build/dist/Server/Services/IncidentEpisodePublicNoteService.js.map +1 -1
- package/build/dist/Server/Services/IncidentEpisodeService.js +14 -0
- package/build/dist/Server/Services/IncidentEpisodeService.js.map +1 -1
- package/build/dist/Server/Services/IncidentEpisodeStateTimelineService.js +26 -0
- package/build/dist/Server/Services/IncidentEpisodeStateTimelineService.js.map +1 -1
- package/build/dist/Server/Services/IncidentPublicNoteService.js +26 -1
- package/build/dist/Server/Services/IncidentPublicNoteService.js.map +1 -1
- package/build/dist/Server/Services/IncidentService.js +1052 -0
- package/build/dist/Server/Services/IncidentService.js.map +1 -1
- package/build/dist/Server/Services/IncidentStateTimelineService.js +12 -0
- package/build/dist/Server/Services/IncidentStateTimelineService.js.map +1 -1
- package/build/dist/Server/Services/IncidentTemplateService.js +83 -0
- package/build/dist/Server/Services/IncidentTemplateService.js.map +1 -1
- package/build/dist/Server/Services/ScheduledMaintenancePublicNoteService.js +26 -1
- package/build/dist/Server/Services/ScheduledMaintenancePublicNoteService.js.map +1 -1
- package/build/dist/Server/Services/ScheduledMaintenanceService.js +47 -17
- package/build/dist/Server/Services/ScheduledMaintenanceService.js.map +1 -1
- package/build/dist/Server/Services/SmsService.js +2 -22
- package/build/dist/Server/Services/SmsService.js.map +1 -1
- package/build/dist/Server/Services/StatusPageService.js +47 -9
- package/build/dist/Server/Services/StatusPageService.js.map +1 -1
- package/build/dist/Server/Services/StatusPageSubscriberNotificationTemplateService.js +237 -32
- package/build/dist/Server/Services/StatusPageSubscriberNotificationTemplateService.js.map +1 -1
- package/build/dist/Server/Services/StatusPageSubscriberNotificationTemplateStatusPageService.js +109 -0
- package/build/dist/Server/Services/StatusPageSubscriberNotificationTemplateStatusPageService.js.map +1 -1
- package/build/dist/Server/Services/StatusPageSubscriberService.js +925 -99
- package/build/dist/Server/Services/StatusPageSubscriberService.js.map +1 -1
- package/build/dist/Server/Types/Markdown.js +110 -6
- package/build/dist/Server/Types/Markdown.js.map +1 -1
- package/build/dist/Server/Types/Workflow/Components/Email.js +55 -6
- package/build/dist/Server/Types/Workflow/Components/Email.js.map +1 -1
- package/build/dist/Server/Utils/CustomField/CustomFieldRename.js +211 -0
- package/build/dist/Server/Utils/CustomField/CustomFieldRename.js.map +1 -0
- package/build/dist/Server/Utils/DataSource/EgressGuard.js +41 -12
- package/build/dist/Server/Utils/DataSource/EgressGuard.js.map +1 -1
- package/build/dist/Server/Utils/Mail/PinnedSmtpSocket.js +101 -0
- package/build/dist/Server/Utils/Mail/PinnedSmtpSocket.js.map +1 -0
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaObservationBuilder.js +9 -0
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaObservationBuilder.js.map +1 -1
- package/build/dist/Server/Utils/SSRFProtection.js +48 -6
- package/build/dist/Server/Utils/SSRFProtection.js.map +1 -1
- package/build/dist/Server/Utils/StatusPage/IncidentStatusPageScope.js +631 -0
- package/build/dist/Server/Utils/StatusPage/IncidentStatusPageScope.js.map +1 -0
- package/build/dist/Server/Utils/StatusPage/IncidentSubscriberAudienceBuilder.js +403 -0
- package/build/dist/Server/Utils/StatusPage/IncidentSubscriberAudienceBuilder.js.map +1 -0
- package/build/dist/Server/Utils/StatusPage/IncidentTemplateVariableBuilder.js +451 -0
- package/build/dist/Server/Utils/StatusPage/IncidentTemplateVariableBuilder.js.map +1 -0
- package/build/dist/Server/Utils/StatusPage/StatusPageExclusion.js +13 -0
- package/build/dist/Server/Utils/StatusPage/StatusPageExclusion.js.map +1 -0
- package/build/dist/Server/Utils/StatusPage/StatusPageReadAccess.js +91 -0
- package/build/dist/Server/Utils/StatusPage/StatusPageReadAccess.js.map +1 -0
- package/build/dist/Server/Utils/StatusPage/StatusPageSubscriberUnsubscribeNotice.js +101 -0
- package/build/dist/Server/Utils/StatusPage/StatusPageSubscriberUnsubscribeNotice.js.map +1 -0
- package/build/dist/Server/Utils/StatusPage/StatusPageSubscriberUnsubscribeToken.js +47 -0
- package/build/dist/Server/Utils/StatusPage/StatusPageSubscriberUnsubscribeToken.js.map +1 -0
- package/build/dist/Server/Utils/StatusPage/SubscriberIncidentEmailBuilder.js +273 -0
- package/build/dist/Server/Utils/StatusPage/SubscriberIncidentEmailBuilder.js.map +1 -0
- package/build/dist/Server/Utils/StatusPage/SubscriberNotificationClaim.js +73 -0
- package/build/dist/Server/Utils/StatusPage/SubscriberNotificationClaim.js.map +1 -0
- package/build/dist/Server/Utils/StatusPage/SubscriberNotificationDeliveryRecord.js +722 -0
- package/build/dist/Server/Utils/StatusPage/SubscriberNotificationDeliveryRecord.js.map +1 -0
- package/build/dist/Server/Utils/StatusPage/SubscriberNotificationFanOut.js +102 -0
- package/build/dist/Server/Utils/StatusPage/SubscriberNotificationFanOut.js.map +1 -0
- package/build/dist/Server/Utils/StatusPage/SubscriberNotificationPreviewBuilder.js +527 -0
- package/build/dist/Server/Utils/StatusPage/SubscriberNotificationPreviewBuilder.js.map +1 -0
- package/build/dist/Server/Utils/StatusPage/SubscriberNotificationResendAccess.js +278 -0
- package/build/dist/Server/Utils/StatusPage/SubscriberNotificationResendAccess.js.map +1 -0
- package/build/dist/Server/Utils/StatusPage/SubscriberNotificationRunLimit.js +137 -0
- package/build/dist/Server/Utils/StatusPage/SubscriberNotificationRunLimit.js.map +1 -0
- package/build/dist/Server/Utils/StatusPage/SubscriberNotificationTiming.js +103 -0
- package/build/dist/Server/Utils/StatusPage/SubscriberNotificationTiming.js.map +1 -0
- package/build/dist/Server/Utils/StatusPage/SubscriberTemplateIncidentRecordAccess.js +114 -0
- package/build/dist/Server/Utils/StatusPage/SubscriberTemplateIncidentRecordAccess.js.map +1 -0
- package/build/dist/Server/Utils/StatusPageResource.js +39 -7
- package/build/dist/Server/Utils/StatusPageResource.js.map +1 -1
- package/build/dist/Server/Utils/VM/VMAPI.js.map +1 -1
- package/build/dist/Server/Utils/VM/VMRunner.js +1 -0
- package/build/dist/Server/Utils/VM/VMRunner.js.map +1 -1
- package/build/dist/Server/Utils/Workflow/OAuth2TokenClient.js +3 -0
- package/build/dist/Server/Utils/Workflow/OAuth2TokenClient.js.map +1 -1
- package/build/dist/Types/CustomField/CustomFieldOrder.js +36 -0
- package/build/dist/Types/CustomField/CustomFieldOrder.js.map +1 -0
- package/build/dist/Types/CustomField/CustomFieldSavedViews.js +135 -0
- package/build/dist/Types/CustomField/CustomFieldSavedViews.js.map +1 -0
- package/build/dist/Types/CustomField/CustomFieldTemplateMerge.js +27 -0
- package/build/dist/Types/CustomField/CustomFieldTemplateMerge.js.map +1 -0
- package/build/dist/Types/CustomField/CustomFieldType.js +12 -0
- package/build/dist/Types/CustomField/CustomFieldType.js.map +1 -1
- package/build/dist/Types/CustomField/CustomFieldValueFormat.js +126 -0
- package/build/dist/Types/CustomField/CustomFieldValueFormat.js.map +1 -0
- package/build/dist/Types/CustomField/CustomFieldValueValidator.js +280 -0
- package/build/dist/Types/CustomField/CustomFieldValueValidator.js.map +1 -0
- package/build/dist/Types/CustomField/CustomFieldVariableKey.js +150 -0
- package/build/dist/Types/CustomField/CustomFieldVariableKey.js.map +1 -0
- package/build/dist/Types/SafeHtml.js +84 -0
- package/build/dist/Types/SafeHtml.js.map +1 -0
- package/build/dist/Types/StatusPage/IncidentCreatedRenotify.js +117 -0
- package/build/dist/Types/StatusPage/IncidentCreatedRenotify.js.map +1 -0
- package/build/dist/Types/StatusPage/IncidentCreatedResend.js +86 -0
- package/build/dist/Types/StatusPage/IncidentCreatedResend.js.map +1 -0
- package/build/dist/Types/StatusPage/IncidentScopeAddedPagesNotification.js +246 -0
- package/build/dist/Types/StatusPage/IncidentScopeAddedPagesNotification.js.map +1 -0
- package/build/dist/Types/StatusPage/IncidentSubscriberAudience.js +183 -0
- package/build/dist/Types/StatusPage/IncidentSubscriberAudience.js.map +1 -0
- package/build/dist/Types/StatusPage/StatusPageSubscriberUnsubscribe.js +277 -0
- package/build/dist/Types/StatusPage/StatusPageSubscriberUnsubscribe.js.map +1 -0
- package/build/dist/Types/StatusPage/SubscriberNotificationInterruption.js +27 -0
- package/build/dist/Types/StatusPage/SubscriberNotificationInterruption.js.map +1 -0
- package/build/dist/Types/StatusPage/SubscriberNotificationPreview.js +190 -0
- package/build/dist/Types/StatusPage/SubscriberNotificationPreview.js.map +1 -0
- package/build/dist/Types/StatusPage/SubscriberNotificationResend.js +102 -0
- package/build/dist/Types/StatusPage/SubscriberNotificationResend.js.map +1 -0
- package/build/dist/Types/StatusPage/SubscriberNotificationTemplateCompiler.js +97 -0
- package/build/dist/Types/StatusPage/SubscriberNotificationTemplateCompiler.js.map +1 -0
- package/build/dist/Types/StatusPage/SubscriberNotificationTemplatePreview.js +175 -0
- package/build/dist/Types/StatusPage/SubscriberNotificationTemplatePreview.js.map +1 -0
- package/build/dist/Types/StatusPage/SubscriberNotificationTemplateVariables.js +144 -4
- package/build/dist/Types/StatusPage/SubscriberNotificationTemplateVariables.js.map +1 -1
- package/build/dist/Types/StatusPage/SubscriberUpdateNotification.js +29 -9
- package/build/dist/Types/StatusPage/SubscriberUpdateNotification.js.map +1 -1
- package/build/dist/UI/Components/CustomFields/CustomFieldFormFields.js +169 -0
- package/build/dist/UI/Components/CustomFields/CustomFieldFormFields.js.map +1 -0
- package/build/dist/UI/Components/CustomFields/CustomFieldModelFormFields.js +212 -0
- package/build/dist/UI/Components/CustomFields/CustomFieldModelFormFields.js.map +1 -0
- package/build/dist/UI/Components/CustomFields/CustomFieldsDetail.js +64 -49
- package/build/dist/UI/Components/CustomFields/CustomFieldsDetail.js.map +1 -1
- package/build/dist/UI/Components/Forms/ModelForm.js +39 -5
- package/build/dist/UI/Components/Forms/ModelForm.js.map +1 -1
- package/build/dist/UI/Components/Forms/Validation.js +1 -1
- package/build/dist/UI/Components/Forms/Validation.js.map +1 -1
- package/build/dist/UI/Components/ModelFormModal/ModelFormModal.js.map +1 -1
- package/build/dist/UI/Components/ModelTable/AnalyticsModelTable.js.map +1 -1
- package/build/dist/UI/Components/ModelTable/BaseModelTable.js +2 -2
- package/build/dist/UI/Components/ModelTable/BaseModelTable.js.map +1 -1
- package/build/dist/UI/Components/ModelTable/CustomFieldColumns.js +13 -1
- package/build/dist/UI/Components/ModelTable/CustomFieldColumns.js.map +1 -1
- package/build/dist/UI/Components/ModelTable/ModelTable.js +1 -1
- package/build/dist/UI/Components/ModelTable/ModelTable.js.map +1 -1
- package/build/dist/UI/Utils/SensitiveUrlToken.js +10 -5
- package/build/dist/UI/Utils/SensitiveUrlToken.js.map +1 -1
- package/build/dist/Utils/API.js +177 -1
- package/build/dist/Utils/API.js.map +1 -1
- package/build/dist/Utils/Incident/IncidentNoteTemplateVariables.js +155 -0
- package/build/dist/Utils/Incident/IncidentNoteTemplateVariables.js.map +1 -0
- package/build/dist/Utils/Markdown/MarkdownEscape.js +48 -0
- package/build/dist/Utils/Markdown/MarkdownEscape.js.map +1 -1
- package/build/dist/Utils/ProbeNetworkFailureUtil.js +460 -0
- package/build/dist/Utils/ProbeNetworkFailureUtil.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { describe, expect, test } from "@jest/globals";
|
|
2
|
+
import { JSONObject } from "../../../Types/JSON";
|
|
3
|
+
import IncidentSubscriberAudience from "../../../Types/StatusPage/IncidentSubscriberAudience";
|
|
4
|
+
import SubscriberNotificationPreview, {
|
|
5
|
+
SubscriberEmailTemplateChoiceReason,
|
|
6
|
+
SubscriberNotificationPreviewEvent,
|
|
7
|
+
SubscriberNotificationPreviewNothingSentReason,
|
|
8
|
+
SubscriberNotificationPreviewResult,
|
|
9
|
+
} from "../../../Types/StatusPage/SubscriberNotificationPreview";
|
|
10
|
+
|
|
11
|
+
/*
|
|
12
|
+
* The preview's shape, shared by the server that answers and the dashboard
|
|
13
|
+
* that shows it: what travels (and nothing else - no address), how the
|
|
14
|
+
* dashboard reads an answer defensively, and the sample unsubscribe link.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const SITE_1: string = "b0000000-0000-4000-8000-000000000001";
|
|
18
|
+
|
|
19
|
+
function result(): SubscriberNotificationPreviewResult {
|
|
20
|
+
return {
|
|
21
|
+
event: SubscriberNotificationPreviewEvent.IncidentPublicNoteCreated,
|
|
22
|
+
nothingSentReason: null,
|
|
23
|
+
statusPages: [
|
|
24
|
+
{
|
|
25
|
+
statusPageId: SITE_1,
|
|
26
|
+
name: "Site 01",
|
|
27
|
+
subscriberCounts: {
|
|
28
|
+
...IncidentSubscriberAudience.getEmptyCounts(),
|
|
29
|
+
email: 41,
|
|
30
|
+
sms: 3,
|
|
31
|
+
},
|
|
32
|
+
subject: "[Update Incident] Checkout",
|
|
33
|
+
html: "<p>Checkout</p>",
|
|
34
|
+
templateChoice: {
|
|
35
|
+
usesCustomTemplate: false,
|
|
36
|
+
reason:
|
|
37
|
+
SubscriberEmailTemplateChoiceReason.CustomTemplateNeedsCustomSmtp,
|
|
38
|
+
customTemplateName: "Branded",
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
audience: {
|
|
43
|
+
hasMonitors: true,
|
|
44
|
+
isScoped: true,
|
|
45
|
+
isHiddenFromStatusPages: false,
|
|
46
|
+
statusPages: [
|
|
47
|
+
{
|
|
48
|
+
statusPageId: SITE_1,
|
|
49
|
+
name: "Site 01",
|
|
50
|
+
subscriberCounts: {
|
|
51
|
+
...IncidentSubscriberAudience.getEmptyCounts(),
|
|
52
|
+
email: 41,
|
|
53
|
+
sms: 3,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
hiddenStatusPageCount: 2,
|
|
58
|
+
excludedStatusPages: [],
|
|
59
|
+
selectedStatusPagesNotListingMonitors: [],
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
describe("SubscriberNotificationPreview", () => {
|
|
65
|
+
test("an answer survives the trip to the dashboard", () => {
|
|
66
|
+
const json: JSONObject = JSON.parse(
|
|
67
|
+
JSON.stringify(SubscriberNotificationPreview.toJSON(result())),
|
|
68
|
+
) as JSONObject;
|
|
69
|
+
|
|
70
|
+
expect(SubscriberNotificationPreview.fromJSON(json)).toEqual(result());
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test("only these fields travel for each page: no address, no mail settings", () => {
|
|
74
|
+
const json: JSONObject = SubscriberNotificationPreview.toJSON(result());
|
|
75
|
+
const page: JSONObject = (json["statusPages"] as Array<JSONObject>)[0]!;
|
|
76
|
+
|
|
77
|
+
expect(Object.keys(json).sort()).toEqual(
|
|
78
|
+
["audience", "event", "nothingSentReason", "statusPages"].sort(),
|
|
79
|
+
);
|
|
80
|
+
expect(Object.keys(page).sort()).toEqual(
|
|
81
|
+
[
|
|
82
|
+
"html",
|
|
83
|
+
"name",
|
|
84
|
+
"statusPageId",
|
|
85
|
+
"subject",
|
|
86
|
+
"subscriberCounts",
|
|
87
|
+
"templateChoice",
|
|
88
|
+
].sort(),
|
|
89
|
+
);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test("a malformed answer reads as nothing rather than breaking the dialog", () => {
|
|
93
|
+
const parsed: SubscriberNotificationPreviewResult =
|
|
94
|
+
SubscriberNotificationPreview.fromJSON({
|
|
95
|
+
event: "Unknown",
|
|
96
|
+
nothingSentReason: "Nope",
|
|
97
|
+
statusPages: [
|
|
98
|
+
null,
|
|
99
|
+
"x",
|
|
100
|
+
{
|
|
101
|
+
statusPageId: SITE_1,
|
|
102
|
+
subscriberCounts: { email: "12", sms: -4, slack: "lots" },
|
|
103
|
+
templateChoice: { reason: "Made up", customTemplateName: 7 },
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
} as unknown as JSONObject);
|
|
107
|
+
|
|
108
|
+
expect(parsed.event).toBe(
|
|
109
|
+
SubscriberNotificationPreviewEvent.IncidentCreated,
|
|
110
|
+
);
|
|
111
|
+
expect(parsed.nothingSentReason).toBeNull();
|
|
112
|
+
expect(parsed.statusPages).toEqual([
|
|
113
|
+
{
|
|
114
|
+
statusPageId: SITE_1,
|
|
115
|
+
name: "",
|
|
116
|
+
subscriberCounts: {
|
|
117
|
+
...IncidentSubscriberAudience.getEmptyCounts(),
|
|
118
|
+
email: 12,
|
|
119
|
+
},
|
|
120
|
+
subject: "",
|
|
121
|
+
html: "",
|
|
122
|
+
templateChoice: {
|
|
123
|
+
usesCustomTemplate: false,
|
|
124
|
+
reason: SubscriberEmailTemplateChoiceReason.NoCustomTemplate,
|
|
125
|
+
customTemplateName: undefined,
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
]);
|
|
129
|
+
expect(parsed.audience.statusPages).toEqual([]);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
test("a reason nothing will be sent is read back", () => {
|
|
133
|
+
expect(
|
|
134
|
+
SubscriberNotificationPreview.fromJSON({
|
|
135
|
+
event: "IncidentCreated",
|
|
136
|
+
nothingSentReason: "NoMonitors",
|
|
137
|
+
}).nothingSentReason,
|
|
138
|
+
).toBe(SubscriberNotificationPreviewNothingSentReason.NoMonitors);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
test("requests travel with their dates as ISO strings, and a test names its page", () => {
|
|
142
|
+
expect(
|
|
143
|
+
SubscriberNotificationPreview.requestToJSON({
|
|
144
|
+
event: SubscriberNotificationPreviewEvent.IncidentPublicNoteCreated,
|
|
145
|
+
incidentId: "a0000000-0000-4000-8000-00000000000a",
|
|
146
|
+
note: "Update",
|
|
147
|
+
postedAt: new Date("2026-09-27T10:30:00.000Z"),
|
|
148
|
+
statusPageId: SITE_1,
|
|
149
|
+
}),
|
|
150
|
+
).toEqual({
|
|
151
|
+
event: "IncidentPublicNoteCreated",
|
|
152
|
+
incidentId: "a0000000-0000-4000-8000-00000000000a",
|
|
153
|
+
note: "Update",
|
|
154
|
+
postedAt: "2026-09-27T10:30:00.000Z",
|
|
155
|
+
statusPageId: SITE_1,
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
expect(
|
|
159
|
+
SubscriberNotificationPreview.requestToJSON({
|
|
160
|
+
event: SubscriberNotificationPreviewEvent.IncidentCreated,
|
|
161
|
+
incident: {
|
|
162
|
+
title: "Down",
|
|
163
|
+
description: "",
|
|
164
|
+
incidentSeverityId: null,
|
|
165
|
+
monitorIds: ["c0000000-0000-4000-8000-000000000001"],
|
|
166
|
+
statusPageIds: [],
|
|
167
|
+
labelIds: [],
|
|
168
|
+
customFields: { Impact: "High" },
|
|
169
|
+
isPrivate: false,
|
|
170
|
+
shouldStatusPageSubscribersBeNotifiedOnIncidentCreated: true,
|
|
171
|
+
},
|
|
172
|
+
}),
|
|
173
|
+
).toEqual({
|
|
174
|
+
event: "IncidentCreated",
|
|
175
|
+
incident: {
|
|
176
|
+
title: "Down",
|
|
177
|
+
description: "",
|
|
178
|
+
incidentSeverityId: null,
|
|
179
|
+
monitorIds: ["c0000000-0000-4000-8000-000000000001"],
|
|
180
|
+
statusPageIds: [],
|
|
181
|
+
labelIds: [],
|
|
182
|
+
customFields: { Impact: "High" },
|
|
183
|
+
isPrivate: false,
|
|
184
|
+
shouldStatusPageSubscribersBeNotifiedOnIncidentCreated: true,
|
|
185
|
+
},
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
test("the preview's unsubscribe link names no subscription", () => {
|
|
190
|
+
expect(
|
|
191
|
+
SubscriberNotificationPreview.getPreviewUnsubscribeUrl(
|
|
192
|
+
"https://status.acme.com",
|
|
193
|
+
),
|
|
194
|
+
).toBe("https://status.acme.com/unsubscribe/preview");
|
|
195
|
+
});
|
|
196
|
+
});
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import StatusPageSubscriberNotificationStatus from "../../../Types/StatusPage/StatusPageSubscriberNotificationStatus";
|
|
2
|
+
import SubscriberNotificationResend, {
|
|
3
|
+
SubscriberNotificationResendAction,
|
|
4
|
+
} from "../../../Types/StatusPage/SubscriberNotificationResend";
|
|
5
|
+
import { describe, expect, test } from "@jest/globals";
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
* Which settled subscriber notifications can be sent again, and when the
|
|
9
|
+
* server refuses a public note's. The dashboard's buttons and the server's
|
|
10
|
+
* checks both read these, so a wrong answer either hides Resend where it
|
|
11
|
+
* works or offers it where the note would sit in Pending forever.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const ALL_STATUSES: Array<StatusPageSubscriberNotificationStatus | undefined> =
|
|
15
|
+
[
|
|
16
|
+
StatusPageSubscriberNotificationStatus.Success,
|
|
17
|
+
StatusPageSubscriberNotificationStatus.Failed,
|
|
18
|
+
StatusPageSubscriberNotificationStatus.Skipped,
|
|
19
|
+
StatusPageSubscriberNotificationStatus.Pending,
|
|
20
|
+
StatusPageSubscriberNotificationStatus.InProgress,
|
|
21
|
+
undefined,
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
describe("SubscriberNotificationResend.getAction", () => {
|
|
25
|
+
test("a failed notification offers Retry, whether or not Resend is offered", () => {
|
|
26
|
+
for (const isResendAfterSuccessOffered of [true, false]) {
|
|
27
|
+
expect(
|
|
28
|
+
SubscriberNotificationResend.getAction({
|
|
29
|
+
status: StatusPageSubscriberNotificationStatus.Failed,
|
|
30
|
+
isResendAfterSuccessOffered,
|
|
31
|
+
}),
|
|
32
|
+
).toBe(SubscriberNotificationResendAction.Retry);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test("a notification that went out offers Resend where the caller supports it", () => {
|
|
37
|
+
expect(
|
|
38
|
+
SubscriberNotificationResend.getAction({
|
|
39
|
+
status: StatusPageSubscriberNotificationStatus.Success,
|
|
40
|
+
isResendAfterSuccessOffered: true,
|
|
41
|
+
}),
|
|
42
|
+
).toBe(SubscriberNotificationResendAction.Resend);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test("and nothing where it does not: the old Failed-only behaviour", () => {
|
|
46
|
+
expect(
|
|
47
|
+
SubscriberNotificationResend.getAction({
|
|
48
|
+
status: StatusPageSubscriberNotificationStatus.Success,
|
|
49
|
+
isResendAfterSuccessOffered: false,
|
|
50
|
+
}),
|
|
51
|
+
).toBeNull();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test.each([
|
|
55
|
+
StatusPageSubscriberNotificationStatus.Skipped,
|
|
56
|
+
StatusPageSubscriberNotificationStatus.Pending,
|
|
57
|
+
StatusPageSubscriberNotificationStatus.InProgress,
|
|
58
|
+
undefined,
|
|
59
|
+
null,
|
|
60
|
+
])(
|
|
61
|
+
"%s offers nothing: never sent, or on its way",
|
|
62
|
+
(status: StatusPageSubscriberNotificationStatus | undefined | null) => {
|
|
63
|
+
for (const isResendAfterSuccessOffered of [true, false]) {
|
|
64
|
+
expect(
|
|
65
|
+
SubscriberNotificationResend.getAction({
|
|
66
|
+
status,
|
|
67
|
+
isResendAfterSuccessOffered,
|
|
68
|
+
}),
|
|
69
|
+
).toBeNull();
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
test("only Success and Failed ever offer anything", () => {
|
|
75
|
+
const offering: Array<StatusPageSubscriberNotificationStatus | undefined> =
|
|
76
|
+
ALL_STATUSES.filter(
|
|
77
|
+
(status: StatusPageSubscriberNotificationStatus | undefined) => {
|
|
78
|
+
return (
|
|
79
|
+
SubscriberNotificationResend.getAction({
|
|
80
|
+
status,
|
|
81
|
+
isResendAfterSuccessOffered: true,
|
|
82
|
+
}) !== null
|
|
83
|
+
);
|
|
84
|
+
},
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
expect(offering).toEqual([
|
|
88
|
+
StatusPageSubscriberNotificationStatus.Success,
|
|
89
|
+
StatusPageSubscriberNotificationStatus.Failed,
|
|
90
|
+
]);
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
describe("SubscriberNotificationResend.getPublicNoteResendRefusal", () => {
|
|
95
|
+
test.each([
|
|
96
|
+
StatusPageSubscriberNotificationStatus.Success,
|
|
97
|
+
StatusPageSubscriberNotificationStatus.Failed,
|
|
98
|
+
])(
|
|
99
|
+
"a note that notifies subscribers and is %s may be sent again",
|
|
100
|
+
(status: StatusPageSubscriberNotificationStatus) => {
|
|
101
|
+
expect(
|
|
102
|
+
SubscriberNotificationResend.getPublicNoteResendRefusal({
|
|
103
|
+
status,
|
|
104
|
+
shouldStatusPageSubscribersBeNotifiedOnNoteCreated: true,
|
|
105
|
+
}),
|
|
106
|
+
).toBeNull();
|
|
107
|
+
},
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
test("a note posted without notifying subscribers never may: the job would never pick it up", () => {
|
|
111
|
+
for (const status of ALL_STATUSES) {
|
|
112
|
+
expect(
|
|
113
|
+
SubscriberNotificationResend.getPublicNoteResendRefusal({
|
|
114
|
+
status,
|
|
115
|
+
shouldStatusPageSubscribersBeNotifiedOnNoteCreated: false,
|
|
116
|
+
}),
|
|
117
|
+
).toBe(SubscriberNotificationResend.notePostedWithoutNotifyingMessage);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
test("a notification being sent right now may not: its send would overwrite the request", () => {
|
|
122
|
+
expect(
|
|
123
|
+
SubscriberNotificationResend.getPublicNoteResendRefusal({
|
|
124
|
+
status: StatusPageSubscriberNotificationStatus.InProgress,
|
|
125
|
+
shouldStatusPageSubscribersBeNotifiedOnNoteCreated: true,
|
|
126
|
+
}),
|
|
127
|
+
).toBe(SubscriberNotificationResend.beingSentMessage);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
test("a queued one may: nothing changes", () => {
|
|
131
|
+
expect(
|
|
132
|
+
SubscriberNotificationResend.getPublicNoteResendRefusal({
|
|
133
|
+
status: StatusPageSubscriberNotificationStatus.Pending,
|
|
134
|
+
shouldStatusPageSubscribersBeNotifiedOnNoteCreated: true,
|
|
135
|
+
}),
|
|
136
|
+
).toBeNull();
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
test("a skip of a note that does notify (a hidden incident, no monitors) is looked at afresh", () => {
|
|
140
|
+
expect(
|
|
141
|
+
SubscriberNotificationResend.getPublicNoteResendRefusal({
|
|
142
|
+
status: StatusPageSubscriberNotificationStatus.Skipped,
|
|
143
|
+
shouldStatusPageSubscribersBeNotifiedOnNoteCreated: true,
|
|
144
|
+
}),
|
|
145
|
+
).toBeNull();
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
test("an unread flag is not taken for a no", () => {
|
|
149
|
+
expect(
|
|
150
|
+
SubscriberNotificationResend.getPublicNoteResendRefusal({
|
|
151
|
+
status: StatusPageSubscriberNotificationStatus.Success,
|
|
152
|
+
shouldStatusPageSubscribersBeNotifiedOnNoteCreated: undefined,
|
|
153
|
+
}),
|
|
154
|
+
).toBeNull();
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
describe("SubscriberNotificationResend.isPublicNoteResendRequested", () => {
|
|
159
|
+
test("an update writing Pending into the posted status asks for it", () => {
|
|
160
|
+
expect(
|
|
161
|
+
SubscriberNotificationResend.isPublicNoteResendRequested({
|
|
162
|
+
subscriberNotificationStatusOnNoteCreated:
|
|
163
|
+
StatusPageSubscriberNotificationStatus.Pending,
|
|
164
|
+
}),
|
|
165
|
+
).toBe(true);
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
test.each([
|
|
169
|
+
StatusPageSubscriberNotificationStatus.Success,
|
|
170
|
+
StatusPageSubscriberNotificationStatus.Failed,
|
|
171
|
+
StatusPageSubscriberNotificationStatus.Skipped,
|
|
172
|
+
StatusPageSubscriberNotificationStatus.InProgress,
|
|
173
|
+
])(
|
|
174
|
+
"writing %s does not",
|
|
175
|
+
(status: StatusPageSubscriberNotificationStatus) => {
|
|
176
|
+
expect(
|
|
177
|
+
SubscriberNotificationResend.isPublicNoteResendRequested({
|
|
178
|
+
subscriberNotificationStatusOnNoteCreated: status,
|
|
179
|
+
}),
|
|
180
|
+
).toBe(false);
|
|
181
|
+
},
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
test("an edit that leaves the status alone does not", () => {
|
|
185
|
+
expect(SubscriberNotificationResend.isPublicNoteResendRequested({})).toBe(
|
|
186
|
+
false,
|
|
187
|
+
);
|
|
188
|
+
expect(
|
|
189
|
+
SubscriberNotificationResend.isPublicNoteResendRequested(undefined),
|
|
190
|
+
).toBe(false);
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
test("retrying the update notification is not a resend of the post", () => {
|
|
194
|
+
expect(
|
|
195
|
+
SubscriberNotificationResend.isPublicNoteResendRequested({
|
|
196
|
+
subscriberNotificationStatusOnNoteUpdated:
|
|
197
|
+
StatusPageSubscriberNotificationStatus.Pending,
|
|
198
|
+
} as { subscriberNotificationStatusOnNoteCreated?: unknown }),
|
|
199
|
+
).toBe(false);
|
|
200
|
+
});
|
|
201
|
+
});
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import SafeHtml from "../../../Types/SafeHtml";
|
|
2
|
+
import SubscriberNotificationTemplateCompiler from "../../../Types/StatusPage/SubscriberNotificationTemplateCompiler";
|
|
3
|
+
import { describe, expect, test } from "@jest/globals";
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* A custom subscriber notification template is filled one of two ways,
|
|
7
|
+
* depending on what its channel renders:
|
|
8
|
+
*
|
|
9
|
+
* - the body of an EMAIL template is HTML, so a plain value (a title, a
|
|
10
|
+
* name, a URL) is escaped into it and only a SafeHtml value goes in as
|
|
11
|
+
* markup;
|
|
12
|
+
* - an email subject, SMS, Slack and Teams show text as written, so they
|
|
13
|
+
* get every value unchanged.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const TITLE_WITH_LINK: string =
|
|
17
|
+
'<a href="https://evil.example/reset">Reset your password</a>';
|
|
18
|
+
const TITLE_WITH_SCRIPT: string = "<script>alert('x')</script>";
|
|
19
|
+
const TITLE_WITH_QUOTES: string = `Payments "EU" & 'UK' down`;
|
|
20
|
+
|
|
21
|
+
describe("SubscriberNotificationTemplateCompiler.compileEmailBodyTemplate", () => {
|
|
22
|
+
const compile: (
|
|
23
|
+
template: string,
|
|
24
|
+
variables: Record<string, string | SafeHtml>,
|
|
25
|
+
) => string = (
|
|
26
|
+
template: string,
|
|
27
|
+
variables: Record<string, string | SafeHtml>,
|
|
28
|
+
): string => {
|
|
29
|
+
return SubscriberNotificationTemplateCompiler.compileEmailBodyTemplate(
|
|
30
|
+
template,
|
|
31
|
+
variables,
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
test("escapes a plain value that holds a link", () => {
|
|
36
|
+
const body: string = compile("<h1>{{incidentTitle}}</h1>", {
|
|
37
|
+
incidentTitle: TITLE_WITH_LINK,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
expect(body).toBe(
|
|
41
|
+
"<h1><a href="https://evil.example/reset">Reset your password</a></h1>",
|
|
42
|
+
);
|
|
43
|
+
expect(body).not.toContain("<a ");
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test("escapes a plain value that holds a script", () => {
|
|
47
|
+
const body: string = compile("<p>{{incidentTitle}}</p>", {
|
|
48
|
+
incidentTitle: TITLE_WITH_SCRIPT,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
expect(body).toBe("<p><script>alert('x')</script></p>");
|
|
52
|
+
expect(body).not.toContain("<script");
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test("escapes quotes and ampersands, so a value cannot break out of an attribute", () => {
|
|
56
|
+
const body: string = compile(
|
|
57
|
+
`<a href="{{detailsUrl}}" title='{{incidentTitle}}'>Details</a>`,
|
|
58
|
+
{
|
|
59
|
+
detailsUrl: 'https://status.example.com/" onmouseover="alert(1)',
|
|
60
|
+
incidentTitle: TITLE_WITH_QUOTES,
|
|
61
|
+
},
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
expect(body).toBe(
|
|
65
|
+
`<a href="https://status.example.com/" onmouseover="alert(1)" title='Payments "EU" & 'UK' down'>Details</a>`,
|
|
66
|
+
);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test("keeps the ampersands of a URL working: the attribute decodes them back", () => {
|
|
70
|
+
const body: string = compile(`<a href="{{detailsUrl}}">x</a>`, {
|
|
71
|
+
detailsUrl: "https://status.example.com/incidents/1?view=details&lang=en",
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
expect(body).toBe(
|
|
75
|
+
`<a href="https://status.example.com/incidents/1?view=details&lang=en">x</a>`,
|
|
76
|
+
);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
test("inserts a SafeHtml value as it is", () => {
|
|
80
|
+
const body: string = compile(
|
|
81
|
+
"<div>{{incidentDescription}}</div><div>{{resourcesAffected}}</div>",
|
|
82
|
+
{
|
|
83
|
+
incidentDescription: SafeHtml.fromTrustedHtml(
|
|
84
|
+
'<p>Card payments <strong>fail</strong> in <a href="https://acme.com/eu">Europe</a>.</p>',
|
|
85
|
+
),
|
|
86
|
+
resourcesAffected: SafeHtml.fromTrustedHtml(
|
|
87
|
+
"Europe: Checkout API<br/>Americas: Payments & Billing",
|
|
88
|
+
),
|
|
89
|
+
},
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
expect(body).toBe(
|
|
93
|
+
'<div><p>Card payments <strong>fail</strong> in <a href="https://acme.com/eu">Europe</a>.</p></div>' +
|
|
94
|
+
"<div>Europe: Checkout API<br/>Americas: Payments & Billing</div>",
|
|
95
|
+
);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
test("escapes plain values and keeps HTML ones in the same template", () => {
|
|
99
|
+
const body: string = compile(
|
|
100
|
+
"<h1>{{incidentTitle}}</h1>{{incidentDescription}}<p>{{statusPageName}}</p>",
|
|
101
|
+
{
|
|
102
|
+
incidentTitle: TITLE_WITH_SCRIPT,
|
|
103
|
+
incidentDescription: SafeHtml.fromTrustedHtml("<p><em>ok</em></p>"),
|
|
104
|
+
statusPageName: "Acme <Status>",
|
|
105
|
+
},
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
expect(body).toBe(
|
|
109
|
+
"<h1><script>alert('x')</script></h1><p><em>ok</em></p><p>Acme <Status></p>",
|
|
110
|
+
);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
test("the template's own HTML is sent as written: the admin who wrote it is trusted", () => {
|
|
114
|
+
const template: string =
|
|
115
|
+
'<table><tr><td style="color:red">{{incidentTitle}}</td></tr></table><a href="https://acme.com">Acme</a>';
|
|
116
|
+
|
|
117
|
+
expect(compile(template, { incidentTitle: "Down" })).toBe(
|
|
118
|
+
'<table><tr><td style="color:red">Down</td></tr></table><a href="https://acme.com">Acme</a>',
|
|
119
|
+
);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
test("a placeholder with no variable is left as written", () => {
|
|
123
|
+
expect(
|
|
124
|
+
compile("Hello {{unknownVariable}} {{incidentTitle}}", {
|
|
125
|
+
incidentTitle: "Down",
|
|
126
|
+
}),
|
|
127
|
+
).toBe("Hello {{unknownVariable}} Down");
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
test("a missing or empty value renders as nothing", () => {
|
|
131
|
+
expect(
|
|
132
|
+
compile("[{{a}}][{{b}}][{{c}}]", {
|
|
133
|
+
a: "",
|
|
134
|
+
b: undefined as unknown as string,
|
|
135
|
+
c: SafeHtml.fromTrustedHtml(""),
|
|
136
|
+
}),
|
|
137
|
+
).toBe("[][][]");
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
test("placeholders inside a value are not expanded", () => {
|
|
141
|
+
expect(
|
|
142
|
+
compile("{{note}} | {{unsubscribeUrl}}", {
|
|
143
|
+
note: SafeHtml.fromTrustedHtml("<p>See {{unsubscribeUrl}}</p>"),
|
|
144
|
+
unsubscribeUrl: "https://status.example.com/u/1",
|
|
145
|
+
}),
|
|
146
|
+
).toBe("<p>See {{unsubscribeUrl}}</p> | https://status.example.com/u/1");
|
|
147
|
+
|
|
148
|
+
expect(
|
|
149
|
+
compile("{{incidentTitle}} | {{unsubscribeUrl}}", {
|
|
150
|
+
incidentTitle: "Quoting {{unsubscribeUrl}}",
|
|
151
|
+
unsubscribeUrl: "https://status.example.com/u/1",
|
|
152
|
+
}),
|
|
153
|
+
).toBe("Quoting {{unsubscribeUrl}} | https://status.example.com/u/1");
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
test.each([
|
|
157
|
+
["$$", "Refunds of $$5 issued"],
|
|
158
|
+
["$&", "Store $& Co"],
|
|
159
|
+
["$`", "cost $` now"],
|
|
160
|
+
["$'", "cost $' now"],
|
|
161
|
+
])(
|
|
162
|
+
"inserts a value containing %s literally",
|
|
163
|
+
(_label: string, text: string) => {
|
|
164
|
+
expect(compile("Before {{note}} after", { note: text })).toBe(
|
|
165
|
+
`Before ${SafeHtml.escape(text)} after`,
|
|
166
|
+
);
|
|
167
|
+
expect(
|
|
168
|
+
compile("Before {{note}} after", {
|
|
169
|
+
note: SafeHtml.fromTrustedHtml(text),
|
|
170
|
+
}),
|
|
171
|
+
).toBe(`Before ${text} after`);
|
|
172
|
+
},
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
test("does not read inherited properties as variables", () => {
|
|
176
|
+
expect(compile("{{toString}} {{constructor}}", {})).toBe(
|
|
177
|
+
"{{toString}} {{constructor}}",
|
|
178
|
+
);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
test("a plain object that only looks like SafeHtml is escaped, not trusted", () => {
|
|
182
|
+
const lookalike: SafeHtml = {
|
|
183
|
+
toHtml: (): string => {
|
|
184
|
+
return "<b>trusted?</b>";
|
|
185
|
+
},
|
|
186
|
+
toString: (): string => {
|
|
187
|
+
return "<b>trusted?</b>";
|
|
188
|
+
},
|
|
189
|
+
} as unknown as SafeHtml;
|
|
190
|
+
|
|
191
|
+
expect(compile("{{x}}", { x: lookalike })).toBe(
|
|
192
|
+
"<b>trusted?</b>",
|
|
193
|
+
);
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
describe("SubscriberNotificationTemplateCompiler.compileTemplate", () => {
|
|
198
|
+
/*
|
|
199
|
+
* An email subject, SMS, Slack and Teams do not render HTML: escaping would
|
|
200
|
+
* show the reader "&" and "<". They get every value as written.
|
|
201
|
+
*/
|
|
202
|
+
test("inserts text channel values exactly as written, never escaped", () => {
|
|
203
|
+
expect(
|
|
204
|
+
SubscriberNotificationTemplateCompiler.compileTemplate(
|
|
205
|
+
"[Incident] {{incidentTitle}} on {{statusPageName}}",
|
|
206
|
+
{
|
|
207
|
+
incidentTitle: TITLE_WITH_QUOTES,
|
|
208
|
+
statusPageName: "Acme <Status>",
|
|
209
|
+
},
|
|
210
|
+
),
|
|
211
|
+
).toBe(`[Incident] Payments "EU" & 'UK' down on Acme <Status>`);
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
test("leaves an unknown placeholder alone and fills the known ones", () => {
|
|
215
|
+
expect(
|
|
216
|
+
SubscriberNotificationTemplateCompiler.compileTemplate(
|
|
217
|
+
"{{a}} {{ b }} {{c}}",
|
|
218
|
+
{ a: "1", b: "2" },
|
|
219
|
+
),
|
|
220
|
+
).toBe("1 2 {{c}}");
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
describe("SubscriberNotificationTemplateCompiler.getPlaceholderNames", () => {
|
|
225
|
+
test("names exactly the placeholders the compile fills, each once", () => {
|
|
226
|
+
const templates: Array<string | null | undefined> = [
|
|
227
|
+
"<p>{{incidentTitle}} {{ customFields.root_cause }}</p>",
|
|
228
|
+
"{{customFields.root_cause}} {{incidentLabels}}",
|
|
229
|
+
null,
|
|
230
|
+
undefined,
|
|
231
|
+
"",
|
|
232
|
+
// Not placeholders the compile fills: left as written.
|
|
233
|
+
"{{customFields.root-cause}} {{ }} {{customFields.café}} {incidentTitle}",
|
|
234
|
+
];
|
|
235
|
+
|
|
236
|
+
expect(
|
|
237
|
+
Array.from(
|
|
238
|
+
SubscriberNotificationTemplateCompiler.getPlaceholderNames(templates),
|
|
239
|
+
),
|
|
240
|
+
).toEqual(["incidentTitle", "customFields.root_cause", "incidentLabels"]);
|
|
241
|
+
|
|
242
|
+
// Every name it finds is one the compile replaces, and no other.
|
|
243
|
+
const variables: Record<string, string> = {};
|
|
244
|
+
|
|
245
|
+
for (const name of SubscriberNotificationTemplateCompiler.getPlaceholderNames(
|
|
246
|
+
templates,
|
|
247
|
+
)) {
|
|
248
|
+
variables[name] = "X";
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
const compiled: string = templates
|
|
252
|
+
.map((template: string | null | undefined): string => {
|
|
253
|
+
return SubscriberNotificationTemplateCompiler.compileTemplate(
|
|
254
|
+
template || "",
|
|
255
|
+
variables,
|
|
256
|
+
);
|
|
257
|
+
})
|
|
258
|
+
.join("\n");
|
|
259
|
+
|
|
260
|
+
expect(compiled).not.toContain("{{incidentTitle}}");
|
|
261
|
+
expect(compiled).not.toContain("customFields.root_cause");
|
|
262
|
+
expect(compiled).toContain("{{customFields.root-cause}}");
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
test("can be called again and again: no pattern state carries over", () => {
|
|
266
|
+
for (let i: number = 0; i < 3; i++) {
|
|
267
|
+
expect(
|
|
268
|
+
Array.from(
|
|
269
|
+
SubscriberNotificationTemplateCompiler.getPlaceholderNames([
|
|
270
|
+
"{{a}}",
|
|
271
|
+
"{{a}} {{b}}",
|
|
272
|
+
]),
|
|
273
|
+
),
|
|
274
|
+
).toEqual(["a", "b"]);
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
});
|