Added test to slack-notifications to check for correct reason when value too far from milestone

This commit is contained in:
Aileen Nowak 2023-02-23 16:35:37 +02:00 committed by Aileen Booker
parent 086da740a2
commit 61e7cd644b

View File

@ -240,6 +240,74 @@ describe('SlackNotifications', function () {
assert(sendStub.calledOnce === true);
assert(sendStub.calledWith(expectedResult, 'https://slack-webhook.example') === true);
});
it('Shows the correct reason for email not send when last milestone is too far from actual value', async function () {
await slackNotifications.notifyMilestoneReceived({
milestone: {
id: ObjectId().toHexString(),
name: 'members-1000',
type: 'members',
createdAt: '2023-02-15T00:00:00.000Z',
emailSentAt: null,
value: 1000
},
meta: {
currentValue: 1105,
reason: 'tooFar'
}
});
const expectedResult = {
unfurl_links: false,
username: 'Ghost Milestone Service',
attachments: [{
color: '#36a64f',
blocks: [
{
type: 'header',
text: {
type: 'plain_text',
text: ':tada: Members Milestone 1,000 reached!',
emoji: true
}
},
{
type: 'section',
text: {
type: 'mrkdwn',
text: 'New *Members Milestone* achieved for <https://ghost.example|https://ghost.example>'
}
},
{
type: 'divider'
},
{
type: 'section',
fields: [
{
type: 'mrkdwn',
text: '*Milestone:*\n1,000'
},
{
type: 'mrkdwn',
text: '*Current Members:*\n1,105'
}
]
},
{
type: 'section',
text: {
type: 'mrkdwn',
text: '*Email sent:*\nno / too far from milestone'
}
}
]
}]
};
assert(sendStub.calledOnce === true);
assert(sendStub.calledWith(expectedResult, 'https://slack-webhook.example') === true);
});
});
describe('send', function () {