-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(j-s): send criminal records to public prosecutor static email (#…
…17406) * feat(j-s): add criminal record files uploaded when submiting case to public prosecutor * chroe(j-s): add tests for criminal record notification * chore(j-s): add parameter for email secret in all env and adjust email assignment logic * chore: charts update dirty files * fix(j-s): clean-up * fix(j-s): format * fix(j-s): Remove unused import --------- Co-authored-by: andes-it <[email protected]> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
- Loading branch information
1 parent
7f6cb5f
commit fd4a86b
Showing
15 changed files
with
215 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
.../indictmentCaseNotification/sendIndictmentCriminalRecordFilesUploadedNotification.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import { uuid } from 'uuidv4' | ||
|
||
import { EmailService } from '@island.is/email-service' | ||
import { ConfigType } from '@island.is/nest/config' | ||
|
||
import { IndictmentCaseNotificationType } from '@island.is/judicial-system/types' | ||
|
||
import { createTestingNotificationModule } from '../../createTestingNotificationModule' | ||
|
||
import { Case } from '../../../../case' | ||
import { DeliverResponse } from '../../../models/deliver.response' | ||
import { notificationModuleConfig } from '../../../notification.config' | ||
|
||
interface Then { | ||
result: DeliverResponse | ||
error: Error | ||
} | ||
|
||
type GivenWhenThen = ( | ||
theCase: Case, | ||
notificationType: IndictmentCaseNotificationType, | ||
) => Promise<Then> | ||
|
||
describe('IndictmentCaseService', () => { | ||
const caseId = uuid() | ||
const courtName = uuid() | ||
|
||
const courtCaseNumber = uuid() | ||
const theCase = { | ||
id: caseId, | ||
court: { name: courtName }, | ||
courtCaseNumber, | ||
} as Case | ||
|
||
let mockEmailService: EmailService | ||
let mockConfig: ConfigType<typeof notificationModuleConfig> | ||
let givenWhenThen: GivenWhenThen | ||
|
||
beforeEach(async () => { | ||
process.env.PUBLIC_PROSECUTOR_CRIMINAL_RECORDS_EMAIL = | ||
'[email protected]' | ||
|
||
const { | ||
emailService, | ||
notificationConfig, | ||
indictmentCaseNotificationService, | ||
} = await createTestingNotificationModule() | ||
|
||
mockEmailService = emailService | ||
mockConfig = notificationConfig | ||
|
||
givenWhenThen = async ( | ||
theCase: Case, | ||
notificationType: IndictmentCaseNotificationType, | ||
) => { | ||
const then = {} as Then | ||
|
||
await indictmentCaseNotificationService | ||
.sendIndictmentCaseNotification(notificationType, theCase) | ||
.then((result) => (then.result = result)) | ||
.catch((error) => (then.error = error)) | ||
|
||
return then | ||
} | ||
}) | ||
|
||
describe('notification sent to public prosecutor criminal records secretary', () => { | ||
it('should send notification', async () => { | ||
const then = await givenWhenThen( | ||
theCase, | ||
IndictmentCaseNotificationType.CRIMINAL_RECORD_FILES_UPLOADED, | ||
) | ||
|
||
expect(mockEmailService.sendEmail).toBeCalledWith( | ||
expect.objectContaining({ | ||
to: [ | ||
{ | ||
name: 'Ritari sakaskrár', | ||
address: mockConfig.email.publicProsecutorCriminalRecordsEmail, | ||
}, | ||
], | ||
subject: expect.stringContaining( | ||
`Tilkynning til sakaskrár í máli ${courtCaseNumber}`, | ||
), | ||
html: expect.stringContaining( | ||
`Máli ${courtCaseNumber} hjá ${courtName} hefur verið lokið.`, | ||
), | ||
}), | ||
) | ||
expect(then.result).toEqual({ delivered: true }) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters