mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-04 00:18:01 +01:00
fix: slack back link url to point to the feature page (#2128)
* fix: slack back link url to point to the feature page * update snapshots * update feature link in case project info is available in event * update missing snapshot
This commit is contained in:
parent
774d4234bb
commit
1d5249eddc
@ -2,6 +2,8 @@
|
||||
|
||||
exports[`Should call datadog webhook for archived toggle 1`] = `"{"text":"%%% \\n some@user.com just archived feature toggle *[some-toggle](http://some-url.com/archive)* \\n %%% ","title":"Unleash notification update"}"`;
|
||||
|
||||
exports[`Should call datadog webhook 1`] = `"{"text":"%%% \\n some@user.com created feature toggle [some-toggle](http://some-url.com/projects//some-toggle) in project *undefined* \\n %%% ","title":"Unleash notification update"}"`;
|
||||
exports[`Should call datadog webhook for archived toggle with project info 1`] = `"{"text":"%%% \\n some@user.com just archived feature toggle *[some-toggle](http://some-url.com/projects/some-project/archive)* \\n %%% ","title":"Unleash notification update"}"`;
|
||||
|
||||
exports[`Should call datadog webhook for toggled environment 1`] = `"{"text":"%%% \\n some@user.com *disabled* [some-toggle](http://some-url.com/projects/default/some-toggle) in *development* environment in project *default* \\n %%% ","title":"Unleash notification update"}"`;
|
||||
exports[`Should call datadog webhook 1`] = `"{"text":"%%% \\n some@user.com created feature toggle [some-toggle](http://some-url.com/projects//features/some-toggle) in project *undefined* \\n %%% ","title":"Unleash notification update"}"`;
|
||||
|
||||
exports[`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) in *development* environment in project *default* \\n %%% ","title":"Unleash notification update"}"`;
|
||||
|
@ -1,7 +1,9 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Should call slack webhook 1`] = `"{"username":"Unleash","icon_emoji":":unleash:","text":"some@user.com created feature toggle <http://some-url.com/projects/default/some-toggle|some-toggle> in project *default*","channel":"#undefined","attachments":[{"actions":[{"name":"featureToggle","text":"Open in Unleash","type":"button","value":"featureToggle","style":"primary","url":"http://some-url.com/projects/default/some-toggle"}]}]}"`;
|
||||
exports[`Should call slack webhook 1`] = `"{"username":"Unleash","icon_emoji":":unleash:","text":"some@user.com created feature toggle <http://some-url.com/projects/default/features/some-toggle|some-toggle> in project *default*","channel":"#undefined","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[`Should call slack webhook for archived toggle 1`] = `"{"username":"Unleash","icon_emoji":":unleash:","text":" some@user.com just archived feature toggle *<http://some-url.com/archive|some-toggle>*","channel":"#undefined","attachments":[{"actions":[{"name":"featureToggle","text":"Open in Unleash","type":"button","value":"featureToggle","style":"primary","url":"http://some-url.com/archive"}]}]}"`;
|
||||
|
||||
exports[`Should call webhook for toggled environment 1`] = `"{"username":"Unleash","icon_emoji":":unleash:","text":"some@user.com *disabled* <http://some-url.com/projects/default/some-toggle|some-toggle> in *development* environment in project *default*","channel":"#undefined","attachments":[{"actions":[{"name":"featureToggle","text":"Open in Unleash","type":"button","value":"featureToggle","style":"primary","url":"http://some-url.com/projects/default/some-toggle"}]}]}"`;
|
||||
exports[`Should call slack webhook for archived toggle with project info 1`] = `"{"username":"Unleash","icon_emoji":":unleash:","text":" some@user.com just archived feature toggle *<http://some-url.com/projects/some-project/archive|some-toggle>*","channel":"#undefined","attachments":[{"actions":[{"name":"featureToggle","text":"Open in Unleash","type":"button","value":"featureToggle","style":"primary","url":"http://some-url.com/projects/some-project/archive"}]}]}"`;
|
||||
|
||||
exports[`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> in *development* environment in project *default*","channel":"#undefined","attachments":[{"actions":[{"name":"featureToggle","text":"Open in Unleash","type":"button","value":"featureToggle","style":"primary","url":"http://some-url.com/projects/default/features/some-toggle"}]}]}"`;
|
||||
|
@ -1,7 +1,9 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Should call teams webhook 1`] = `"{"themeColor":"0076D7","summary":"Message","sections":[{"activityTitle":"some@user.com created feature toggle [some-toggle](http://some-url.com/projects//some-toggle) in project *undefined*","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//some-toggle"}]}]}"`;
|
||||
exports[`Should call teams webhook 1`] = `"{"themeColor":"0076D7","summary":"Message","sections":[{"activityTitle":"some@user.com created feature toggle [some-toggle](http://some-url.com/projects//features/some-toggle) in project *undefined*","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[`Should call teams webhook for archived toggle 1`] = `"{"themeColor":"0076D7","summary":"Message","sections":[{"activityTitle":" some@user.com just archived feature toggle *[some-toggle](http://some-url.com/archive)*","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/archive"}]}]}"`;
|
||||
|
||||
exports[`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/some-toggle) in *development* environment in project *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/some-toggle"}]}]}"`;
|
||||
exports[`Should call teams webhook for archived toggle with project info 1`] = `"{"themeColor":"0076D7","summary":"Message","sections":[{"activityTitle":" some@user.com just archived feature toggle *[some-toggle](http://some-url.com/projects/some-project/archive)*","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[`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) in *development* environment in project *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"}]}]}"`;
|
||||
|
@ -89,6 +89,33 @@ test('Should call datadog webhook for archived toggle', async () => {
|
||||
expect(fetchRetryCalls[0].options.body).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('Should call datadog webhook for archived toggle with project info', async () => {
|
||||
const addon = new DatadogAddon({
|
||||
getLogger: noLogger,
|
||||
unleashUrl: 'http://some-url.com',
|
||||
});
|
||||
const event: IEvent = {
|
||||
id: 2,
|
||||
createdAt: new Date(),
|
||||
type: FEATURE_ARCHIVED,
|
||||
createdBy: 'some@user.com',
|
||||
featureName: 'some-toggle',
|
||||
project: 'some-project',
|
||||
data: {
|
||||
name: 'some-toggle',
|
||||
},
|
||||
};
|
||||
|
||||
const parameters = {
|
||||
url: 'http://api.datadoghq.com/api/v1/events',
|
||||
};
|
||||
|
||||
await addon.handleEvent(event, parameters);
|
||||
expect(fetchRetryCalls.length).toBe(1);
|
||||
expect(fetchRetryCalls[0].url).toBe(parameters.url);
|
||||
expect(fetchRetryCalls[0].options.body).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test(`Should call datadog webhook for toggled environment`, async () => {
|
||||
const addon = new DatadogAddon({
|
||||
getLogger: noLogger,
|
||||
|
@ -98,9 +98,13 @@ export class FeatureEventFormatterMd implements FeatureEventFormatter {
|
||||
featureLink(event: IEvent): string {
|
||||
const { type, project = '', featureName } = event;
|
||||
if (type === FEATURE_ARCHIVED) {
|
||||
if (project) {
|
||||
return `${this.unleashUrl}/projects/${project}/archive`;
|
||||
}
|
||||
return `${this.unleashUrl}/archive`;
|
||||
}
|
||||
return `${this.unleashUrl}/projects/${project}/${featureName}`;
|
||||
|
||||
return `${this.unleashUrl}/projects/${project}/features/${featureName}`;
|
||||
}
|
||||
|
||||
getAction(type: string): string {
|
||||
|
@ -91,6 +91,33 @@ test('Should call slack webhook for archived toggle', async () => {
|
||||
expect(fetchRetryCalls[0].options.body).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('Should call slack webhook for archived toggle with project info', async () => {
|
||||
const addon = new SlackAddon({
|
||||
getLogger: noLogger,
|
||||
unleashUrl: 'http://some-url.com',
|
||||
});
|
||||
const event: IEvent = {
|
||||
id: 2,
|
||||
createdAt: new Date(),
|
||||
type: FEATURE_ARCHIVED,
|
||||
featureName: 'some-toggle',
|
||||
project: 'some-project',
|
||||
createdBy: 'some@user.com',
|
||||
data: {
|
||||
name: 'some-toggle',
|
||||
},
|
||||
};
|
||||
|
||||
const parameters = {
|
||||
url: 'http://hooks.slack.com',
|
||||
};
|
||||
|
||||
await addon.handleEvent(event, parameters);
|
||||
expect(fetchRetryCalls.length).toBe(1);
|
||||
expect(fetchRetryCalls[0].url).toBe(parameters.url);
|
||||
expect(fetchRetryCalls[0].options.body).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test(`Should call webhook for toggled environment`, async () => {
|
||||
const addon = new SlackAddon({
|
||||
getLogger: noLogger,
|
||||
|
@ -69,7 +69,7 @@ test('Should call teams webhook for archived toggle', async () => {
|
||||
getLogger: noLogger,
|
||||
unleashUrl: 'http://some-url.com',
|
||||
});
|
||||
const event = {
|
||||
const event: IEvent = {
|
||||
id: 1,
|
||||
createdAt: new Date(),
|
||||
type: FEATURE_ARCHIVED,
|
||||
@ -90,6 +90,33 @@ test('Should call teams webhook for archived toggle', async () => {
|
||||
expect(fetchRetryCalls[0].options.body).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('Should call teams webhook for archived toggle with project info', async () => {
|
||||
const addon = new TeamsAddon({
|
||||
getLogger: noLogger,
|
||||
unleashUrl: 'http://some-url.com',
|
||||
});
|
||||
const event: IEvent = {
|
||||
id: 1,
|
||||
createdAt: new Date(),
|
||||
type: FEATURE_ARCHIVED,
|
||||
createdBy: 'some@user.com',
|
||||
featureName: 'some-toggle',
|
||||
project: 'some-project',
|
||||
data: {
|
||||
name: 'some-toggle',
|
||||
},
|
||||
};
|
||||
|
||||
const parameters = {
|
||||
url: 'http://hooks.office.com',
|
||||
};
|
||||
|
||||
await addon.handleEvent(event, parameters);
|
||||
expect(fetchRetryCalls.length).toBe(1);
|
||||
expect(fetchRetryCalls[0].url).toBe(parameters.url);
|
||||
expect(fetchRetryCalls[0].options.body).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test(`Should call teams webhook for toggled environment`, async () => {
|
||||
const addon = new TeamsAddon({
|
||||
getLogger: noLogger,
|
||||
|
Loading…
Reference in New Issue
Block a user