1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-09-15 17:50:48 +02:00

test: fix tests

This commit is contained in:
Nuno Góis 2024-09-20 15:03:23 +01:00
parent f07cc2e460
commit c9bd071c07
No known key found for this signature in database
GPG Key ID: 71ECC689F1091765
9 changed files with 84 additions and 53 deletions

View File

@ -1,16 +1,16 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Datadog integration Should call datadog webhook for archived toggle 1`] = `"{"text":"%%% \\n *some@user.com* archived *some-toggle* in project ** \\n %%% ","title":"Unleash notification update"}"`; exports[`Datadog integration Should call datadog webhook for archived toggle 1`] = `"{"text":"%%% \\n **some@user.com** archived **some-toggle** in project **** \\n %%% ","title":"Unleash notification update"}"`;
exports[`Datadog integration Should call datadog webhook for archived toggle with project info 1`] = `"{"text":"%%% \\n *some@user.com* archived *some-toggle* in project *[some-project](http://some-url.com/projects/some-project)* \\n %%% ","title":"Unleash notification update"}"`; exports[`Datadog integration Should call datadog webhook for archived toggle with project info 1`] = `"{"text":"%%% \\n **some@user.com** archived **some-toggle** in project **[some-project](http://some-url.com/projects/some-project)** \\n %%% ","title":"Unleash notification update"}"`;
exports[`Datadog integration Should call datadog webhook 1`] = `"{"text":"%%% \\n *some@user.com* created *[some-toggle](http://some-url.com/projects//features/some-toggle)* in project ** \\n %%% ","title":"Unleash notification update"}"`; exports[`Datadog integration Should call datadog webhook 1`] = `"{"text":"%%% \\n **some@user.com** created **[some-toggle](http://some-url.com/projects//features/some-toggle)** in project **** \\n %%% ","title":"Unleash notification update"}"`;
exports[`Datadog integration Should call datadog webhook for toggled environment 1`] = `"{"text":"%%% \\n *some@user.com* disabled *[some-toggle](http://some-url.com/projects/default/features/some-toggle)* for the *development* environment in project *[default](http://some-url.com/projects/default)* \\n %%% ","title":"Unleash notification update"}"`; exports[`Datadog integration Should call datadog webhook for toggled environment 1`] = `"{"text":"%%% \\n **some@user.com** disabled **[some-toggle](http://some-url.com/projects/default/features/some-toggle)** for the **development** environment in project **[default](http://some-url.com/projects/default)** \\n %%% ","title":"Unleash notification update"}"`;
exports[`Datadog integration Should call datadog webhook with JSON when template set 1`] = `"{"text":"{\\n \\"event\\": \\"feature-created\\",\\n \\"createdBy\\": \\"some@user.com\\"\\n}","title":"Unleash notification update"}"`; exports[`Datadog integration Should call datadog webhook with JSON when template set 1`] = `"{"text":"{\\n \\"event\\": \\"feature-created\\",\\n \\"createdBy\\": \\"some@user.com\\"\\n}","title":"Unleash notification update"}"`;
exports[`Datadog integration Should include customHeaders in headers when calling service 1`] = `"{"text":"%%% \\n *some@user.com* disabled *[some-toggle](http://some-url.com/projects/default/features/some-toggle)* for the *development* environment in project *[default](http://some-url.com/projects/default)* \\n %%% ","title":"Unleash notification update"}"`; exports[`Datadog integration Should include customHeaders in headers when calling service 1`] = `"{"text":"%%% \\n **some@user.com** disabled **[some-toggle](http://some-url.com/projects/default/features/some-toggle)** for the **development** environment in project **[default](http://some-url.com/projects/default)** \\n %%% ","title":"Unleash notification update"}"`;
exports[`Datadog integration Should include customHeaders in headers when calling service 2`] = ` exports[`Datadog integration Should include customHeaders in headers when calling service 2`] = `
{ {
@ -20,7 +20,7 @@ exports[`Datadog integration Should include customHeaders in headers when callin
} }
`; `;
exports[`Datadog integration Should not include source_type_name when included in the config 1`] = `"{"text":"%%% \\n *some@user.com* disabled *[some-toggle](http://some-url.com/projects/default/features/some-toggle)* for the *development* environment in project *[default](http://some-url.com/projects/default)* \\n %%% ","title":"Unleash notification update","source_type_name":"my-custom-source-type"}"`; exports[`Datadog integration Should not include source_type_name when included in the config 1`] = `"{"text":"%%% \\n **some@user.com** disabled **[some-toggle](http://some-url.com/projects/default/features/some-toggle)** for the **development** environment in project **[default](http://some-url.com/projects/default)** \\n %%% ","title":"Unleash notification update","source_type_name":"my-custom-source-type"}"`;
exports[`Datadog integration Should not include source_type_name when included in the config 2`] = ` exports[`Datadog integration Should not include source_type_name when included in the config 2`] = `
{ {

View File

@ -2,210 +2,240 @@
exports[`Should format specialised text for events when IPs changed 1`] = ` exports[`Should format specialised text for events when IPs changed 1`] = `
{ {
"text": "*user@company.com* updated *[new-feature](unleashUrl/projects/my-other-project/features/new-feature)* in project *[my-other-project](unleashUrl/projects/my-other-project)* by updating strategy *remoteAddress* in *production* IPs from empty set of IPs to [127.0.0.1]; constraints from empty set of constraints to [appName is one of (x,y)]", "label": "Flag strategy updated",
"text": "**user@company.com** updated **[new-feature](unleashUrl/projects/my-other-project/features/new-feature)** in project **[my-other-project](unleashUrl/projects/my-other-project)** by updating strategy **remoteAddress** in **production** IPs from empty set of IPs to [127.0.0.1]; constraints from empty set of constraints to [appName is one of (x,y)]",
"url": "unleashUrl/projects/my-other-project/features/new-feature", "url": "unleashUrl/projects/my-other-project/features/new-feature",
} }
`; `;
exports[`Should format specialised text for events when a scheduled change request is suspended 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.", "label": "Change request suspended",
"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", "url": "unleashUrl/projects/my-other-project/change-requests/1",
} }
`; `;
exports[`Should format specialised text for events when change request is scheduled 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 flag *[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*", "label": "Change request scheduled",
"text": "**user@company.com** scheduled change request **[#1](unleashUrl/projects/my-other-project/change-requests/1)** for feature flag **[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", "url": "unleashUrl/projects/my-other-project/change-requests/1",
} }
`; `;
exports[`Should format specialised text for events when constraints and rollout percentage and stickiness changed 1`] = ` exports[`Should format specialised text for events when constraints and rollout percentage and stickiness changed 1`] = `
{ {
"text": "*user@company.com* updated *[new-feature](unleashUrl/projects/my-other-project/features/new-feature)* in project *[my-other-project](unleashUrl/projects/my-other-project)* by updating strategy *flexibleRollout* in *production* stickiness from default to random; rollout from 67% to 32%; constraints from empty set of constraints to [appName is one of (x,y)]", "label": "Flag strategy updated",
"text": "**user@company.com** updated **[new-feature](unleashUrl/projects/my-other-project/features/new-feature)** in project **[my-other-project](unleashUrl/projects/my-other-project)** by updating strategy **flexibleRollout** in **production** stickiness from default to random; rollout from 67% to 32%; constraints from empty set of constraints to [appName is one of (x,y)]",
"url": "unleashUrl/projects/my-other-project/features/new-feature", "url": "unleashUrl/projects/my-other-project/features/new-feature",
} }
`; `;
exports[`Should format specialised text for events when default strategy updated 1`] = ` exports[`Should format specialised text for events when default strategy updated 1`] = `
{ {
"text": "*admin* updated *[aaa](unleashUrl/projects/default/features/aaa)* in project *[default](unleashUrl/projects/default)* by updating strategy *default* in *production* constraints from empty set of constraints to [appName is one of (x,y), appName not is one of (x)]", "label": "Flag strategy updated",
"text": "**admin** updated **[aaa](unleashUrl/projects/default/features/aaa)** in project **[default](unleashUrl/projects/default)** by updating strategy **default** in **production** constraints from empty set of constraints to [appName is one of (x,y), appName not is one of (x)]",
"url": "unleashUrl/projects/default/features/aaa", "url": "unleashUrl/projects/default/features/aaa",
} }
`; `;
exports[`Should format specialised text for events when default strategy updated 2`] = ` exports[`Should format specialised text for events when default strategy updated 2`] = `
{ {
"text": "*admin* updated *[aaa](unleashUrl/projects/default/features/aaa)* in project *[default](unleashUrl/projects/default)* by updating strategy *default* in *production* constraints from empty set of constraints to [appName is not one of (x,y), appName not is not one of (x)]", "label": "Flag strategy updated",
"text": "**admin** updated **[aaa](unleashUrl/projects/default/features/aaa)** in project **[default](unleashUrl/projects/default)** by updating strategy **default** in **production** constraints from empty set of constraints to [appName is not one of (x,y), appName not is not one of (x)]",
"url": "unleashUrl/projects/default/features/aaa", "url": "unleashUrl/projects/default/features/aaa",
} }
`; `;
exports[`Should format specialised text for events when default strategy updated 3`] = ` exports[`Should format specialised text for events when default strategy updated 3`] = `
{ {
"text": "*admin* updated *[aaa](unleashUrl/projects/default/features/aaa)* in project *[default](unleashUrl/projects/default)* by updating strategy *default* in *production* constraints from empty set of constraints to [appName is a string that contains (x,y), appName not is a string that contains (x)]", "label": "Flag strategy updated",
"text": "**admin** updated **[aaa](unleashUrl/projects/default/features/aaa)** in project **[default](unleashUrl/projects/default)** by updating strategy **default** in **production** constraints from empty set of constraints to [appName is a string that contains (x,y), appName not is a string that contains (x)]",
"url": "unleashUrl/projects/default/features/aaa", "url": "unleashUrl/projects/default/features/aaa",
} }
`; `;
exports[`Should format specialised text for events when default strategy updated 4`] = ` exports[`Should format specialised text for events when default strategy updated 4`] = `
{ {
"text": "*admin* updated *[aaa](unleashUrl/projects/default/features/aaa)* in project *[default](unleashUrl/projects/default)* by updating strategy *default* in *production* constraints from empty set of constraints to [appName is a string that starts with (x,y), appName not is a string that starts with (x)]", "label": "Flag strategy updated",
"text": "**admin** updated **[aaa](unleashUrl/projects/default/features/aaa)** in project **[default](unleashUrl/projects/default)** by updating strategy **default** in **production** constraints from empty set of constraints to [appName is a string that starts with (x,y), appName not is a string that starts with (x)]",
"url": "unleashUrl/projects/default/features/aaa", "url": "unleashUrl/projects/default/features/aaa",
} }
`; `;
exports[`Should format specialised text for events when default strategy updated 5`] = ` exports[`Should format specialised text for events when default strategy updated 5`] = `
{ {
"text": "*admin* updated *[aaa](unleashUrl/projects/default/features/aaa)* in project *[default](unleashUrl/projects/default)* by updating strategy *default* in *production* constraints from empty set of constraints to [appName is a string that ends with (x,y), appName not is a string that ends with (x)]", "label": "Flag strategy updated",
"text": "**admin** updated **[aaa](unleashUrl/projects/default/features/aaa)** in project **[default](unleashUrl/projects/default)** by updating strategy **default** in **production** constraints from empty set of constraints to [appName is a string that ends with (x,y), appName not is a string that ends with (x)]",
"url": "unleashUrl/projects/default/features/aaa", "url": "unleashUrl/projects/default/features/aaa",
} }
`; `;
exports[`Should format specialised text for events when default strategy updated with numeric constraint DATE_AFTER 1`] = ` exports[`Should format specialised text for events when default strategy updated with numeric constraint DATE_AFTER 1`] = `
{ {
"text": "*admin* updated *[aaa](unleashUrl/projects/default/features/aaa)* in project *[default](unleashUrl/projects/default)* by updating strategy *default* in *production* constraints from [appName is a date after 4] to empty set of constraints", "label": "Flag strategy updated",
"text": "**admin** updated **[aaa](unleashUrl/projects/default/features/aaa)** in project **[default](unleashUrl/projects/default)** by updating strategy **default** in **production** constraints from [appName is a date after 4] to empty set of constraints",
"url": "unleashUrl/projects/default/features/aaa", "url": "unleashUrl/projects/default/features/aaa",
} }
`; `;
exports[`Should format specialised text for events when default strategy updated with numeric constraint DATE_BEFORE 1`] = ` exports[`Should format specialised text for events when default strategy updated with numeric constraint DATE_BEFORE 1`] = `
{ {
"text": "*admin* updated *[aaa](unleashUrl/projects/default/features/aaa)* in project *[default](unleashUrl/projects/default)* by updating strategy *default* in *production* constraints from [appName is a date before 4] to empty set of constraints", "label": "Flag strategy updated",
"text": "**admin** updated **[aaa](unleashUrl/projects/default/features/aaa)** in project **[default](unleashUrl/projects/default)** by updating strategy **default** in **production** constraints from [appName is a date before 4] to empty set of constraints",
"url": "unleashUrl/projects/default/features/aaa", "url": "unleashUrl/projects/default/features/aaa",
} }
`; `;
exports[`Should format specialised text for events when default strategy updated with numeric constraint NUM_EQ 1`] = ` exports[`Should format specialised text for events when default strategy updated with numeric constraint NUM_EQ 1`] = `
{ {
"text": "*admin* updated *[aaa](unleashUrl/projects/default/features/aaa)* in project *[default](unleashUrl/projects/default)* by updating strategy *default* in *production* constraints from [appName is a number equal to 4] to empty set of constraints", "label": "Flag strategy updated",
"text": "**admin** updated **[aaa](unleashUrl/projects/default/features/aaa)** in project **[default](unleashUrl/projects/default)** by updating strategy **default** in **production** constraints from [appName is a number equal to 4] to empty set of constraints",
"url": "unleashUrl/projects/default/features/aaa", "url": "unleashUrl/projects/default/features/aaa",
} }
`; `;
exports[`Should format specialised text for events when default strategy updated with numeric constraint NUM_GT 1`] = ` exports[`Should format specialised text for events when default strategy updated with numeric constraint NUM_GT 1`] = `
{ {
"text": "*admin* updated *[aaa](unleashUrl/projects/default/features/aaa)* in project *[default](unleashUrl/projects/default)* by updating strategy *default* in *production* constraints from [appName is a number greater than 4] to empty set of constraints", "label": "Flag strategy updated",
"text": "**admin** updated **[aaa](unleashUrl/projects/default/features/aaa)** in project **[default](unleashUrl/projects/default)** by updating strategy **default** in **production** constraints from [appName is a number greater than 4] to empty set of constraints",
"url": "unleashUrl/projects/default/features/aaa", "url": "unleashUrl/projects/default/features/aaa",
} }
`; `;
exports[`Should format specialised text for events when default strategy updated with numeric constraint NUM_GTE 1`] = ` exports[`Should format specialised text for events when default strategy updated with numeric constraint NUM_GTE 1`] = `
{ {
"text": "*admin* updated *[aaa](unleashUrl/projects/default/features/aaa)* in project *[default](unleashUrl/projects/default)* by updating strategy *default* in *production* constraints from [appName is a number greater than or equal to 4] to empty set of constraints", "label": "Flag strategy updated",
"text": "**admin** updated **[aaa](unleashUrl/projects/default/features/aaa)** in project **[default](unleashUrl/projects/default)** by updating strategy **default** in **production** constraints from [appName is a number greater than or equal to 4] to empty set of constraints",
"url": "unleashUrl/projects/default/features/aaa", "url": "unleashUrl/projects/default/features/aaa",
} }
`; `;
exports[`Should format specialised text for events when default strategy updated with numeric constraint NUM_LT 1`] = ` exports[`Should format specialised text for events when default strategy updated with numeric constraint NUM_LT 1`] = `
{ {
"text": "*admin* updated *[aaa](unleashUrl/projects/default/features/aaa)* in project *[default](unleashUrl/projects/default)* by updating strategy *default* in *production* constraints from [appName is a number less than 4] to empty set of constraints", "label": "Flag strategy updated",
"text": "**admin** updated **[aaa](unleashUrl/projects/default/features/aaa)** in project **[default](unleashUrl/projects/default)** by updating strategy **default** in **production** constraints from [appName is a number less than 4] to empty set of constraints",
"url": "unleashUrl/projects/default/features/aaa", "url": "unleashUrl/projects/default/features/aaa",
} }
`; `;
exports[`Should format specialised text for events when default strategy updated with numeric constraint NUM_LTE 1`] = ` exports[`Should format specialised text for events when default strategy updated with numeric constraint NUM_LTE 1`] = `
{ {
"text": "*admin* updated *[aaa](unleashUrl/projects/default/features/aaa)* in project *[default](unleashUrl/projects/default)* by updating strategy *default* in *production* constraints from [appName is a number less than or equal to 4] to empty set of constraints", "label": "Flag strategy updated",
"text": "**admin** updated **[aaa](unleashUrl/projects/default/features/aaa)** in project **[default](unleashUrl/projects/default)** by updating strategy **default** in **production** constraints from [appName is a number less than or equal to 4] to empty set of constraints",
"url": "unleashUrl/projects/default/features/aaa", "url": "unleashUrl/projects/default/features/aaa",
} }
`; `;
exports[`Should format specialised text for events when default strategy updated with numeric constraint SEMVER_EQ 1`] = ` exports[`Should format specialised text for events when default strategy updated with numeric constraint SEMVER_EQ 1`] = `
{ {
"text": "*admin* updated *[aaa](unleashUrl/projects/default/features/aaa)* in project *[default](unleashUrl/projects/default)* by updating strategy *default* in *production* constraints from [appName is a SemVer equal to 4] to empty set of constraints", "label": "Flag strategy updated",
"text": "**admin** updated **[aaa](unleashUrl/projects/default/features/aaa)** in project **[default](unleashUrl/projects/default)** by updating strategy **default** in **production** constraints from [appName is a SemVer equal to 4] to empty set of constraints",
"url": "unleashUrl/projects/default/features/aaa", "url": "unleashUrl/projects/default/features/aaa",
} }
`; `;
exports[`Should format specialised text for events when default strategy updated with numeric constraint SEMVER_GT 1`] = ` exports[`Should format specialised text for events when default strategy updated with numeric constraint SEMVER_GT 1`] = `
{ {
"text": "*admin* updated *[aaa](unleashUrl/projects/default/features/aaa)* in project *[default](unleashUrl/projects/default)* by updating strategy *default* in *production* constraints from [appName is a SemVer greater than 4] to empty set of constraints", "label": "Flag strategy updated",
"text": "**admin** updated **[aaa](unleashUrl/projects/default/features/aaa)** in project **[default](unleashUrl/projects/default)** by updating strategy **default** in **production** constraints from [appName is a SemVer greater than 4] to empty set of constraints",
"url": "unleashUrl/projects/default/features/aaa", "url": "unleashUrl/projects/default/features/aaa",
} }
`; `;
exports[`Should format specialised text for events when default strategy updated with numeric constraint SEMVER_LT 1`] = ` exports[`Should format specialised text for events when default strategy updated with numeric constraint SEMVER_LT 1`] = `
{ {
"text": "*admin* updated *[aaa](unleashUrl/projects/default/features/aaa)* in project *[default](unleashUrl/projects/default)* by updating strategy *default* in *production* constraints from [appName is a SemVer less than 4] to empty set of constraints", "label": "Flag strategy updated",
"text": "**admin** updated **[aaa](unleashUrl/projects/default/features/aaa)** in project **[default](unleashUrl/projects/default)** by updating strategy **default** in **production** constraints from [appName is a SemVer less than 4] to empty set of constraints",
"url": "unleashUrl/projects/default/features/aaa", "url": "unleashUrl/projects/default/features/aaa",
} }
`; `;
exports[`Should format specialised text for events when groupId changed 1`] = ` exports[`Should format specialised text for events when groupId changed 1`] = `
{ {
"text": "*user@company.com* updated *[new-feature](unleashUrl/projects/my-other-project/features/new-feature)* in project *[my-other-project](unleashUrl/projects/my-other-project)* by updating strategy *flexibleRollout* in *production* groupId from new-feature to different-feature", "label": "Flag strategy updated",
"text": "**user@company.com** updated **[new-feature](unleashUrl/projects/my-other-project/features/new-feature)** in project **[my-other-project](unleashUrl/projects/my-other-project)** by updating strategy **flexibleRollout** in **production** groupId from new-feature to different-feature",
"url": "unleashUrl/projects/my-other-project/features/new-feature", "url": "unleashUrl/projects/my-other-project/features/new-feature",
} }
`; `;
exports[`Should format specialised text for events when host names changed 1`] = ` exports[`Should format specialised text for events when host names changed 1`] = `
{ {
"text": "*user@company.com* updated *[new-feature](unleashUrl/projects/my-other-project/features/new-feature)* in project *[my-other-project](unleashUrl/projects/my-other-project)* by updating strategy *applicationHostname* in *production* hostNames from empty set of hostNames to [unleash.com]; constraints from empty set of constraints to [appName is one of (x,y)]", "label": "Flag strategy updated",
"text": "**user@company.com** updated **[new-feature](unleashUrl/projects/my-other-project/features/new-feature)** in project **[my-other-project](unleashUrl/projects/my-other-project)** by updating strategy **applicationHostname** in **production** hostNames from empty set of hostNames to [unleash.com]; constraints from empty set of constraints to [appName is one of (x,y)]",
"url": "unleashUrl/projects/my-other-project/features/new-feature", "url": "unleashUrl/projects/my-other-project/features/new-feature",
} }
`; `;
exports[`Should format specialised text for events when neither rollout percentage nor stickiness changed 1`] = ` exports[`Should format specialised text for events when neither rollout percentage nor stickiness changed 1`] = `
{ {
"text": "*user@company.com* updated *[new-feature](unleashUrl/projects/my-other-project/features/new-feature)* in project *[my-other-project](unleashUrl/projects/my-other-project)* by updating strategy *flexibleRollout* in *production*", "label": "Flag strategy updated",
"text": "**user@company.com** updated **[new-feature](unleashUrl/projects/my-other-project/features/new-feature)** in project **[my-other-project](unleashUrl/projects/my-other-project)** by updating strategy **flexibleRollout** in **production**",
"url": "unleashUrl/projects/my-other-project/features/new-feature", "url": "unleashUrl/projects/my-other-project/features/new-feature",
} }
`; `;
exports[`Should format specialised text for events when no specific text for strategy exists yet 1`] = ` exports[`Should format specialised text for events when no specific text for strategy exists yet 1`] = `
{ {
"text": "*user@company.com* updated *[new-feature](unleashUrl/projects/my-other-project/features/new-feature)* in project *[my-other-project](unleashUrl/projects/my-other-project)* by updating strategy *newStrategy* in *production*", "label": "Flag strategy updated",
"text": "**user@company.com** updated **[new-feature](unleashUrl/projects/my-other-project/features/new-feature)** in project **[my-other-project](unleashUrl/projects/my-other-project)** by updating strategy **newStrategy** in **production**",
"url": "unleashUrl/projects/my-other-project/features/new-feature", "url": "unleashUrl/projects/my-other-project/features/new-feature",
} }
`; `;
exports[`Should format specialised text for events when rollout percentage changed 1`] = ` exports[`Should format specialised text for events when rollout percentage changed 1`] = `
{ {
"text": "*user@company.com* updated *[new-feature](unleashUrl/projects/my-other-project/features/new-feature)* in project *[my-other-project](unleashUrl/projects/my-other-project)* by updating strategy *flexibleRollout* in *production* rollout from 67% to 32%", "label": "Flag strategy updated",
"text": "**user@company.com** updated **[new-feature](unleashUrl/projects/my-other-project/features/new-feature)** in project **[my-other-project](unleashUrl/projects/my-other-project)** by updating strategy **flexibleRollout** in **production** rollout from 67% to 32%",
"url": "unleashUrl/projects/my-other-project/features/new-feature", "url": "unleashUrl/projects/my-other-project/features/new-feature",
} }
`; `;
exports[`Should format specialised text for events when scheduled change request fails 1`] = ` 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 flag *[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*.", "label": "Scheduled change request failed",
"text": "**Failed** to apply the scheduled change request **[#1](unleashUrl/projects/my-other-project/change-requests/1)** for feature flag **[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", "url": "unleashUrl/projects/my-other-project/change-requests/1",
} }
`; `;
exports[`Should format specialised text for events when scheduled change request succeeds 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 flag *[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*.", "label": "Scheduled change request applied successfully",
"text": "**Successfully** applied the scheduled change request **[#1](unleashUrl/projects/my-other-project/change-requests/1)** for feature flag **[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", "url": "unleashUrl/projects/my-other-project/change-requests/1",
} }
`; `;
exports[`Should format specialised text for events when stickiness changed 1`] = ` exports[`Should format specialised text for events when stickiness changed 1`] = `
{ {
"text": "*user@company.com* updated *[new-feature](unleashUrl/projects/my-other-project/features/new-feature)* in project *[my-other-project](unleashUrl/projects/my-other-project)* by updating strategy *flexibleRollout* in *production* stickiness from default to random", "label": "Flag strategy updated",
"text": "**user@company.com** updated **[new-feature](unleashUrl/projects/my-other-project/features/new-feature)** in project **[my-other-project](unleashUrl/projects/my-other-project)** by updating strategy **flexibleRollout** in **production** stickiness from default to random",
"url": "unleashUrl/projects/my-other-project/features/new-feature", "url": "unleashUrl/projects/my-other-project/features/new-feature",
} }
`; `;
exports[`Should format specialised text for events when strategy added 1`] = ` exports[`Should format specialised text for events when strategy added 1`] = `
{ {
"text": "*user@company.com* added strategy *flexibleRollout* to *[new-feature](unleashUrl/projects/my-other-project/features/new-feature)* for the *production* environment in project *[my-other-project](unleashUrl/projects/my-other-project)*", "label": "Flag strategy added",
"text": "**user@company.com** added strategy **flexibleRollout** to **[new-feature](unleashUrl/projects/my-other-project/features/new-feature)** for the **production** environment in project **[my-other-project](unleashUrl/projects/my-other-project)**",
"url": "unleashUrl/projects/my-other-project/features/new-feature", "url": "unleashUrl/projects/my-other-project/features/new-feature",
} }
`; `;
exports[`Should format specialised text for events when strategy removed 1`] = ` exports[`Should format specialised text for events when strategy removed 1`] = `
{ {
"text": "*user@company.com* removed strategy *default* from *[new-feature](unleashUrl/projects/my-other-project/features/new-feature)* for the *production* environment in project *[my-other-project](unleashUrl/projects/my-other-project)*", "label": "Flag strategy removed",
"text": "**user@company.com** removed strategy **default** from **[new-feature](unleashUrl/projects/my-other-project/features/new-feature)** for the **production** environment in project **[my-other-project](unleashUrl/projects/my-other-project)**",
"url": "unleashUrl/projects/my-other-project/features/new-feature", "url": "unleashUrl/projects/my-other-project/features/new-feature",
} }
`; `;
exports[`Should format specialised text for events when userIds changed 1`] = ` exports[`Should format specialised text for events when userIds changed 1`] = `
{ {
"text": "*user@company.com* updated *[new-feature](unleashUrl/projects/my-other-project/features/new-feature)* in project *[my-other-project](unleashUrl/projects/my-other-project)* by updating strategy *userWithId* in *production* userIds from empty set of userIds to [a,b]; constraints from empty set of constraints to [appName is one of (x,y)]", "label": "Flag strategy updated",
"text": "**user@company.com** updated **[new-feature](unleashUrl/projects/my-other-project/features/new-feature)** in project **[my-other-project](unleashUrl/projects/my-other-project)** by updating strategy **userWithId** in **production** userIds from empty set of userIds to [a,b]; constraints from empty set of constraints to [appName is one of (x,y)]",
"url": "unleashUrl/projects/my-other-project/features/new-feature", "url": "unleashUrl/projects/my-other-project/features/new-feature",
} }
`; `;

View File

@ -1,14 +1,14 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Slack integration Should call slack webhook 1`] = `"{"username":"Unleash","icon_emoji":":unleash:","text":"*some@user.com* created *<http://some-url.com/projects/default/features/some-toggle|some-toggle>* in project *<http://some-url.com/projects/default|default>*","channel":"#general","attachments":[{"actions":[{"name":"featureToggle","text":"Open in Unleash","type":"button","value":"featureToggle","style":"primary","url":"http://some-url.com/projects/default/features/some-toggle"}]}]}"`; exports[`Slack integration Should call slack webhook 1`] = `"{"username":"Unleash","icon_emoji":":unleash:","text":"**some@user.com** created **<http://some-url.com/projects/default/features/some-toggle|some-toggle>** in project **<http://some-url.com/projects/default|default>**","channel":"#general","attachments":[{"actions":[{"name":"featureToggle","text":"Open in Unleash","type":"button","value":"featureToggle","style":"primary","url":"http://some-url.com/projects/default/features/some-toggle"}]}]}"`;
exports[`Slack integration Should call slack webhook for archived toggle 1`] = `"{"username":"Unleash","icon_emoji":":unleash:","text":"*some@user.com* archived *some-toggle* in project **","channel":"#general","attachments":[{"actions":[{"name":"featureToggle","text":"Open in Unleash","type":"button","value":"featureToggle","style":"primary","url":"http://some-url.com/projects//archive"}]}]}"`; exports[`Slack integration Should call slack webhook for archived toggle 1`] = `"{"username":"Unleash","icon_emoji":":unleash:","text":"**some@user.com** archived **some-toggle** in project ****","channel":"#general","attachments":[{"actions":[{"name":"featureToggle","text":"Open in Unleash","type":"button","value":"featureToggle","style":"primary","url":"http://some-url.com/projects//archive"}]}]}"`;
exports[`Slack integration Should call slack webhook for archived toggle with project info 1`] = `"{"username":"Unleash","icon_emoji":":unleash:","text":"*some@user.com* archived *some-toggle* in project *<http://some-url.com/projects/some-project|some-project>*","channel":"#general","attachments":[{"actions":[{"name":"featureToggle","text":"Open in Unleash","type":"button","value":"featureToggle","style":"primary","url":"http://some-url.com/projects/some-project/archive"}]}]}"`; exports[`Slack integration Should call slack webhook for archived toggle with project info 1`] = `"{"username":"Unleash","icon_emoji":":unleash:","text":"**some@user.com** archived **some-toggle** in project **<http://some-url.com/projects/some-project|some-project>**","channel":"#general","attachments":[{"actions":[{"name":"featureToggle","text":"Open in Unleash","type":"button","value":"featureToggle","style":"primary","url":"http://some-url.com/projects/some-project/archive"}]}]}"`;
exports[`Slack integration Should call webhook for toggled environment 1`] = `"{"username":"Unleash","icon_emoji":":unleash:","text":"*some@user.com* disabled *<http://some-url.com/projects/default/features/some-toggle|some-toggle>* for the *development* environment in project *<http://some-url.com/projects/default|default>*","channel":"#general","attachments":[{"actions":[{"name":"featureToggle","text":"Open in Unleash","type":"button","value":"featureToggle","style":"primary","url":"http://some-url.com/projects/default/features/some-toggle"}]}]}"`; exports[`Slack integration Should call webhook for toggled environment 1`] = `"{"username":"Unleash","icon_emoji":":unleash:","text":"**some@user.com** disabled **<http://some-url.com/projects/default/features/some-toggle|some-toggle>** for the **development** environment in project **<http://some-url.com/projects/default|default>**","channel":"#general","attachments":[{"actions":[{"name":"featureToggle","text":"Open in Unleash","type":"button","value":"featureToggle","style":"primary","url":"http://some-url.com/projects/default/features/some-toggle"}]}]}"`;
exports[`Slack integration Should include custom headers from parameters in call to service 1`] = `"{"username":"Unleash","icon_emoji":":unleash:","text":"*some@user.com* disabled *<http://some-url.com/projects/default/features/some-toggle|some-toggle>* for the *development* environment in project *<http://some-url.com/projects/default|default>*","channel":"#general","attachments":[{"actions":[{"name":"featureToggle","text":"Open in Unleash","type":"button","value":"featureToggle","style":"primary","url":"http://some-url.com/projects/default/features/some-toggle"}]}]}"`; exports[`Slack integration Should include custom headers from parameters in call to service 1`] = `"{"username":"Unleash","icon_emoji":":unleash:","text":"**some@user.com** disabled **<http://some-url.com/projects/default/features/some-toggle|some-toggle>** for the **development** environment in project **<http://some-url.com/projects/default|default>**","channel":"#general","attachments":[{"actions":[{"name":"featureToggle","text":"Open in Unleash","type":"button","value":"featureToggle","style":"primary","url":"http://some-url.com/projects/default/features/some-toggle"}]}]}"`;
exports[`Slack integration Should include custom headers from parameters in call to service 2`] = ` exports[`Slack integration Should include custom headers from parameters in call to service 2`] = `
{ {

View File

@ -1,14 +1,14 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Teams integration Should call teams webhook 1`] = `"{"themeColor":"0076D7","summary":"Message","sections":[{"activityTitle":"*some@user.com* created *[some-toggle](http://some-url.com/projects//features/some-toggle)* in project **","activitySubtitle":"Unleash notification update","facts":[{"name":"User","value":"some@user.com"},{"name":"Action","value":"feature-created"}]}],"potentialAction":[{"@type":"OpenUri","name":"Go to feature","targets":[{"os":"default","uri":"http://some-url.com/projects//features/some-toggle"}]}]}"`; exports[`Teams integration Should call teams webhook 1`] = `"{"themeColor":"0076D7","summary":"Message","sections":[{"activityTitle":"**some@user.com** created **[some-toggle](http://some-url.com/projects//features/some-toggle)** in project ****","activitySubtitle":"Unleash notification update","facts":[{"name":"User","value":"some@user.com"},{"name":"Action","value":"feature-created"}]}],"potentialAction":[{"@type":"OpenUri","name":"Go to feature","targets":[{"os":"default","uri":"http://some-url.com/projects//features/some-toggle"}]}]}"`;
exports[`Teams integration Should call teams webhook for archived toggle 1`] = `"{"themeColor":"0076D7","summary":"Message","sections":[{"activityTitle":"*some@user.com* archived *some-toggle* in project **","activitySubtitle":"Unleash notification update","facts":[{"name":"User","value":"some@user.com"},{"name":"Action","value":"feature-archived"}]}],"potentialAction":[{"@type":"OpenUri","name":"Go to feature","targets":[{"os":"default","uri":"http://some-url.com/projects//archive"}]}]}"`; exports[`Teams integration Should call teams webhook for archived toggle 1`] = `"{"themeColor":"0076D7","summary":"Message","sections":[{"activityTitle":"**some@user.com** archived **some-toggle** in project ****","activitySubtitle":"Unleash notification update","facts":[{"name":"User","value":"some@user.com"},{"name":"Action","value":"feature-archived"}]}],"potentialAction":[{"@type":"OpenUri","name":"Go to feature","targets":[{"os":"default","uri":"http://some-url.com/projects//archive"}]}]}"`;
exports[`Teams integration Should call teams webhook for archived toggle with project info 1`] = `"{"themeColor":"0076D7","summary":"Message","sections":[{"activityTitle":"*some@user.com* archived *some-toggle* in project *[some-project](http://some-url.com/projects/some-project)*","activitySubtitle":"Unleash notification update","facts":[{"name":"User","value":"some@user.com"},{"name":"Action","value":"feature-archived"}]}],"potentialAction":[{"@type":"OpenUri","name":"Go to feature","targets":[{"os":"default","uri":"http://some-url.com/projects/some-project/archive"}]}]}"`; exports[`Teams integration Should call teams webhook for archived toggle with project info 1`] = `"{"themeColor":"0076D7","summary":"Message","sections":[{"activityTitle":"**some@user.com** archived **some-toggle** in project **[some-project](http://some-url.com/projects/some-project)**","activitySubtitle":"Unleash notification update","facts":[{"name":"User","value":"some@user.com"},{"name":"Action","value":"feature-archived"}]}],"potentialAction":[{"@type":"OpenUri","name":"Go to feature","targets":[{"os":"default","uri":"http://some-url.com/projects/some-project/archive"}]}]}"`;
exports[`Teams integration Should call teams webhook for toggled environment 1`] = `"{"themeColor":"0076D7","summary":"Message","sections":[{"activityTitle":"*some@user.com* disabled *[some-toggle](http://some-url.com/projects/default/features/some-toggle)* for the *development* environment in project *[default](http://some-url.com/projects/default)*","activitySubtitle":"Unleash notification update","facts":[{"name":"User","value":"some@user.com"},{"name":"Action","value":"feature-environment-disabled"}]}],"potentialAction":[{"@type":"OpenUri","name":"Go to feature","targets":[{"os":"default","uri":"http://some-url.com/projects/default/features/some-toggle"}]}]}"`; exports[`Teams integration Should call teams webhook for toggled environment 1`] = `"{"themeColor":"0076D7","summary":"Message","sections":[{"activityTitle":"**some@user.com** disabled **[some-toggle](http://some-url.com/projects/default/features/some-toggle)** for the **development** environment in project **[default](http://some-url.com/projects/default)**","activitySubtitle":"Unleash notification update","facts":[{"name":"User","value":"some@user.com"},{"name":"Action","value":"feature-environment-disabled"}]}],"potentialAction":[{"@type":"OpenUri","name":"Go to feature","targets":[{"os":"default","uri":"http://some-url.com/projects/default/features/some-toggle"}]}]}"`;
exports[`Teams integration Should include custom headers in call to teams 1`] = `"{"themeColor":"0076D7","summary":"Message","sections":[{"activityTitle":"*some@user.com* disabled *[some-toggle](http://some-url.com/projects/default/features/some-toggle)* for the *development* environment in project *[default](http://some-url.com/projects/default)*","activitySubtitle":"Unleash notification update","facts":[{"name":"User","value":"some@user.com"},{"name":"Action","value":"feature-environment-disabled"}]}],"potentialAction":[{"@type":"OpenUri","name":"Go to feature","targets":[{"os":"default","uri":"http://some-url.com/projects/default/features/some-toggle"}]}]}"`; exports[`Teams integration Should include custom headers in call to teams 1`] = `"{"themeColor":"0076D7","summary":"Message","sections":[{"activityTitle":"**some@user.com** disabled **[some-toggle](http://some-url.com/projects/default/features/some-toggle)** for the **development** environment in project **[default](http://some-url.com/projects/default)**","activitySubtitle":"Unleash notification update","facts":[{"name":"User","value":"some@user.com"},{"name":"Action","value":"feature-environment-disabled"}]}],"potentialAction":[{"@type":"OpenUri","name":"Go to feature","targets":[{"os":"default","uri":"http://some-url.com/projects/default/features/some-toggle"}]}]}"`;
exports[`Teams integration Should include custom headers in call to teams 2`] = ` exports[`Teams integration Should include custom headers in call to teams 2`] = `
{ {

View File

@ -3,6 +3,6 @@
exports[`Webhook integration should allow for eventJson and eventMarkdown in bodyTemplate 1`] = ` exports[`Webhook integration should allow for eventJson and eventMarkdown in bodyTemplate 1`] = `
"{ "{
"json": "{\\"id\\":1,\\"createdAt\\":\\"2024-07-24T00:00:00.000Z\\",\\"createdByUserId\\":-1337,\\"type\\":\\"feature-created\\",\\"createdBy\\":\\"some@user.com\\",\\"featureName\\":\\"some-toggle\\",\\"project\\":\\"default\\",\\"data\\":{\\"name\\":\\"some-toggle\\",\\"enabled\\":false,\\"strategies\\":[{\\"name\\":\\"default\\"}]}}", "json": "{\\"id\\":1,\\"createdAt\\":\\"2024-07-24T00:00:00.000Z\\",\\"createdByUserId\\":-1337,\\"type\\":\\"feature-created\\",\\"createdBy\\":\\"some@user.com\\",\\"featureName\\":\\"some-toggle\\",\\"project\\":\\"default\\",\\"data\\":{\\"name\\":\\"some-toggle\\",\\"enabled\\":false,\\"strategies\\":[{\\"name\\":\\"default\\"}]}}",
"markdown": "*some@user.com* created *[some-toggle](http://some-url.com/projects/default/features/some-toggle)* in project *[default](http://some-url.com/projects/default)*" "markdown": "**some@user.com** created **[some-toggle](http://some-url.com/projects/default/features/some-toggle)** in project **[default](http://some-url.com/projects/default)**"
}" }"
`; `;

View File

@ -82,7 +82,7 @@ export enum LinkStyle {
MD = 1, MD = 1,
} }
const bold = (text?: string) => (text ? `**${text}**` : ''); export const bold = (text?: string) => (text ? `**${text}**` : '');
const EVENT_MAP: Record<string, IEventData> = { const EVENT_MAP: Record<string, IEventData> = {
[ADDON_CONFIG_CREATED]: { [ADDON_CONFIG_CREATED]: {

View File

@ -10,6 +10,7 @@ import {
} from '../types'; } from '../types';
import type { IntegrationEventsService } from '../services'; import type { IntegrationEventsService } from '../services';
import type { Logger } from '../logger'; import type { Logger } from '../logger';
import { bold } from './feature-event-formatter-md';
const slackApiCalls: ChatPostMessageArguments[] = []; const slackApiCalls: ChatPostMessageArguments[] = [];
@ -271,8 +272,7 @@ describe('SlackAppAddon', () => {
event: serializeDates(eventWith2Tags), event: serializeDates(eventWith2Tags),
details: { details: {
channels: ['general', 'another-channel-1', 'another-channel-2'], channels: ['general', 'another-channel-1', 'another-channel-2'],
message: message: `${bold('some@user.com')} enabled ${bold('<http://some-url.com/projects/default/features/some-toggle|some-toggle>')} for the ${bold('development')} environment in project ${bold('<http://some-url.com/projects/default|default>')}`,
'*some@user.com* enabled *<http://some-url.com/projects/default/features/some-toggle|some-toggle>* for the *development* environment in project *<http://some-url.com/projects/default|default>*',
}, },
}); });
}); });

View File

@ -17,6 +17,7 @@ import {
SYSTEM_USER_ID, SYSTEM_USER_ID,
} from '../types'; } from '../types';
import type { IntegrationEventsService } from '../services'; import type { IntegrationEventsService } from '../services';
import { bold } from './feature-event-formatter-md';
let fetchRetryCalls: any[] = []; let fetchRetryCalls: any[] = [];
const registerEventMock = jest.fn(); const registerEventMock = jest.fn();
@ -338,8 +339,7 @@ describe('Slack integration', () => {
url: parameters.url, url: parameters.url,
channels: ['general'], channels: ['general'],
username: 'Unleash', username: 'Unleash',
message: message: `${bold('some@user.com')} disabled ${bold('<http://some-url.com/projects/default/features/some-toggle|some-toggle>')} for the ${bold('development')} environment in project ${bold('<http://some-url.com/projects/default|default>')}`,
'*some@user.com* disabled *<http://some-url.com/projects/default/features/some-toggle|some-toggle>* for the *development* environment in project *<http://some-url.com/projects/default|default>*',
}, },
}); });
}); });

View File

@ -18,6 +18,7 @@ import {
SYSTEM_USER_ID, SYSTEM_USER_ID,
} from '../types'; } from '../types';
import type { IntegrationEventsService } from '../services'; import type { IntegrationEventsService } from '../services';
import { bold } from './feature-event-formatter-md';
let fetchRetryCalls: any[]; let fetchRetryCalls: any[];
const registerEventMock = jest.fn(); const registerEventMock = jest.fn();
@ -231,7 +232,7 @@ describe('Teams integration', () => {
summary: 'Message', summary: 'Message',
sections: [ sections: [
{ {
activityTitle: `*${event.createdBy}* disabled *[${event.featureName}](${ARGS.unleashUrl}/projects/${event.project}/features/${event.featureName})* for the *${event.environment}* environment in project *[${event.project}](${ARGS.unleashUrl}/projects/${event.project})*`, activityTitle: `${bold(event.createdBy)} disabled ${bold(`[${event.featureName}](${ARGS.unleashUrl}/projects/${event.project}/features/${event.featureName})`)} for the ${bold(event.environment)} environment in project ${bold(`[${event.project}](${ARGS.unleashUrl}/projects/${event.project})`)}`,
activitySubtitle: `Unleash notification update`, activitySubtitle: `Unleash notification update`,
facts: [ facts: [
{ {