Skip to content

Commit 7c43897

Browse files
committed
fix: fix breaking notifications with excluded documents
1 parent 8dc87d0 commit 7c43897

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

lib/api/Notification.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,18 @@ export class Notification {
3333
const subjectTemplate = Handlebars.compile(this._configuration.notificationSubjectTemplate)
3434
const bodyTemplate = Handlebars.compile(this._configuration.notificationBodyTemplate)
3535

36-
for (const documentInfo of documentInfos) {
36+
process: for (const documentInfo of documentInfos) {
3737
for (const exception of this._configuration.exceptions) {
3838
if (documentInfo.matchesPath(exception)) {
3939
this._log.info(`Skipping ${documentInfo.title} because it matches the exception ${exception}`)
40-
return
40+
continue process
4141
}
4242
}
4343

4444
for (const excludedLabel of this._configuration.excludedLabels) {
4545
if (documentInfo.labels.some((label) => label.toLowerCase() == excludedLabel.toLowerCase())) {
4646
this._log.info(`Skipping ${documentInfo.title} because it has the excluded label ${excludedLabel}`)
47-
return
47+
continue process
4848
}
4949
}
5050

test/NotificationTest.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@ describe('The Notification API', (): void => {
164164
it('should not send notifications for a document excluded by label', async (): Promise<void> => {
165165
const notification = new Notification(configuration, '', confluence, transportStub)
166166
const documentInfo = new DocumentInfo(0, 'author2', moment(), 'message', 'Title', ['main'], 'http://example.com', 'test', ['not'])
167-
await notification.notify([documentInfo])
168-
chai.expect((transportStub as unknown as SinonStubbedInstance<Mail>).sendMail.calledOnce).to.be.false
167+
const documentInfoValid = new DocumentInfo(0, 'author2', moment(), 'message', 'Title', ['main'], 'http://example.com', 'test', [])
168+
await notification.notify([documentInfo, documentInfoValid])
169+
chai.expect((transportStub as unknown as SinonStubbedInstance<Mail>).sendMail.calledOnce).to.be.true
170+
chai.expect((transportStub as unknown as SinonStubbedInstance<Mail>).sendMail.calledTwice).to.be.false
169171
})
170172
})

0 commit comments

Comments
 (0)