Skip to content

Commit

Permalink
Fixes court name and unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gudjong committed Oct 22, 2024
1 parent d5d7861 commit 4f8019b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ export const notifications = {
body: {
id: 'judicial.system.backend:notifications.case_files_updated.body',
defaultMessage:
'Ný gögn hafa borist vegna máls {courtCaseNumber}. {userHasAccessToRVG, select, true {Hægt er að nálgast gögn málsins á {linkStart}yfirlitssíðu málsins í Réttarvörslugátt{linkEnd}} other {Hægt er að nálgast gögn málsins hjá {court} ef þau hafa ekki þegar verið afhent}}',
'Ný gögn hafa borist vegna máls {courtCaseNumber}. {userHasAccessToRVG, select, true {Hægt er að nálgast gögn málsins á {linkStart}yfirlitssíðu málsins í Réttarvörslugátt{linkEnd}} other {Hægt er að nálgast gögn málsins hjá {court} ef þau hafa ekki þegar verið afhent}}.',
description: 'Texti í pósti til aðila máls þegar ný gögn eru send',
},
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1766,6 +1766,7 @@ export class InternalNotificationService extends BaseNotificationService {
//#region CASE_FILES_UPDATED notifications
private sendCaseFilesUpdatedNotification(
courtCaseNumber?: string,
court?: string,
link?: string,
name?: string,
email?: string,
Expand All @@ -1775,6 +1776,7 @@ export class InternalNotificationService extends BaseNotificationService {
})
const html = this.formatMessage(notifications.caseFilesUpdated.body, {
courtCaseNumber,
court: court?.replace('dómur', 'dómi'),
userHasAccessToRVG: Boolean(link),
linkStart: `<a href="${link}">`,
linkEnd: '</a>',
Expand All @@ -1790,6 +1792,7 @@ export class InternalNotificationService extends BaseNotificationService {
const promises = [
this.sendCaseFilesUpdatedNotification(
theCase.courtCaseNumber,
theCase.court?.name,
`${this.config.clientUrl}${INDICTMENTS_COURT_OVERVIEW_ROUTE}/${theCase.id}`,
theCase.judge?.name,
theCase.judge?.email,
Expand All @@ -1805,6 +1808,7 @@ export class InternalNotificationService extends BaseNotificationService {
promises.push(
this.sendCaseFilesUpdatedNotification(
theCase.courtCaseNumber,
theCase.court?.name,
civilClaimant.spokespersonNationalId &&
formatDefenderRoute(
this.config.clientUrl,
Expand All @@ -1828,6 +1832,7 @@ export class InternalNotificationService extends BaseNotificationService {
promises.push(
this.sendCaseFilesUpdatedNotification(
theCase.courtCaseNumber,
theCase.court?.name,
defendant.defenderNationalId &&
formatDefenderRoute(
this.config.clientUrl,
Expand All @@ -1846,6 +1851,7 @@ export class InternalNotificationService extends BaseNotificationService {
promises.push(
this.sendCaseFilesUpdatedNotification(
theCase.courtCaseNumber,
theCase.court?.name,
`${this.config.clientUrl}${INDICTMENTS_OVERVIEW_ROUTE}/${theCase.id}`,
theCase.prosecutor?.name,
theCase.prosecutor?.email,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ describe('InternalNotificationController - Send case files updated notifications
const prosecutorEmail = uuid()
const judgeName = uuid()
const judgeEmail = uuid()
const defenderNationalId = uuid()
const defenderName = uuid()
const defenderEmail = uuid()
const spokespersonNationalId = uuid()
const spokespersonName = uuid()
const spokespersonEmail = uuid()
let mockEmailService: EmailService
Expand All @@ -52,11 +54,17 @@ describe('InternalNotificationController - Send case files updated notifications
id: caseId,
type: CaseType.INDICTMENT,
courtCaseNumber,
court: { name: 'Héraðsdómur Reykjavíkur' },
prosecutor: { name: prosecutorName, email: prosecutorEmail },
judge: { name: judgeName, email: judgeEmail },
defendants: [{ defenderName, defenderEmail }],
defendants: [{ defenderNationalId, defenderName, defenderEmail }],
civilClaimants: [
{ hasSpokesperson: true, spokespersonName, spokespersonEmail },
{
hasSpokesperson: true,
spokespersonNationalId,
spokespersonName,
spokespersonEmail,
},
],
} as Case,
{
Expand Down Expand Up @@ -88,11 +96,15 @@ describe('InternalNotificationController - Send case files updated notifications
subject: `Ný gögn í máli ${courtCaseNumber}`,
html: `Ný gögn hafa borist vegna máls ${courtCaseNumber}. Hægt er að nálgast gögn málsins á <a href="http://localhost:4200/domur/akaera/yfirlit/${caseId}">yfirlitssíðu málsins í Réttarvörslugátt</a>.`,
}),
)
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
to: [{ name: spokespersonName, address: spokespersonEmail }],
subject: `Ný gögn í máli ${courtCaseNumber}`,
html: `Ný gögn hafa borist vegna máls ${courtCaseNumber}. Hægt er að nálgast gögn málsins á <a href="http://localhost:4200/verjandi/akaera/${caseId}">yfirlitssíðu málsins í Réttarvörslugátt</a>.`,
}),
)
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
to: [{ name: defenderName, address: defenderEmail }],
subject: `Ný gögn í máli ${courtCaseNumber}`,
Expand All @@ -119,15 +131,19 @@ describe('InternalNotificationController - Send case files updated notifications
subject: `Ný gögn í máli ${courtCaseNumber}`,
html: `Ný gögn hafa borist vegna máls ${courtCaseNumber}. Hægt er að nálgast gögn málsins á <a href="http://localhost:4200/domur/akaera/yfirlit/${caseId}">yfirlitssíðu málsins í Réttarvörslugátt</a>.`,
}),
)
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
to: [{ name: spokespersonName, address: spokespersonEmail }],
subject: `Ný gögn í máli ${courtCaseNumber}`,
html: `Ný gögn hafa borist vegna máls ${courtCaseNumber}. Hægt er að nálgast gögn málsins á <a href="http://localhost:4200/verjandi/akaera/${caseId}">yfirlitssíðu málsins í Réttarvörslugátt</a>.`,
}),
)
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
to: [{ name: prosecutorName, address: prosecutorEmail }],
subject: `Ný gögn í máli ${courtCaseNumber}`,
html: `Ný gögn hafa borist vegna máls ${courtCaseNumber}. Hægt er að nálgast gögn málsins á <a href="http://localhost:4200/akaera/yfirlit/${caseId}">yfirlitssíðu málsins í Réttarvörslugátt</a>.`,
html: `Ný gögn hafa borist vegna máls ${courtCaseNumber}. Hægt er að nálgast gögn málsins á <a href="http://localhost:4200/akaera/stadfesta/${caseId}">yfirlitssíðu málsins í Réttarvörslugátt</a>.`,
}),
)
expect(then.result).toEqual({ delivered: true })
Expand Down

0 comments on commit 4f8019b

Please sign in to comment.