diff --git a/src/lib/addons/__snapshots__/feature-event-formatter-md.test.ts.snap b/src/lib/addons/__snapshots__/feature-event-formatter-md.test.ts.snap index 77278bad78..e25f10db3a 100644 --- a/src/lib/addons/__snapshots__/feature-event-formatter-md.test.ts.snap +++ b/src/lib/addons/__snapshots__/feature-event-formatter-md.test.ts.snap @@ -7,9 +7,16 @@ exports[`Should format specialised text for events when IPs changed 1`] = ` } `; +exports[`Should format specialised text for events when a scheduled change request is suspended 1`] = ` +{ + "text": "Change request *[#1](unleashUrl/projects/my-other-project/change-requests/1)* in the *production* environment in project *[my-other-project](unleashUrl/projects/my-other-project)* was suspended for the following reason: The user who scheduled this change request (user id: 6) has been deleted from this Unleash instance.", + "url": "unleashUrl/projects/my-other-project/change-requests/1", +} +`; + exports[`Should format specialised text for events when change request is scheduled 1`] = ` { - "text": "*user@company.com* scheduled change request *[#1](unleashUrl/projects/my-other-project/change-requests/1)* for feature toggle *[new-feature](unleashUrl/projects/my-other-project/features/new-feature)* in *production* environment in project *[my-other-project](unleashUrl/projects/my-other-project)* to be applied at in project *my-other-project*", + "text": "*user@company.com* scheduled change request *[#1](unleashUrl/projects/my-other-project/change-requests/1)* for feature toggle *[new-feature](unleashUrl/projects/my-other-project/features/new-feature)* in the *production* environment in project *[my-other-project](unleashUrl/projects/my-other-project)* to be applied at in project *my-other-project*", "url": "unleashUrl/projects/my-other-project/change-requests/1", } `; @@ -163,14 +170,14 @@ exports[`Should format specialised text for events when rollout percentage chang exports[`Should format specialised text for events when scheduled change request fails 1`] = ` { - "text": "*Failed* to apply the scheduled change request *[#1](unleashUrl/projects/my-other-project/change-requests/1)* for feature toggle *[new-feature](unleashUrl/projects/my-other-project/features/new-feature)* in *production* environment in project *[my-other-project](unleashUrl/projects/my-other-project)* by *user@company.com* in project *my-other-project*.", + "text": "*Failed* to apply the scheduled change request *[#1](unleashUrl/projects/my-other-project/change-requests/1)* for feature toggle *[new-feature](unleashUrl/projects/my-other-project/features/new-feature)* in the *production* environment in project *[my-other-project](unleashUrl/projects/my-other-project)* by *user@company.com* in project *my-other-project*.", "url": "unleashUrl/projects/my-other-project/change-requests/1", } `; exports[`Should format specialised text for events when scheduled change request succeeds 1`] = ` { - "text": "*Successfully* applied the scheduled change request *[#1](unleashUrl/projects/my-other-project/change-requests/1)* for feature toggle *[new-feature](unleashUrl/projects/my-other-project/features/new-feature)* in *production* environment in project *[my-other-project](unleashUrl/projects/my-other-project)* by *user@company.com* in project *my-other-project*.", + "text": "*Successfully* applied the scheduled change request *[#1](unleashUrl/projects/my-other-project/change-requests/1)* for feature toggle *[new-feature](unleashUrl/projects/my-other-project/features/new-feature)* in the *production* environment in project *[my-other-project](unleashUrl/projects/my-other-project)* by *user@company.com* in project *my-other-project*.", "url": "unleashUrl/projects/my-other-project/change-requests/1", } `; diff --git a/src/lib/addons/feature-event-formatter-md.test.ts b/src/lib/addons/feature-event-formatter-md.test.ts index 5f2aad1e5b..2d92c67219 100644 --- a/src/lib/addons/feature-event-formatter-md.test.ts +++ b/src/lib/addons/feature-event-formatter-md.test.ts @@ -2,6 +2,7 @@ import { CHANGE_REQUEST_SCHEDULED, CHANGE_REQUEST_SCHEDULED_APPLICATION_FAILURE, CHANGE_REQUEST_SCHEDULED_APPLICATION_SUCCESS, + CHANGE_REQUEST_SCHEDULE_SUSPENDED, FEATURE_STRATEGY_ADD, FEATURE_STRATEGY_REMOVE, FEATURE_STRATEGY_UPDATE, @@ -552,6 +553,24 @@ const testCases: [string, IEvent][] = [ environment: 'production', }, ], + [ + 'when a scheduled change request is suspended', + { + id: 921, + type: CHANGE_REQUEST_SCHEDULE_SUSPENDED, + createdBy: 'user@company.com', + createdByUserId: SYSTEM_USER_ID, + createdAt: new Date('2022-06-01T10:03:11.549Z'), + data: { + changeRequestId: 1, + reason: 'The user who scheduled this change request (user id: 6) has been deleted from this Unleash instance.', + }, + preData: {}, + tags: [], + project: 'my-other-project', + environment: 'production', + }, + ], ]; testCases.forEach(([description, event]) => diff --git a/src/lib/addons/feature-event-formatter-md.ts b/src/lib/addons/feature-event-formatter-md.ts index 000fefb529..56a5c36a84 100644 --- a/src/lib/addons/feature-event-formatter-md.ts +++ b/src/lib/addons/feature-event-formatter-md.ts @@ -58,6 +58,7 @@ import { CHANGE_REQUEST_SCHEDULED, CHANGE_REQUEST_SCHEDULED_APPLICATION_SUCCESS, CHANGE_REQUEST_SCHEDULED_APPLICATION_FAILURE, + CHANGE_REQUEST_SCHEDULE_SUSPENDED, } from '../types'; interface IEventData { @@ -155,6 +156,10 @@ const EVENT_MAP: Record = { action: '*Failed* to apply the scheduled change request {{changeRequest}} by *{{user}}* in project *{{event.project}}*.', path: '/projects/{{event.project}}/change-requests/{{event.data.changeRequestId}}', }, + [CHANGE_REQUEST_SCHEDULE_SUSPENDED]: { + action: 'Change request {{changeRequest}} was suspended for the following reason: {{event.data.reason}}', + path: '/projects/{{event.project}}/change-requests/{{event.data.changeRequestId}}', + }, [CONTEXT_FIELD_CREATED]: { action: '*{{user}}* created context field *{{event.data.name}}*', path: '/context', @@ -327,7 +332,7 @@ export class FeatureEventFormatterMd implements FeatureEventFormatter { ? ` for feature toggle *${featureLink}*` : ''; const environmentText = environment - ? ` in *${environment}* environment` + ? ` in the *${environment}* environment` : ''; const projectLink = this.generateProjectLink(event); const projectText = project ? ` in project *${projectLink}*` : ''; diff --git a/src/lib/addons/slack-app-definition.ts b/src/lib/addons/slack-app-definition.ts index 71f2877974..60196adb92 100644 --- a/src/lib/addons/slack-app-definition.ts +++ b/src/lib/addons/slack-app-definition.ts @@ -43,6 +43,7 @@ import { CHANGE_REQUEST_CANCELLED, CHANGE_REQUEST_SENT_TO_REVIEW, CHANGE_REQUEST_APPLIED, + CHANGE_REQUEST_SCHEDULE_SUSPENDED, API_TOKEN_CREATED, API_TOKEN_DELETED, SERVICE_ACCOUNT_CREATED, @@ -110,6 +111,7 @@ const slackAppDefinition: IAddonDefinition = { CHANGE_REQUEST_SCHEDULED, CHANGE_REQUEST_SCHEDULED_APPLICATION_SUCCESS, CHANGE_REQUEST_SCHEDULED_APPLICATION_FAILURE, + CHANGE_REQUEST_SCHEDULE_SUSPENDED, CONTEXT_FIELD_CREATED, CONTEXT_FIELD_DELETED, CONTEXT_FIELD_UPDATED, diff --git a/src/lib/addons/webhook-definition.ts b/src/lib/addons/webhook-definition.ts index 8b7388f58e..2867fd6193 100644 --- a/src/lib/addons/webhook-definition.ts +++ b/src/lib/addons/webhook-definition.ts @@ -28,6 +28,7 @@ import { CHANGE_REQUEST_SCHEDULED_APPLICATION_SUCCESS, CHANGE_REQUEST_SCHEDULED_APPLICATION_FAILURE, CHANGE_REQUEST_SCHEDULED, + CHANGE_REQUEST_SCHEDULE_SUSPENDED, } from '../types/events'; import { IAddonDefinition } from '../types/model'; @@ -123,6 +124,7 @@ const webhookDefinition: IAddonDefinition = { CHANGE_REQUEST_SCHEDULED, CHANGE_REQUEST_SCHEDULED_APPLICATION_SUCCESS, CHANGE_REQUEST_SCHEDULED_APPLICATION_FAILURE, + CHANGE_REQUEST_SCHEDULE_SUSPENDED, FEATURE_POTENTIALLY_STALE_ON, ], };