{defenderHasAccessToRVG, select, true {Gögn málsins eru aðgengileg á {linkStart}yfirlitssíðu málsins í Réttarvörslugátt{linkEnd}} other {Þú getur nálgast gögn málsins hjá {courtName} ef þau hafa ekki þegar verið afhent}}.',
+ description: 'Texti í pósti til verjanda þegar hann er skráður á mál.',
+ },
+ bodyAccess: {
+ id: 'judicial.system.backend:notifications.defender_assigned_email.body_access',
+ defaultMessage:
+ '{court} hefur skráð þig {advocateType, select, LAWYER {lögmann einkaréttarkröfuhafa} LEGAL_RIGHTS_PROTECTOR {réttargæslumann einkaréttarkröfuhafa} other {verjanda}} í máli {courtCaseNumber}.
Sjá nánar á yfirlitssíðu málsins í Réttarvörslugátt.`,
+ })
+ })
+ })
+
+ describe('when the case has civil claims and the advocate is a legal rights protector', () => {
+ const caseId = uuid()
+ const civilClaimant = {
+ hasSpokesperson: true,
+ spokespersonNationalId: '1234567890',
+ spokespersonEmail: 'recipient@gmail.com',
+ spokespersonName: 'John Doe',
+ spokespersonIsLawyer: false,
+ }
+ const theCase = {
+ id: caseId,
+ type: CaseType.INDICTMENT,
+ court,
+ courtCaseNumber: 'S-123/2022',
+ civilClaimants: [civilClaimant],
+ } as Case
+
+ beforeEach(async () => {
+ await givenWhenThen(caseId, theCase, notificationDTO)
+ })
+
+ it('should send correct email', () => {
+ expect(mockEmailService.sendEmail).toHaveBeenCalledTimes(1)
+ expect(mockEmailService.sendEmail).toHaveBeenCalledWith({
+ from: {
+ name: mockConfig.email.fromName,
+ address: mockConfig.email.fromEmail,
+ },
+ to: [
+ {
+ name: civilClaimant.spokespersonName,
+ address: civilClaimant.spokespersonEmail,
+ },
+ ],
+ replyTo: {
+ name: mockConfig.email.replyToName,
+ address: mockConfig.email.replyToEmail,
+ },
+ attachments: undefined,
+ subject: `Skráning í máli ${theCase.courtCaseNumber}`,
+ text: expect.anything(), // same as html but stripped html tags
+ html: `Héraðsdómur Reykjavíkur hefur skráð þig réttargæslumann einkaréttarkröfuhafa í máli ${theCase.courtCaseNumber}.
Sjá nánar á yfirlitssíðu málsins í Réttarvörslugátt.`,
+ })
+ })
+ })
+
+ describe('when the case has civil claims and civil claimant does not have representation', () => {
+ const caseId = uuid()
+ const civilClaimant = {
+ hasSpokesperson: false,
+ }
+ const theCase = {
+ id: caseId,
+ type: CaseType.INDICTMENT,
+ court,
+ courtCaseNumber: 'S-123/2022',
+ civilClaimants: [civilClaimant],
+ } as Case
+
+ beforeEach(async () => {
+ await givenWhenThen(caseId, theCase, notificationDTO)
+ })
+
+ it('should send correct email', () => {
+ expect(mockEmailService.sendEmail).not.toHaveBeenCalled()
+ })
+ })
+
describe('when sending assigned defender notifications in a restriction case', () => {
const caseId = uuid()
const theCase = {
@@ -89,8 +204,8 @@ describe('InternalNotificationController - Send defender assigned notifications'
type: CaseType.ADMISSION_TO_FACILITY,
court,
courtCaseNumber: 'R-123/2022',
- defenderEmail: defender.email,
- defenderName: defender.name,
+ defenderEmail: 'recipient@gmail.com',
+ defenderName: 'John Doe',
defenderNationalId: '1234567890',
dateLogs: [{ date: new Date(), dateType: DateType.ARRAIGNMENT_DATE }],
} as Case
@@ -131,8 +246,8 @@ describe('InternalNotificationController - Send defender assigned notifications'
type: CaseType.ADMISSION_TO_FACILITY,
court,
courtCaseNumber: 'R-123/2022',
- defenderEmail: defender.email,
- defenderName: defender.name,
+ defenderEmail: 'recipient@gmail.com',
+ defenderName: 'John Doe',
dateLogs: [{ date: new Date(), dateType: DateType.ARRAIGNMENT_DATE }],
} as Case
@@ -172,8 +287,8 @@ describe('InternalNotificationController - Send defender assigned notifications'
type: CaseType.PHONE_TAPPING,
court,
courtCaseNumber: 'R-123/2022',
- defenderEmail: defender.email,
- defenderName: defender.name,
+ defenderEmail: 'recipient@gmail.com',
+ defenderName: 'John Doe',
dateLogs: [{ date: new Date(), dateType: DateType.ARRAIGNMENT_DATE }],
} as Case
diff --git a/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAppealCompletedNotifications.spec.ts b/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAppealCompletedNotifications.spec.ts
index df4807508115..bc9c0a684778 100644
--- a/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAppealCompletedNotifications.spec.ts
+++ b/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAppealCompletedNotifications.spec.ts
@@ -12,10 +12,7 @@ import {
User,
} from '@island.is/judicial-system/types'
-import {
- createTestingNotificationModule,
- createTestUsers,
-} from '../createTestingNotificationModule'
+import { createTestingNotificationModule } from '../createTestingNotificationModule'
import { Case } from '../../../case'
import { DeliverResponse } from '../../models/deliver.response'
@@ -32,24 +29,25 @@ type GivenWhenThen = (
) => Promise
describe('InternalNotificationController - Send appeal completed notifications', () => {
- const { prosecutor, defender, judge, courtOfAppeals } = createTestUsers([
- 'prosecutor',
- 'defender',
- 'judge',
- 'courtOfAppeals',
- ])
const userId = uuid()
const caseId = uuid()
+ const prosecutorName = uuid()
+ const prosecutorEmail = uuid()
+ const defenderName = uuid()
+ const defenderEmail = uuid()
+ const judgeName = uuid()
+ const judgeEmail = uuid()
const courtCaseNumber = uuid()
const appealCaseNumber = uuid()
const courtId = uuid()
+ const courtOfAppealsEmail = uuid()
let mockEmailService: EmailService
let mockConfig: ConfigType
let givenWhenThen: GivenWhenThen
beforeEach(async () => {
- process.env.COURTS_EMAILS = `{"4676f08b-aab4-4b4f-a366-697540788088":"${courtOfAppeals.email}"}`
+ process.env.COURTS_EMAILS = `{"4676f08b-aab4-4b4f-a366-697540788088":"${courtOfAppealsEmail}"}`
const { emailService, notificationConfig, internalNotificationController } =
await createTestingNotificationModule()
@@ -73,12 +71,12 @@ describe('InternalNotificationController - Send appeal completed notifications',
decision: CaseDecision.ACCEPTING,
appealRulingDecision:
appealRulingDecision ?? CaseAppealRulingDecision.ACCEPTING,
- prosecutor: { name: prosecutor.name, email: prosecutor.email },
- judge: { name: judge.name, email: judge.email },
+ prosecutor: { name: prosecutorName, email: prosecutorEmail },
+ judge: { name: judgeName, email: judgeEmail },
court: { name: 'Héraðsdómur Reykjavíkur' },
defenderNationalId,
- defenderName: defender.name,
- defenderEmail: defender.email,
+ defenderName: defenderName,
+ defenderEmail: defenderEmail,
courtCaseNumber,
appealCaseNumber,
courtId: courtId,
@@ -104,14 +102,14 @@ describe('InternalNotificationController - Send appeal completed notifications',
it('should send notifications', () => {
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: judge.name, address: judge.email }],
+ to: [{ name: judgeName, address: judgeEmail }],
subject: `Úrskurður í landsréttarmáli ${appealCaseNumber} (${courtCaseNumber})`,
html: `Landsréttur hefur úrskurðað í máli ${appealCaseNumber} (héraðsdómsmál nr. ${courtCaseNumber}). Niðurstaða Landsréttar: Staðfest. Hægt er að nálgast gögn málsins á yfirlitssíðu málsins í Réttarvörslugátt.`,
}),
)
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: prosecutor.name, address: prosecutor.email }],
+ to: [{ name: prosecutorName, address: prosecutorEmail }],
subject: `Úrskurður í landsréttarmáli ${appealCaseNumber} (${courtCaseNumber})`,
html: `Landsréttur hefur úrskurðað í máli ${appealCaseNumber} (héraðsdómsmál nr. ${courtCaseNumber}). Niðurstaða Landsréttar: Staðfest. Hægt er að nálgast gögn málsins á yfirlitssíðu málsins í Réttarvörslugátt.`,
}),
@@ -142,7 +140,7 @@ describe('InternalNotificationController - Send appeal completed notifications',
)
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: defender.name, address: defender.email }],
+ to: [{ name: defenderName, address: defenderEmail }],
subject: `Úrskurður í landsréttarmáli ${appealCaseNumber} (${courtCaseNumber})`,
html: `Landsréttur hefur úrskurðað í máli ${appealCaseNumber} (héraðsdómsmál nr. ${courtCaseNumber}). Niðurstaða Landsréttar: Staðfest. Hægt er að nálgast gögn málsins á yfirlitssíðu málsins í Réttarvörslugátt.`,
}),
@@ -161,7 +159,7 @@ describe('InternalNotificationController - Send appeal completed notifications',
it('should send notification without a link to defender', () => {
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: defender.name, address: defender.email }],
+ to: [{ name: defenderName, address: defenderEmail }],
subject: `Úrskurður í landsréttarmáli ${appealCaseNumber} (${courtCaseNumber})`,
html: `Landsréttur hefur úrskurðað í máli ${appealCaseNumber} (héraðsdómsmál nr. ${courtCaseNumber}). Niðurstaða Landsréttar: Staðfest. Hægt er að nálgast gögn málsins hjá Héraðsdómi Reykjavíkur ef þau hafa ekki þegar verið afhent.`,
}),
@@ -180,14 +178,14 @@ describe('InternalNotificationController - Send appeal completed notifications',
it('should send notification about discontinuance', () => {
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: prosecutor.name, address: prosecutor.email }],
+ to: [{ name: prosecutorName, address: prosecutorEmail }],
subject: `Niðurfelling máls ${appealCaseNumber} (${courtCaseNumber})`,
html: `Landsréttur hefur móttekið afturköllun á kæru í máli ${courtCaseNumber}. Landsréttarmálið ${appealCaseNumber} hefur verið fellt niður. Hægt er að nálgast yfirlitssíðu málsins á rettarvorslugatt.island.is.`,
}),
)
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: defender.name, address: defender.email }],
+ to: [{ name: defenderName, address: defenderEmail }],
subject: `Niðurfelling máls ${appealCaseNumber} (${courtCaseNumber})`,
html: `Landsréttur hefur móttekið afturköllun á kæru í máli ${courtCaseNumber}. Landsréttarmálið ${appealCaseNumber} hefur verið fellt niður.`,
}),
diff --git a/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAppealFilesUpdatedNotifications.spec.ts b/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAppealFilesUpdatedNotifications.spec.ts
index d50f5d2a5707..1cc6f4f9e31a 100644
--- a/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAppealFilesUpdatedNotifications.spec.ts
+++ b/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAppealFilesUpdatedNotifications.spec.ts
@@ -8,10 +8,7 @@ import {
UserRole,
} from '@island.is/judicial-system/types'
-import {
- createTestingNotificationModule,
- createTestUsers,
-} from '../createTestingNotificationModule'
+import { createTestingNotificationModule } from '../createTestingNotificationModule'
import { Case } from '../../../case'
import { DeliverResponse } from '../../models/deliver.response'
@@ -24,17 +21,22 @@ interface Then {
type GivenWhenThen = (defenderNationalId?: string) => Promise
describe('InternalNotificationController - Send appeal case files updated notifications', () => {
- const { assistant, judge1, judge2, judge3 } = createTestUsers([
- 'assistant',
- 'judge1',
- 'judge2',
- 'judge3',
- ])
const userId = uuid()
const caseId = uuid()
const courtCaseNumber = uuid()
const appealCaseNumber = uuid()
const receivedDate = new Date()
+ const assistantName = uuid()
+ const assistantEmail = uuid()
+ const judgeName1 = uuid()
+ const judgeEmail1 = uuid()
+ const judgeId1 = uuid()
+ const judgeName2 = uuid()
+ const judgeEmail2 = uuid()
+ const judgeId2 = uuid()
+ const judgeName3 = uuid()
+ const judgeEmail3 = uuid()
+ const judgeId3 = uuid()
let mockEmailService: EmailService
let givenWhenThen: GivenWhenThen
@@ -57,26 +59,27 @@ describe('InternalNotificationController - Send appeal case files updated notifi
appealCaseNumber,
appealReceivedByCourtDate: receivedDate,
appealAssistant: {
- name: assistant.name,
- email: assistant.email,
+ name: assistantName,
+ email: assistantEmail,
role: UserRole.COURT_OF_APPEALS_ASSISTANT,
},
appealJudge1: {
- name: judge1.name,
- email: judge1.email,
- id: judge1.id,
+ name: judgeName1,
+ email: judgeEmail1,
+ id: judgeId1,
role: UserRole.COURT_OF_APPEALS_JUDGE,
},
+ appealJudge1Id: judgeId1,
appealJudge2: {
- name: judge2.name,
- email: judge2.email,
- id: judge2.id,
+ name: judgeName2,
+ email: judgeEmail2,
+ id: judgeId2,
role: UserRole.COURT_OF_APPEALS_JUDGE,
},
appealJudge3: {
- name: judge3.name,
- email: judge3.email,
- id: judge3.id,
+ name: judgeName3,
+ email: judgeEmail3,
+ id: judgeId3,
role: UserRole.COURT_OF_APPEALS_JUDGE,
},
} as Case,
@@ -101,7 +104,7 @@ describe('InternalNotificationController - Send appeal case files updated notifi
it('should send notification to the assigned court of appeal judges and assistant', () => {
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: assistant.name, address: assistant.email }],
+ to: [{ name: assistantName, address: assistantEmail }],
subject: `Ný gögn í máli ${courtCaseNumber} (${appealCaseNumber})`,
html: `Ný gögn hafa borist vegna kæru í máli ${courtCaseNumber} (Landsréttarmál nr. ${appealCaseNumber}). Hægt er að nálgast gögn málsins á yfirlitssíðu málsins í Réttarvörslugátt.`,
}),
@@ -110,8 +113,8 @@ describe('InternalNotificationController - Send appeal case files updated notifi
expect.objectContaining({
to: [
{
- name: judge1.name,
- address: judge1.email,
+ name: judgeName1,
+ address: judgeEmail1,
},
],
subject: `Ný gögn í máli ${courtCaseNumber} (${appealCaseNumber})`,
@@ -120,14 +123,14 @@ describe('InternalNotificationController - Send appeal case files updated notifi
)
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: judge2.name, address: judge2.email }],
+ to: [{ name: judgeName2, address: judgeEmail2 }],
subject: `Ný gögn í máli ${courtCaseNumber} (${appealCaseNumber})`,
html: `Ný gögn hafa borist vegna kæru í máli ${courtCaseNumber} (Landsréttarmál nr. ${appealCaseNumber}). Hægt er að nálgast gögn málsins á yfirlitssíðu málsins í Réttarvörslugátt.`,
}),
)
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: judge3.name, address: judge3.email }],
+ to: [{ name: judgeName3, address: judgeEmail3 }],
subject: `Ný gögn í máli ${courtCaseNumber} (${appealCaseNumber})`,
html: `Ný gögn hafa borist vegna kæru í máli ${courtCaseNumber} (Landsréttarmál nr. ${appealCaseNumber}). Hægt er að nálgast gögn málsins á yfirlitssíðu málsins í Réttarvörslugátt.`,
}),
diff --git a/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAppealJudgesAssignedNotifications.spec.ts b/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAppealJudgesAssignedNotifications.spec.ts
index cf73dbe84fcd..b455d775f174 100644
--- a/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAppealJudgesAssignedNotifications.spec.ts
+++ b/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAppealJudgesAssignedNotifications.spec.ts
@@ -8,10 +8,7 @@ import {
UserRole,
} from '@island.is/judicial-system/types'
-import {
- createTestingNotificationModule,
- createTestUsers,
-} from '../createTestingNotificationModule'
+import { createTestingNotificationModule } from '../createTestingNotificationModule'
import { Case } from '../../../case'
import { DeliverResponse } from '../../models/deliver.response'
@@ -24,16 +21,21 @@ interface Then {
type GivenWhenThen = (defenderNationalId?: string) => Promise
describe('InternalNotificationController - Send appeal judges assigned notifications', () => {
- const { judge1, judge2, judge3, assistant } = createTestUsers([
- 'judge1',
- 'judge2',
- 'judge3',
- 'assistant',
- ])
const userId = uuid()
const caseId = uuid()
const appealCaseNumber = uuid()
const receivedDate = new Date()
+ const assistantName = uuid()
+ const assistantEmail = uuid()
+ const judgeName1 = uuid()
+ const judgeEmail1 = uuid()
+ const judgeId1 = uuid()
+ const judgeName2 = uuid()
+ const judgeEmail2 = uuid()
+ const judgeId2 = uuid()
+ const judgeName3 = uuid()
+ const judgeEmail3 = uuid()
+ const judgeId3 = uuid()
let mockEmailService: EmailService
let givenWhenThen: GivenWhenThen
@@ -55,27 +57,27 @@ describe('InternalNotificationController - Send appeal judges assigned notificat
appealCaseNumber,
appealReceivedByCourtDate: receivedDate,
appealAssistant: {
- name: assistant.name,
- email: assistant.email,
+ name: assistantName,
+ email: assistantEmail,
role: UserRole.COURT_OF_APPEALS_ASSISTANT,
},
appealJudge1: {
- name: judge1.name,
- email: judge1.email,
- id: judge1.id,
+ name: judgeName1,
+ email: judgeEmail1,
+ id: judgeId1,
role: UserRole.COURT_OF_APPEALS_JUDGE,
},
- appealJudge1Id: judge1.id,
+ appealJudge1Id: judgeId1,
appealJudge2: {
- name: judge2.name,
- email: judge2.email,
- id: judge2.id,
+ name: judgeName2,
+ email: judgeEmail2,
+ id: judgeId2,
role: UserRole.COURT_OF_APPEALS_JUDGE,
},
appealJudge3: {
- name: judge3.name,
- email: judge3.email,
- id: judge3.id,
+ name: judgeName3,
+ email: judgeEmail3,
+ id: judgeId3,
role: UserRole.COURT_OF_APPEALS_JUDGE,
},
} as Case,
@@ -100,17 +102,17 @@ describe('InternalNotificationController - Send appeal judges assigned notificat
it('should send notification to the judge foreperson, the two other judges and the judges assistant', () => {
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: assistant.name, address: assistant.email }],
+ to: [{ name: assistantName, address: assistantEmail }],
subject: `Úthlutun máls nr. ${appealCaseNumber}`,
- html: `Landsréttur hefur skráð þig sem aðstoðarmann dómara í máli nr. ${appealCaseNumber}. Dómsformaður er ${judge1.name}. Þú getur nálgast yfirlit málsins á yfirlitssíðu málsins í Réttarvörslugátt.`,
+ html: `Landsréttur hefur skráð þig sem aðstoðarmann dómara í máli nr. ${appealCaseNumber}. Dómsformaður er ${judgeName1}. Þú getur nálgast yfirlit málsins á yfirlitssíðu málsins í Réttarvörslugátt.`,
}),
)
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
to: [
{
- name: judge1.name,
- address: judge1.email,
+ name: judgeName1,
+ address: judgeEmail1,
},
],
subject: `Úthlutun máls nr. ${appealCaseNumber}`,
@@ -119,16 +121,16 @@ describe('InternalNotificationController - Send appeal judges assigned notificat
)
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: judge2.name, address: judge2.email }],
+ to: [{ name: judgeName2, address: judgeEmail2 }],
subject: `Úthlutun máls nr. ${appealCaseNumber}`,
- html: `Landsréttur hefur skráð þig sem dómara í máli nr. ${appealCaseNumber}. Dómsformaður er ${judge1.name}. Þú getur nálgast yfirlit málsins á yfirlitssíðu málsins í Réttarvörslugátt.`,
+ html: `Landsréttur hefur skráð þig sem dómara í máli nr. ${appealCaseNumber}. Dómsformaður er ${judgeName1}. Þú getur nálgast yfirlit málsins á yfirlitssíðu málsins í Réttarvörslugátt.`,
}),
)
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: judge3.name, address: judge3.email }],
+ to: [{ name: judgeName3, address: judgeEmail3 }],
subject: `Úthlutun máls nr. ${appealCaseNumber}`,
- html: `Landsréttur hefur skráð þig sem dómara í máli nr. ${appealCaseNumber}. Dómsformaður er ${judge1.name}. Þú getur nálgast yfirlit málsins á yfirlitssíðu málsins í Réttarvörslugátt.`,
+ html: `Landsréttur hefur skráð þig sem dómara í máli nr. ${appealCaseNumber}. Dómsformaður er ${judgeName1}. Þú getur nálgast yfirlit málsins á yfirlitssíðu málsins í Réttarvörslugátt.`,
}),
)
expect(then.result).toEqual({ delivered: true })
diff --git a/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAppealReceivedByCourtNotifications.spec.ts b/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAppealReceivedByCourtNotifications.spec.ts
index 96a4f7fe0016..27a132aa27a7 100644
--- a/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAppealReceivedByCourtNotifications.spec.ts
+++ b/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAppealReceivedByCourtNotifications.spec.ts
@@ -10,10 +10,7 @@ import {
User,
} from '@island.is/judicial-system/types'
-import {
- createTestingNotificationModule,
- createTestUsers,
-} from '../createTestingNotificationModule'
+import { createTestingNotificationModule } from '../createTestingNotificationModule'
import { Case } from '../../../case'
import { DeliverResponse } from '../../models/deliver.response'
@@ -26,14 +23,14 @@ interface Then {
type GivenWhenThen = (defenderNationalId?: string) => Promise
describe('InternalNotificationController - Send appeal received by court notifications', () => {
- const { coa, defender, prosecutor } = createTestUsers([
- 'coa',
- 'defender',
- 'prosecutor',
- ])
-
+ const courtOfAppealsEmail = uuid()
const userId = uuid()
const caseId = uuid()
+ const prosecutorName = uuid()
+ const prosecutorEmail = uuid()
+ const prosecutorMobileNumber = uuid()
+ const defenderName = uuid()
+ const defenderEmail = uuid()
const courtCaseNumber = uuid()
const receivedDate = new Date()
@@ -43,7 +40,7 @@ describe('InternalNotificationController - Send appeal received by court notific
let givenWhenThen: GivenWhenThen
beforeEach(async () => {
- process.env.COURTS_EMAILS = `{"4676f08b-aab4-4b4f-a366-697540788088":"${coa.email}"}`
+ process.env.COURTS_EMAILS = `{"4676f08b-aab4-4b4f-a366-697540788088":"${courtOfAppealsEmail}"}`
const { emailService, smsService, internalNotificationController } =
await createTestingNotificationModule()
@@ -60,14 +57,14 @@ describe('InternalNotificationController - Send appeal received by court notific
{
id: caseId,
prosecutor: {
- name: prosecutor.name,
- email: prosecutor.email,
- mobileNumber: prosecutor.mobile,
+ name: prosecutorName,
+ email: prosecutorEmail,
+ mobileNumber: prosecutorMobileNumber,
},
court: { name: 'Héraðsdómur Reykjavíkur' },
defenderNationalId,
- defenderName: defender.name,
- defenderEmail: defender.email,
+ defenderName: defenderName,
+ defenderEmail: defenderEmail,
courtCaseNumber,
appealReceivedByCourtDate: receivedDate,
} as Case,
@@ -95,7 +92,7 @@ describe('InternalNotificationController - Send appeal received by court notific
to: [
{
name: 'Landsréttur',
- address: coa.email,
+ address: courtOfAppealsEmail,
},
],
subject: `Upplýsingar vegna kæru í máli ${courtCaseNumber}`,
@@ -107,7 +104,7 @@ describe('InternalNotificationController - Send appeal received by court notific
)
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: prosecutor.name, address: prosecutor.email }],
+ to: [{ name: prosecutorName, address: prosecutorEmail }],
subject: `Upplýsingar vegna kæru í máli ${courtCaseNumber}`,
html: `Kæra í máli ${courtCaseNumber} hefur borist Landsrétti. Frestur til að skila greinargerð er til ${formatDate(
getStatementDeadline(receivedDate),
@@ -117,7 +114,7 @@ describe('InternalNotificationController - Send appeal received by court notific
)
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: defender.name, address: defender.email }],
+ to: [{ name: defenderName, address: defenderEmail }],
subject: `Upplýsingar vegna kæru í máli ${courtCaseNumber}`,
html: `Kæra í máli ${courtCaseNumber} hefur borist Landsrétti. Frestur til að skila greinargerð er til ${formatDate(
getStatementDeadline(receivedDate),
@@ -130,7 +127,7 @@ describe('InternalNotificationController - Send appeal received by court notific
it('should send sms notification to prosecutor', () => {
expect(mockSmsService.sendSms).toHaveBeenCalledWith(
- [prosecutor.mobile],
+ [prosecutorMobileNumber],
`Kæra í máli ${courtCaseNumber} hefur borist Landsrétti. Frestur til að skila greinargerð er til ${formatDate(
getStatementDeadline(receivedDate),
'PPPp',
@@ -149,7 +146,7 @@ describe('InternalNotificationController - Send appeal received by court notific
it('should send notification to prosecutor and defender', () => {
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: prosecutor.name, address: prosecutor.email }],
+ to: [{ name: prosecutorName, address: prosecutorEmail }],
subject: `Upplýsingar vegna kæru í máli ${courtCaseNumber}`,
html: `Kæra í máli ${courtCaseNumber} hefur borist Landsrétti. Frestur til að skila greinargerð er til ${formatDate(
getStatementDeadline(receivedDate),
@@ -159,7 +156,7 @@ describe('InternalNotificationController - Send appeal received by court notific
)
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: defender.name, address: defender.email }],
+ to: [{ name: defenderName, address: defenderEmail }],
subject: `Upplýsingar vegna kæru í máli ${courtCaseNumber}`,
html: `Kæra í máli ${courtCaseNumber} hefur borist Landsrétti. Frestur til að skila greinargerð er til ${formatDate(
getStatementDeadline(receivedDate),
diff --git a/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAppealStatementNotifications.spec.ts b/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAppealStatementNotifications.spec.ts
index a920284e6a9e..0f043505f796 100644
--- a/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAppealStatementNotifications.spec.ts
+++ b/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAppealStatementNotifications.spec.ts
@@ -9,10 +9,7 @@ import {
UserRole,
} from '@island.is/judicial-system/types'
-import {
- createTestingNotificationModule,
- createTestUsers,
-} from '../createTestingNotificationModule'
+import { createTestingNotificationModule } from '../createTestingNotificationModule'
import { Case } from '../../../case'
import { DeliverResponse } from '../../models/deliver.response'
@@ -29,22 +26,22 @@ type GivenWhenThen = (
) => Promise
describe('InternalNotificationController - Send appeal statement notifications', () => {
- const roles = [
- 'prosecutor',
- 'defender',
- 'assistant',
- 'judge1',
- 'judge2',
- 'judge3',
- ]
-
- const { prosecutor, defender, assistant, judge1, judge2, judge3 } =
- createTestUsers(roles)
-
const caseId = uuid()
+ const prosecutorName = uuid()
+ const prosecutorEmail = uuid()
+ const defenderName = uuid()
+ const defenderEmail = uuid()
const courtCaseNumber = uuid()
const receivedDate = new Date()
const appealCaseNumber = uuid()
+ const assistantName = uuid()
+ const assistantEmail = uuid()
+ const judgeName1 = uuid()
+ const judgeEmail1 = uuid()
+ const judgeName2 = uuid()
+ const judgeEmail2 = uuid()
+ const judgeName3 = uuid()
+ const judgeEmail3 = uuid()
let mockEmailService: EmailService
@@ -68,16 +65,16 @@ describe('InternalNotificationController - Send appeal statement notifications',
caseId,
{
id: caseId,
- prosecutor: { name: prosecutor.name, email: prosecutor.email },
+ prosecutor: { name: prosecutorName, email: prosecutorEmail },
court: { name: 'Héraðsdómur Reykjavíkur' },
defenderNationalId,
- defenderName: defender.name,
- defenderEmail: defender.email,
+ defenderName: defenderName,
+ defenderEmail: defenderEmail,
courtCaseNumber,
appealReceivedByCourtDate: receivedDate,
appealCaseNumber,
- appealAssistant: { name: assistant.name, email: assistant.email },
- appealJudge1: { name: judge1.name, email: judge1.email },
+ appealAssistant: { name: assistantName, email: assistantEmail },
+ appealJudge1: { name: judgeName1, email: judgeEmail1 },
} as Case,
{
user,
@@ -113,13 +110,13 @@ describe('InternalNotificationController - Send appeal statement notifications',
})
it('should send notification to appeals court and defender', () => {
- expectCourtEmail(assistant.name, assistant.email)
- expectCourtEmail(judge1.name, judge1.email)
- expectCourtEmail(judge2.name, judge2.email)
- expectCourtEmail(judge3.name, judge3.email)
+ expectCourtEmail(assistantName, assistantEmail)
+ expectCourtEmail(judgeName1, judgeEmail1)
+ expectCourtEmail(judgeName2, judgeEmail2)
+ expectCourtEmail(judgeName3, judgeEmail3)
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: defender.name, address: defender.email }],
+ to: [{ name: defenderName, address: defenderEmail }],
subject: `Ný greinargerð í máli ${courtCaseNumber} (${appealCaseNumber})`,
html: `Greinargerð hefur borist vegna kæru í máli ${courtCaseNumber} (Landsréttarmál nr. ${appealCaseNumber}). Hægt er að nálgast gögn málsins á yfirlitssíðu málsins í Réttarvörslugátt.`,
}),
@@ -143,13 +140,13 @@ describe('InternalNotificationController - Send appeal statement notifications',
})
it('should send notification to appeals court and defender', () => {
- expectCourtEmail(assistant.name, assistant.email)
- expectCourtEmail(judge1.name, judge1.email)
- expectCourtEmail(judge2.name, judge2.email)
- expectCourtEmail(judge3.name, judge3.email)
+ expectCourtEmail(assistantName, assistantEmail)
+ expectCourtEmail(judgeName1, judgeEmail1)
+ expectCourtEmail(judgeName2, judgeEmail2)
+ expectCourtEmail(judgeName3, judgeEmail3)
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: defender.name, address: defender.email }],
+ to: [{ name: defenderName, address: defenderEmail }],
subject: `Ný greinargerð í máli ${courtCaseNumber} (${appealCaseNumber})`,
html: `Greinargerð hefur borist vegna kæru í máli ${courtCaseNumber} (Landsréttarmál nr. ${appealCaseNumber}). Hægt er að nálgast gögn málsins hjá Héraðsdómi Reykjavíkur ef þau hafa ekki þegar verið afhent.`,
}),
@@ -170,13 +167,13 @@ describe('InternalNotificationController - Send appeal statement notifications',
})
it('should send notification to appeals court and prosecutor', () => {
- expectCourtEmail(assistant.name, assistant.email)
- expectCourtEmail(judge1.name, judge1.email)
- expectCourtEmail(judge2.name, judge2.email)
- expectCourtEmail(judge3.name, judge3.email)
+ expectCourtEmail(assistantName, assistantEmail)
+ expectCourtEmail(judgeName1, judgeEmail1)
+ expectCourtEmail(judgeName2, judgeEmail2)
+ expectCourtEmail(judgeName3, judgeEmail3)
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: prosecutor.name, address: prosecutor.email }],
+ to: [{ name: prosecutorName, address: prosecutorEmail }],
subject: `Ný greinargerð í máli ${courtCaseNumber} (${appealCaseNumber})`,
html: `Greinargerð hefur borist vegna kæru í máli ${courtCaseNumber} (Landsréttarmál nr. ${appealCaseNumber}). Hægt er að nálgast gögn málsins á yfirlitssíðu málsins í Réttarvörslugátt.`,
}),
@@ -201,7 +198,7 @@ describe('InternalNotificationController - Send appeal statement notifications',
it('should send notification to defender', () => {
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: defender.name, address: defender.email }],
+ to: [{ name: defenderName, address: defenderEmail }],
subject: `Ný greinargerð í máli ${courtCaseNumber}`,
html: `Greinargerð hefur borist vegna kæru í máli ${courtCaseNumber}. Hægt er að nálgast gögn málsins á yfirlitssíðu málsins í Réttarvörslugátt.`,
}),
@@ -223,7 +220,7 @@ describe('InternalNotificationController - Send appeal statement notifications',
it('should send notification to defender', () => {
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: defender.name, address: defender.email }],
+ to: [{ name: defenderName, address: defenderEmail }],
subject: `Ný greinargerð í máli ${courtCaseNumber}`,
html: `Greinargerð hefur borist vegna kæru í máli ${courtCaseNumber}. Hægt er að nálgast gögn málsins hjá Héraðsdómi Reykjavíkur ef þau hafa ekki þegar verið afhent.`,
}),
@@ -242,7 +239,7 @@ describe('InternalNotificationController - Send appeal statement notifications',
it('should send notification to prosecutor', () => {
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: prosecutor.name, address: prosecutor.email }],
+ to: [{ name: prosecutorName, address: prosecutorEmail }],
subject: `Ný greinargerð í máli ${courtCaseNumber}`,
html: `Greinargerð hefur borist vegna kæru í máli ${courtCaseNumber}. Hægt er að nálgast gögn málsins á yfirlitssíðu málsins í Réttarvörslugátt.`,
}),
diff --git a/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAppealToCourtOfAppealsNotifications.spec.ts b/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAppealToCourtOfAppealsNotifications.spec.ts
index ae50c9e3c325..2119328928c1 100644
--- a/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAppealToCourtOfAppealsNotifications.spec.ts
+++ b/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAppealToCourtOfAppealsNotifications.spec.ts
@@ -10,10 +10,7 @@ import {
UserRole,
} from '@island.is/judicial-system/types'
-import {
- createTestingNotificationModule,
- createTestUsers,
-} from '../createTestingNotificationModule'
+import { createTestingNotificationModule } from '../createTestingNotificationModule'
import { Case } from '../../../case'
import { DeliverResponse } from '../../models/deliver.response'
@@ -26,17 +23,20 @@ interface Then {
type GivenWhenThen = (user: User, defenderNationalId?: string) => Promise
describe('InternalNotificationController - Send appeal to court of appeals notifications', () => {
- const { prosecutor, judge, registrar, defender, court } = createTestUsers([
- 'prosecutor',
- 'judge',
- 'registrar',
- 'defender',
- 'court',
- ])
-
const caseId = uuid()
-
+ const prosecutorName = uuid()
+ const prosecutorEmail = uuid()
+ const prosecutorMobileNumber = uuid()
+ const judgeName = uuid()
+ const judgeEmail = uuid()
+ const registrarName = uuid()
+ const registrarEmail = uuid()
+ const defenderName = uuid()
+ const defenderEmail = uuid()
const courtCaseNumber = uuid()
+ const courtId = uuid()
+ const courtEmail = uuid()
+ const courtMobileNumber = uuid()
let mockEmailService: EmailService
let mockSmsService: SmsService
@@ -44,8 +44,8 @@ describe('InternalNotificationController - Send appeal to court of appeals notif
let givenWhenThen: GivenWhenThen
beforeEach(async () => {
- process.env.COURTS_ASSISTANT_MOBILE_NUMBERS = `{"${court.id}": "${court.mobile}"}`
- process.env.COURTS_EMAILS = `{"${court.id}": "${court.email}"}`
+ process.env.COURTS_ASSISTANT_MOBILE_NUMBERS = `{"${courtId}": "${courtMobileNumber}"}`
+ process.env.COURTS_EMAILS = `{"${courtId}": "${courtEmail}"}`
const { emailService, smsService, internalNotificationController } =
await createTestingNotificationModule()
@@ -62,18 +62,18 @@ describe('InternalNotificationController - Send appeal to court of appeals notif
{
id: caseId,
prosecutor: {
- name: prosecutor.name,
- email: prosecutor.email,
- mobileNumber: prosecutor.mobile,
+ name: prosecutorName,
+ email: prosecutorEmail,
+ mobileNumber: prosecutorMobileNumber,
},
- judge: { name: judge.name, email: judge.email },
- registrar: { name: registrar.name, email: registrar.email },
+ judge: { name: judgeName, email: judgeEmail },
+ registrar: { name: registrarName, email: registrarEmail },
court: { name: 'Héraðsdómur Reykjavíkur' },
defenderNationalId,
- defenderName: defender.name,
- defenderEmail: defender.email,
+ defenderName: defenderName,
+ defenderEmail: defenderEmail,
courtCaseNumber,
- courtId: court.id,
+ courtId: courtId,
} as Case,
{
user,
@@ -102,35 +102,35 @@ describe('InternalNotificationController - Send appeal to court of appeals notif
it('should send notification to judge, registrar, court and defender', () => {
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: judge.name, address: judge.email }],
+ to: [{ name: judgeName, address: judgeEmail }],
subject: `Kæra í máli ${courtCaseNumber}`,
html: `Úrskurður hefur verið kærður í máli ${courtCaseNumber}. Hægt er að nálgast gögn málsins á yfirlitssíðu málsins í Réttarvörslugátt.`,
}),
)
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: registrar.name, address: registrar.email }],
+ to: [{ name: registrarName, address: registrarEmail }],
subject: `Kæra í máli ${courtCaseNumber}`,
html: `Úrskurður hefur verið kærður í máli ${courtCaseNumber}. Hægt er að nálgast gögn málsins á yfirlitssíðu málsins í Réttarvörslugátt.`,
}),
)
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: 'Héraðsdómur Reykjavíkur', address: court.email }],
+ to: [{ name: 'Héraðsdómur Reykjavíkur', address: courtEmail }],
subject: `Kæra í máli ${courtCaseNumber}`,
html: `Úrskurður hefur verið kærður í máli ${courtCaseNumber}. Hægt er að nálgast gögn málsins á yfirlitssíðu málsins í Réttarvörslugátt.`,
}),
)
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: defender.name, address: defender.email }],
+ to: [{ name: defenderName, address: defenderEmail }],
subject: `Kæra í máli ${courtCaseNumber}`,
html: `Úrskurður hefur verið kærður í máli ${courtCaseNumber}. Hægt er að nálgast gögn málsins á yfirlitssíðu málsins í Réttarvörslugátt.`,
}),
)
expect(mockSmsService.sendSms).toHaveBeenCalledWith(
- [court.mobile],
+ [courtMobileNumber],
`Úrskurður hefur verið kærður í máli ${courtCaseNumber}. Sjá nánar á rettarvorslugatt.island.is`,
)
expect(then.result).toEqual({ delivered: true })
@@ -150,20 +150,20 @@ describe('InternalNotificationController - Send appeal to court of appeals notif
it('should send notification to judge and defender', () => {
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: judge.name, address: judge.email }],
+ to: [{ name: judgeName, address: judgeEmail }],
subject: `Kæra í máli ${courtCaseNumber}`,
html: `Úrskurður hefur verið kærður í máli ${courtCaseNumber}. Hægt er að nálgast gögn málsins á yfirlitssíðu málsins í Réttarvörslugátt.`,
}),
)
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: defender.name, address: defender.email }],
+ to: [{ name: defenderName, address: defenderEmail }],
subject: `Kæra í máli ${courtCaseNumber}`,
html: `Úrskurður hefur verið kærður í máli ${courtCaseNumber}. Hægt er að nálgast gögn málsins hjá Héraðsdómi Reykjavíkur ef þau hafa ekki þegar verið afhent.`,
}),
)
expect(mockSmsService.sendSms).toHaveBeenCalledWith(
- [court.mobile],
+ [courtMobileNumber],
`Úrskurður hefur verið kærður í máli ${courtCaseNumber}. Sjá nánar á rettarvorslugatt.island.is`,
)
expect(then.result).toEqual({ delivered: true })
@@ -180,24 +180,24 @@ describe('InternalNotificationController - Send appeal to court of appeals notif
it('should send notifications to judge and prosecutor', () => {
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: judge.name, address: judge.email }],
+ to: [{ name: judgeName, address: judgeEmail }],
subject: `Kæra í máli ${courtCaseNumber}`,
html: `Úrskurður hefur verið kærður í máli ${courtCaseNumber}. Hægt er að nálgast gögn málsins á yfirlitssíðu málsins í Réttarvörslugátt.`,
}),
)
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: prosecutor.name, address: prosecutor.email }],
+ to: [{ name: prosecutorName, address: prosecutorEmail }],
subject: `Kæra í máli ${courtCaseNumber}`,
html: `Úrskurður hefur verið kærður í máli ${courtCaseNumber}. Hægt er að nálgast gögn málsins á yfirlitssíðu málsins í Réttarvörslugátt.`,
}),
)
expect(mockSmsService.sendSms).toHaveBeenCalledWith(
- [court.mobile],
+ [courtMobileNumber],
`Úrskurður hefur verið kærður í máli ${courtCaseNumber}. Sjá nánar á rettarvorslugatt.island.is`,
)
expect(mockSmsService.sendSms).toHaveBeenCalledWith(
- [prosecutor.mobile],
+ [prosecutorMobileNumber],
`Úrskurður hefur verið kærður í máli ${courtCaseNumber}. Sjá nánar á rettarvorslugatt.island.is`,
)
diff --git a/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAppealWithdrawnNotifications.spec.ts b/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAppealWithdrawnNotifications.spec.ts
index bc96d0d487d9..1b2be1516b1e 100644
--- a/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAppealWithdrawnNotifications.spec.ts
+++ b/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAppealWithdrawnNotifications.spec.ts
@@ -5,15 +5,11 @@ import { EmailService } from '@island.is/email-service'
import {
CaseNotificationType,
InstitutionType,
- NotificationType,
User,
UserRole,
} from '@island.is/judicial-system/types'
-import {
- createTestingNotificationModule,
- createTestUsers,
-} from '../createTestingNotificationModule'
+import { createTestingNotificationModule } from '../createTestingNotificationModule'
import { Case } from '../../../case'
import { DeliverResponse } from '../../models/deliver.response'
@@ -31,33 +27,26 @@ type GivenWhenThen = (
) => Promise
describe('InternalNotificationController - Send appeal withdrawn notifications', () => {
- const {
- courtOfAppeals,
- court,
- judge,
- prosecutor,
- defender,
- registrar,
- appealAssistant,
- appealJudge1,
- } = createTestUsers([
- 'courtOfAppeals',
- 'court',
- 'judge',
- 'prosecutor',
- 'defender',
- 'registrar',
- 'appealAssistant',
- 'appealJudge1',
- ])
-
- const courtOfAppealsEmail = courtOfAppeals.email
- const courtEmail = court.email
+ const courtOfAppealsEmail = uuid()
+ const courtEmail = uuid()
const courtId = uuid()
const userId = uuid()
const caseId = uuid()
+ const judgeName = uuid()
+ const judgeEmail = uuid()
+ const prosecutorName = uuid()
+ const prosecutorEmail = uuid()
+ const prosecutorMobileNumber = uuid()
+ const defenderName = uuid()
+ const defenderEmail = uuid()
const courtCaseNumber = uuid()
const receivedDate = new Date()
+ const registrarEmail = uuid()
+ const registrarName = uuid()
+ const appealAssistantName = uuid()
+ const appealAssistantEmail = uuid()
+ const appealJudge1Name = uuid()
+ const appealJudge1Email = uuid()
let mockEmailService: EmailService
let mockNotificationModel: typeof Notification
@@ -85,25 +74,22 @@ describe('InternalNotificationController - Send appeal withdrawn notifications',
{
id: caseId,
prosecutor: {
- name: prosecutor.name,
- email: prosecutor.email,
- mobileNumber: prosecutor.mobile,
+ name: prosecutorName,
+ email: prosecutorEmail,
+ mobileNumber: prosecutorMobileNumber,
},
court: { name: 'Héraðsdómur Reykjavíkur', id: courtId },
- defenderName: defender.name,
- defenderEmail: defender.email,
+ defenderName: defenderName,
+ defenderEmail: defenderEmail,
courtCaseNumber,
appealReceivedByCourtDate,
appealAssistant: {
- name: appealAssistant.name,
- email: appealAssistant.email,
- },
- judge: { name: judge.name, email: judge.email },
- appealJudge1: {
- name: appealJudge1.name,
- email: appealJudge1.email,
+ name: appealAssistantName,
+ email: appealAssistantEmail,
},
- registrar: { name: registrar.name, email: registrar.email },
+ judge: { name: judgeName, email: judgeEmail },
+ appealJudge1: { name: appealJudge1Name, email: appealJudge1Email },
+ registrar: { name: registrarName, email: registrarEmail },
notifications,
} as Case,
{
@@ -130,7 +116,7 @@ describe('InternalNotificationController - Send appeal withdrawn notifications',
it('should send notification to defender', () => {
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: defender.name, address: defender.email }],
+ to: [{ name: defenderName, address: defenderEmail }],
subject: `Afturköllun kæru í máli ${courtCaseNumber}`,
html: `Sækjandi hefur afturkallað kæru í máli ${courtCaseNumber}. Hægt er að nálgast yfirlitssíðu málsins á rettarvorslugatt.island.is.`,
}),
@@ -154,7 +140,7 @@ describe('InternalNotificationController - Send appeal withdrawn notifications',
it('should send notification to appeal assistant ', () => {
expect(mockEmailService.sendEmail).not.toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: appealAssistant.name, address: appealAssistant.email }],
+ to: [{ name: appealAssistantName, address: appealAssistantEmail }],
subject: `Afturköllun kæru í máli ${courtCaseNumber}`,
html: `Sækjandi hefur afturkallað kæru í máli ${courtCaseNumber}. Hægt er að nálgast yfirlitssíðu málsins á rettarvorslugatt.island.is.`,
}),
@@ -172,14 +158,14 @@ describe('InternalNotificationController - Send appeal withdrawn notifications',
then = await givenWhenThen(UserRole.PROSECUTOR, receivedDate, [
{
caseId,
- type: NotificationType.APPEAL_JUDGES_ASSIGNED,
+ type: CaseNotificationType.APPEAL_JUDGES_ASSIGNED,
} as Notification,
])
})
it('should send notification to defender', () => {
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: defender.name, address: defender.email }],
+ to: [{ name: defenderName, address: defenderEmail }],
subject: `Afturköllun kæru í máli ${courtCaseNumber}`,
html: `Sækjandi hefur afturkallað kæru í máli ${courtCaseNumber}. Hægt er að nálgast yfirlitssíðu málsins á rettarvorslugatt.island.is.`,
}),
@@ -203,7 +189,7 @@ describe('InternalNotificationController - Send appeal withdrawn notifications',
it('should send notification to appeal assistant ', () => {
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: appealAssistant.name, address: appealAssistant.email }],
+ to: [{ name: appealAssistantName, address: appealAssistantEmail }],
subject: `Afturköllun kæru í máli ${courtCaseNumber}`,
html: `Sækjandi hefur afturkallað kæru í máli ${courtCaseNumber}. Hægt er að nálgast yfirlitssíðu málsins á rettarvorslugatt.island.is.`,
}),
@@ -212,7 +198,7 @@ describe('InternalNotificationController - Send appeal withdrawn notifications',
it('should send notification to appeal judges', () => {
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: appealJudge1.name, address: appealJudge1.email }],
+ to: [{ name: appealJudge1Name, address: appealJudge1Email }],
}),
)
})
@@ -228,7 +214,7 @@ describe('InternalNotificationController - Send appeal withdrawn notifications',
it('should send notification to prosecutor', () => {
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: prosecutor.name, address: prosecutor.email }],
+ to: [{ name: prosecutorName, address: prosecutorEmail }],
subject: `Afturköllun kæru í máli ${courtCaseNumber}`,
html: `Verjandi hefur afturkallað kæru í máli ${courtCaseNumber}. Hægt er að nálgast yfirlitssíðu málsins á rettarvorslugatt.island.is.`,
}),
@@ -240,7 +226,7 @@ describe('InternalNotificationController - Send appeal withdrawn notifications',
it('should send notification to judge', () => {
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: judge.name, address: judge.email }],
+ to: [{ name: judgeName, address: judgeEmail }],
subject: `Afturköllun kæru í máli ${courtCaseNumber}`,
html: `Verjandi hefur afturkallað kæru í máli ${courtCaseNumber}. Hægt er að nálgast yfirlitssíðu málsins á rettarvorslugatt.island.is.`,
}),
@@ -250,7 +236,7 @@ describe('InternalNotificationController - Send appeal withdrawn notifications',
it('should send notification to registrar', () => {
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: registrar.name, address: registrar.email }],
+ to: [{ name: registrarName, address: registrarEmail }],
subject: `Afturköllun kæru í máli ${courtCaseNumber}`,
html: `Verjandi hefur afturkallað kæru í máli ${courtCaseNumber}. Hægt er að nálgast yfirlitssíðu málsins á rettarvorslugatt.island.is.`,
}),
diff --git a/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendCaseFilesUpdatedNotifications.spec.ts b/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendCaseFilesUpdatedNotifications.spec.ts
index d57f0ea344f2..21df0ee723b4 100644
--- a/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendCaseFilesUpdatedNotifications.spec.ts
+++ b/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendCaseFilesUpdatedNotifications.spec.ts
@@ -10,10 +10,7 @@ import {
UserRole,
} from '@island.is/judicial-system/types'
-import {
- createTestingNotificationModule,
- createTestUsers,
-} from '../createTestingNotificationModule'
+import { createTestingNotificationModule } from '../createTestingNotificationModule'
import { Case } from '../../../case'
import { DeliverResponse } from '../../models/deliver.response'
@@ -26,15 +23,18 @@ interface Then {
type GivenWhenThen = (user: User) => Promise
describe('InternalNotificationController - Send case files updated notifications', () => {
- const { prosecutor, judge, defender, spokesperson } = createTestUsers([
- 'prosecutor',
- 'judge',
- 'defender',
- 'spokesperson',
- ])
-
const caseId = uuid()
const courtCaseNumber = uuid()
+ const prosecutorName = uuid()
+ 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
let givenWhenThen: GivenWhenThen
@@ -55,21 +55,15 @@ describe('InternalNotificationController - Send case files updated notifications
type: CaseType.INDICTMENT,
courtCaseNumber,
court: { name: 'Héraðsdómur Reykjavíkur' },
- prosecutor: { name: prosecutor.name, email: prosecutor.email },
- judge: { name: judge.name, email: judge.email },
- defendants: [
- {
- defenderNationalId: defender.nationalId,
- defenderName: defender.name,
- defenderEmail: defender.email,
- },
- ],
+ prosecutor: { name: prosecutorName, email: prosecutorEmail },
+ judge: { name: judgeName, email: judgeEmail },
+ defendants: [{ defenderNationalId, defenderName, defenderEmail }],
civilClaimants: [
{
hasSpokesperson: true,
- spokespersonNationalId: spokesperson.nationalId,
- spokespersonName: spokesperson.name,
- spokespersonEmail: spokesperson.email,
+ spokespersonNationalId,
+ spokespersonName,
+ spokespersonEmail,
},
],
} as Case,
@@ -98,21 +92,21 @@ describe('InternalNotificationController - Send case files updated notifications
it('should send notifications', () => {
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: judge.name, address: judge.email }],
+ to: [{ name: judgeName, address: judgeEmail }],
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 á yfirlitssíðu málsins í Réttarvörslugátt.`,
}),
)
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: spokesperson.name, address: spokesperson.email }],
+ 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 á yfirlitssíðu málsins í Réttarvörslugátt.`,
}),
)
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: defender.name, address: defender.email }],
+ to: [{ name: defenderName, address: defenderEmail }],
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 á yfirlitssíðu málsins í Réttarvörslugátt.`,
}),
@@ -133,21 +127,21 @@ describe('InternalNotificationController - Send case files updated notifications
it('should send notifications', () => {
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: judge.name, address: judge.email }],
+ to: [{ name: judgeName, address: judgeEmail }],
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 á yfirlitssíðu málsins í Réttarvörslugátt.`,
}),
)
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: spokesperson.name, address: spokesperson.email }],
+ 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 á yfirlitssíðu málsins í Réttarvörslugátt.`,
}),
)
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: prosecutor.name, address: prosecutor.email }],
+ 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 á yfirlitssíðu málsins í Réttarvörslugátt.`,
}),
diff --git a/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendCourtDateNotifications.spec.ts b/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendCourtDateNotifications.spec.ts
index 6cb820f993dc..18bf5d712b71 100644
--- a/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendCourtDateNotifications.spec.ts
+++ b/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendCourtDateNotifications.spec.ts
@@ -6,14 +6,10 @@ import {
CaseNotificationType,
CaseType,
DateType,
- NotificationType,
User,
} from '@island.is/judicial-system/types'
-import {
- createTestingNotificationModule,
- createTestUsers,
-} from '../createTestingNotificationModule'
+import { createTestingNotificationModule } from '../createTestingNotificationModule'
import { Case } from '../../../case'
import { CaseNotificationDto } from '../../dto/caseNotification.dto'
@@ -35,12 +31,13 @@ type GivenWhenThen = (
describe('InternalNotificationController - Send court date notifications', () => {
const userId = uuid()
const caseId = uuid()
-
+ const prosecutorName = uuid()
+ const prosecutorEmail = uuid()
+ const defenderName = uuid()
+ const defenderEmail = uuid()
const courtName = 'Héraðsdómur Reykjavíkur'
const courtCaseNumber = uuid()
- const { prosecutor, defender } = createTestUsers(['prosecutor', 'defender'])
-
let mockEmailService: EmailService
let mockNotificationModel: typeof Notification
let givenWhenThen: GivenWhenThen
@@ -78,11 +75,11 @@ describe('InternalNotificationController - Send court date notifications', () =>
const theCase = {
id: caseId,
type: CaseType.CUSTODY,
- prosecutor: { name: prosecutor.name, email: prosecutor.email },
+ prosecutor: { name: prosecutorName, email: prosecutorEmail },
court: { name: courtName },
courtCaseNumber,
- defenderName: defender.name,
- defenderEmail: defender.email,
+ defenderName,
+ defenderEmail,
} as Case
beforeEach(async () => {
@@ -92,23 +89,23 @@ describe('InternalNotificationController - Send court date notifications', () =>
it('should send notifications to prosecutor and defender', () => {
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: prosecutor.name, address: prosecutor.email }],
+ to: [{ name: prosecutorName, address: prosecutorEmail }],
subject: `Fyrirtaka í máli: ${courtCaseNumber}`,
- html: `Héraðsdómur Reykjavíkur hefur staðfest fyrirtökutíma fyrir kröfu um gæsluvarðhald.
Fyrirtaka mun fara fram á ótilgreindum tíma.
Dómsalur hefur ekki verið skráður.
Dómari hefur ekki verið skráður.
Verjandi sakbornings: ${defender.name}. Hægt er að nálgast yfirlitssíðu málsins á rettarvorslugatt.island.is.`,
+ html: `Héraðsdómur Reykjavíkur hefur staðfest fyrirtökutíma fyrir kröfu um gæsluvarðhald.
Fyrirtaka mun fara fram á ótilgreindum tíma.
Dómsalur hefur ekki verið skráður.
Dómari hefur ekki verið skráður.
Verjandi sakbornings: ${defenderName}. Hægt er að nálgast yfirlitssíðu málsins á rettarvorslugatt.island.is.`,
}),
)
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: defender.name, address: defender.email }],
+ to: [{ name: defenderName, address: defenderEmail }],
subject: `Fyrirtaka í máli ${courtCaseNumber}`,
- html: `Héraðsdómur Reykjavíkur hefur boðað þig í fyrirtöku sem verjanda sakbornings.
Fyrirtaka mun fara fram á ótilgreindum tíma.
Málsnúmer: ${courtCaseNumber}.
Dómsalur hefur ekki verið skráður.
Dómari: .
Sækjandi: ${prosecutor.name} ().`,
+ html: `Héraðsdómur Reykjavíkur hefur boðað þig í fyrirtöku sem verjanda sakbornings.
Hægt er að nálgast gögn málsins á yfirlitssíðu málsins í Réttarvörslugátt.`,
}),
@@ -205,7 +202,7 @@ describe('InternalNotificationController - Send court date notifications', () =>
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: defender.name, address: defender.email }],
+ to: [{ name: defenderName, address: defenderEmail }],
subject: `Nýtt þinghald í máli ${courtCaseNumber}`,
html: `Héraðsdómur Reykjavíkur boðar til þinghalds í máli ${courtCaseNumber}. Fyrirtaka mun fara fram 2. maí 2024, kl. 14:32.
Tegund þinghalds: Óþekkt.
Dómsalur hefur ekki verið skráður.
Dómari hefur ekki verið skráður.
Hægt er að nálgast gögn málsins hjá Héraðsdómur Reykjavíkur.`,
}),
diff --git a/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendDefendantsNotUpdatedAtCourtNotifications.spec.ts b/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendDefendantsNotUpdatedAtCourtNotifications.spec.ts
index b0448904d07f..b7090ce986dc 100644
--- a/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendDefendantsNotUpdatedAtCourtNotifications.spec.ts
+++ b/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendDefendantsNotUpdatedAtCourtNotifications.spec.ts
@@ -2,16 +2,9 @@ import { uuid } from 'uuidv4'
import { EmailService } from '@island.is/email-service'
-import {
- CaseNotificationType,
- NotificationType,
- User,
-} from '@island.is/judicial-system/types'
+import { CaseNotificationType, User } from '@island.is/judicial-system/types'
-import {
- createTestingNotificationModule,
- createTestUsers,
-} from '../createTestingNotificationModule'
+import { createTestingNotificationModule } from '../createTestingNotificationModule'
import { Case } from '../../../case'
import { CaseNotificationDto } from '../../dto/caseNotification.dto'
@@ -34,15 +27,14 @@ describe('InternalNotificationController - Send defendants not updated at court
user: { id: userId } as User,
type: CaseNotificationType.DEFENDANTS_NOT_UPDATED_AT_COURT,
}
-
- const { registrar } = createTestUsers(['registrar', 'defender'])
const caseId = uuid()
const courtCaseNumber = uuid()
-
+ const registrarName = uuid()
+ const registrarEmail = uuid()
const theCase = {
id: caseId,
courtCaseNumber,
- registrar: { name: registrar.name, email: registrar.email },
+ registrar: { name: registrarName, email: registrarEmail },
} as Case
let mockEmailService: EmailService
@@ -80,7 +72,7 @@ describe('InternalNotificationController - Send defendants not updated at court
it('should send email', () => {
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: registrar.name, address: registrar.email }],
+ to: [{ name: registrarName, address: registrarEmail }],
subject: `Skráning varnaraðila/verjenda í máli ${courtCaseNumber}`,
html: `Ekki tókst að skrá varnaraðila/verjendur í máli ${courtCaseNumber} í Auði. Yfirfara þarf málið í Auði og skrá rétta aðila áður en því er lokað.`,
}),
@@ -99,8 +91,8 @@ describe('InternalNotificationController - Send defendants not updated at court
...theCase,
notifications: [
{
- type: NotificationType.DEFENDANTS_NOT_UPDATED_AT_COURT,
- recipients: [{ address: registrar.email, success: true }],
+ type: CaseNotificationType.DEFENDANTS_NOT_UPDATED_AT_COURT,
+ recipients: [{ address: registrarEmail, success: true }],
},
],
} as Case,
diff --git a/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendIndictmentDeniedNotifications.spec.ts b/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendIndictmentDeniedNotifications.spec.ts
index 7efd487f6146..904b873650f9 100644
--- a/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendIndictmentDeniedNotifications.spec.ts
+++ b/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendIndictmentDeniedNotifications.spec.ts
@@ -8,10 +8,7 @@ import {
User,
} from '@island.is/judicial-system/types'
-import {
- createTestingNotificationModule,
- createTestUsers,
-} from '../createTestingNotificationModule'
+import { createTestingNotificationModule } from '../createTestingNotificationModule'
import { Case } from '../../../case'
import { CaseNotificationDto } from '../../dto/caseNotification.dto'
@@ -32,10 +29,8 @@ type GivenWhenThen = (
describe('InternalNotificationController - Send indictment denied notification', () => {
const userId = uuid()
const caseId = uuid()
-
- const { prosecutor } = createTestUsers(['prosecutor'])
- const prosecutorName = prosecutor.name
- const prosecutorEmail = prosecutor.email
+ const prosecutorName = uuid()
+ const prosecutorEmail = uuid()
const policeCaseNumbers = [uuid(), uuid()]
let mockEmailService: EmailService
diff --git a/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendIndictmentReturnedNotifications.spec.ts b/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendIndictmentReturnedNotifications.spec.ts
index ee1f6bd106bb..24a9ddba4558 100644
--- a/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendIndictmentReturnedNotifications.spec.ts
+++ b/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendIndictmentReturnedNotifications.spec.ts
@@ -8,10 +8,7 @@ import {
User,
} from '@island.is/judicial-system/types'
-import {
- createTestingNotificationModule,
- createTestUsers,
-} from '../createTestingNotificationModule'
+import { createTestingNotificationModule } from '../createTestingNotificationModule'
import { Case } from '../../../case'
import { CaseNotificationDto } from '../../dto/caseNotification.dto'
@@ -30,10 +27,10 @@ type GivenWhenThen = (
) => Promise
describe('InternalNotificationController - Send indictment returned notification', () => {
- const { prosecutor } = createTestUsers(['prosecutor'])
const userId = uuid()
const caseId = uuid()
-
+ const prosecutorName = uuid()
+ const prosecutorEmail = uuid()
const policeCaseNumbers = [uuid(), uuid()]
const courtName = uuid()
@@ -72,7 +69,7 @@ describe('InternalNotificationController - Send indictment returned notification
const theCase = {
id: caseId,
type: CaseType.INDICTMENT,
- prosecutor: { name: prosecutor.name, email: prosecutor.email },
+ prosecutor: { name: prosecutorName, email: prosecutorEmail },
policeCaseNumbers,
court: { name: courtName },
} as Case
@@ -84,7 +81,7 @@ describe('InternalNotificationController - Send indictment returned notification
it('should send notifications to prosecutor', () => {
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: prosecutor.name, address: prosecutor.email }],
+ to: [{ name: prosecutorName, address: prosecutorEmail }],
subject: `Ákæra endursend í máli ${policeCaseNumbers[0]}`,
html: `${courtName} hefur endursent ákæru vegna lögreglumáls ${policeCaseNumbers[0]}. Þú getur nálgast samantekt málsins á yfirlitssíðu málsins í Réttarvörslugátt.`,
}),
diff --git a/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendIndictmentsWaitingForConfirmationNotifications.spec.ts b/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendIndictmentsWaitingForConfirmationNotifications.spec.ts
index 3c20d0d96a26..d3992015ded4 100644
--- a/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendIndictmentsWaitingForConfirmationNotifications.spec.ts
+++ b/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendIndictmentsWaitingForConfirmationNotifications.spec.ts
@@ -4,10 +4,7 @@ import { EmailService } from '@island.is/email-service'
import { InstitutionNotificationType } from '@island.is/judicial-system/types'
-import {
- createTestingNotificationModule,
- createTestUsers,
-} from '../createTestingNotificationModule'
+import { createTestingNotificationModule } from '../createTestingNotificationModule'
import { InternalCaseService } from '../../../case'
import { UserService } from '../../../user'
@@ -21,11 +18,10 @@ interface Then {
type GivenWhenThen = () => Promise
describe('InternalNotificationController - Send indictments waiting for confirmation notifications', () => {
- const { prosecutor1, prosecutor2 } = createTestUsers([
- 'prosecutor1',
- 'prosecutor2',
- ])
-
+ const prosecutorName1 = uuid()
+ const prosecutorEmail1 = uuid()
+ const prosecutorName2 = uuid()
+ const prosecutorEmail2 = uuid()
const prosecutorsOfficeId = uuid()
let mockUserService: UserService
let mockInternalCaseService: InternalCaseService
@@ -120,25 +116,25 @@ describe('InternalNotificationController - Send indictments waiting for confirma
const mockGetUsersWhoCanConfirmIndictments =
mockUserService.getUsersWhoCanConfirmIndictments as jest.Mock
mockGetUsersWhoCanConfirmIndictments.mockResolvedValueOnce([
- { name: prosecutor1.name, email: prosecutor1.email },
- { name: prosecutor2.name, email: prosecutor2.email },
+ { name: prosecutorName1, email: prosecutorEmail1 },
+ { name: prosecutorName2, email: prosecutorEmail2 },
])
then = await givenWhenThen()
})
- it('should send messages', () => {
+ it('should not send messages', () => {
expect(mockEmailService.sendEmail).toHaveBeenCalledTimes(2)
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: prosecutor1.name, address: prosecutor1.email }],
+ to: [{ name: prosecutorName1, address: prosecutorEmail1 }],
subject: 'Ákærur bíða staðfestingar',
html: 'Í Réttarvörslugátt bíða 2 ákærur staðfestingar.
Hægt er að nálgast yfirlit og staðfesta ákærur í Réttarvörslugátt.',
}),
)
expect(mockEmailService.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: prosecutor2.name, address: prosecutor2.email }],
+ to: [{ name: prosecutorName2, address: prosecutorEmail2 }],
subject: 'Ákærur bíða staðfestingar',
html: 'Í Réttarvörslugátt bíða 2 ákærur staðfestingar.
Hægt er að nálgast yfirlit og staðfesta ákærur í Réttarvörslugátt.',
}),
diff --git a/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendReadyForCourtNotifications.spec.ts b/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendReadyForCourtNotifications.spec.ts
index f9757746c4ad..e1b3b2c1a4c6 100644
--- a/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendReadyForCourtNotifications.spec.ts
+++ b/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendReadyForCourtNotifications.spec.ts
@@ -15,15 +15,11 @@ import {
CaseType,
DateType,
IndictmentSubtype,
- NotificationType,
RequestSharedWithDefender,
User,
} from '@island.is/judicial-system/types'
-import {
- createTestingNotificationModule,
- createTestUsers,
-} from '../createTestingNotificationModule'
+import { createTestingNotificationModule } from '../createTestingNotificationModule'
import { randomDate } from '../../../../test'
import { Case } from '../../../case'
@@ -48,29 +44,23 @@ describe('InternalNotificationController - Send ready for court notifications fo
const userId = uuid()
const caseId = uuid()
const policeCaseNumber = uuid()
+ const courtId = uuid()
const courtCaseNumber = uuid()
-
- const { prosecutor, defender, testCourt } = createTestUsers([
- 'prosecutor',
- 'defender',
- 'testCourt',
- ])
-
const theCase = {
id: caseId,
type: CaseType.CUSTODY,
state: CaseState.RECEIVED,
policeCaseNumbers: [policeCaseNumber],
prosecutor: {
- name: prosecutor.name,
- email: prosecutor.email,
+ name: 'Derrick',
+ email: 'derrick@dummy.is',
},
- courtId: testCourt.id,
+ courtId,
court: { name: 'Héraðsdómur Reykjavíkur' },
courtCaseNumber,
- defenderNationalId: defender.nationalId,
- defenderName: defender.name,
- defenderEmail: defender.email,
+ defenderNationalId: uuid(),
+ defenderName: 'Saul Goodman',
+ defenderEmail: 'saul@dummy.is',
requestSharedWithDefender: RequestSharedWithDefender.COURT_DATE,
prosecutorsOffice: { name: 'Héraðsdómur Derricks' },
dateLogs: [{ date: randomDate(), dateType: DateType.ARRAIGNMENT_DATE }],
@@ -79,6 +69,7 @@ describe('InternalNotificationController - Send ready for court notifications fo
user: { id: userId } as User,
type: CaseNotificationType.READY_FOR_COURT,
}
+ const courtMobileNumber = uuid()
let mockEmailService: EmailService
let mockSmsService: SmsService
@@ -86,7 +77,7 @@ describe('InternalNotificationController - Send ready for court notifications fo
let givenWhenThen: GivenWhenThen
beforeEach(async () => {
- process.env.COURTS_MOBILE_NUMBERS = `{"${testCourt.id}": "${testCourt.mobile}"}`
+ process.env.COURTS_MOBILE_NUMBERS = `{"${courtId}": "${courtMobileNumber}"}`
const {
emailService,
@@ -128,7 +119,7 @@ describe('InternalNotificationController - Send ready for court notifications fo
name: mockNotificationConfig.email.replyToName,
address: mockNotificationConfig.email.replyToEmail,
},
- to: [{ name: prosecutor.name, address: prosecutor.email }],
+ to: [{ name: 'Derrick', address: 'derrick@dummy.is' }],
subject: 'Krafa um gæsluvarðhald send',
text: `Þú hefur sent kröfu á Héraðsdóm Reykjavíkur vegna LÖKE máls ${policeCaseNumber}. Skjalið er aðgengilegt undir málinu í Réttarvörslugátt.`,
html: `Þú hefur sent kröfu á Héraðsdóm Reykjavíkur vegna LÖKE máls ${policeCaseNumber}. Skjalið er aðgengilegt undir málinu í Réttarvörslugátt.`,
@@ -138,8 +129,8 @@ describe('InternalNotificationController - Send ready for court notifications fo
it('should send ready for court sms notification to court', () => {
expect(mockSmsService.sendSms).toHaveBeenCalledWith(
- [testCourt.mobile],
- `Gæsluvarðhaldskrafa tilbúin til afgreiðslu. Sækjandi: ${prosecutor.name} (Héraðsdómur Derricks). Sjá nánar á rettarvorslugatt.island.is.`,
+ [courtMobileNumber],
+ 'Gæsluvarðhaldskrafa tilbúin til afgreiðslu. Sækjandi: Derrick (Héraðsdómur Derricks). Sjá nánar á rettarvorslugatt.island.is.',
)
})
@@ -157,13 +148,11 @@ describe('InternalNotificationController - Send ready for court notifications fo
notifications: [
{
caseId,
- type: NotificationType.READY_FOR_COURT,
+ type: CaseNotificationType.READY_FOR_COURT,
recipients: [
{
address:
- mockNotificationConfig.sms.courtsMobileNumbers[
- testCourt.id
- ],
+ mockNotificationConfig.sms.courtsMobileNumbers[courtId],
success: true,
},
],
@@ -184,7 +173,7 @@ describe('InternalNotificationController - Send ready for court notifications fo
name: mockNotificationConfig.email.replyToName,
address: mockNotificationConfig.email.replyToEmail,
},
- to: [{ name: prosecutor.name, address: prosecutor.email }],
+ to: [{ name: 'Derrick', address: 'derrick@dummy.is' }],
subject: 'Krafa um gæsluvarðhald send',
text: `Þú hefur sent kröfu á Héraðsdóm Reykjavíkur vegna LÖKE máls ${policeCaseNumber}. Skjalið er aðgengilegt undir málinu í Réttarvörslugátt.`,
html: `Þú hefur sent kröfu á Héraðsdóm Reykjavíkur vegna LÖKE máls ${policeCaseNumber}. Skjalið er aðgengilegt undir málinu í Réttarvörslugátt.`,
@@ -194,7 +183,7 @@ describe('InternalNotificationController - Send ready for court notifications fo
it('should send ready for court sms notification to court', () => {
expect(mockSmsService.sendSms).toHaveBeenCalledWith(
- [testCourt.mobile],
+ [courtMobileNumber],
`Sækjandi í máli ${courtCaseNumber} hefur breytt kröfunni og sent aftur á héraðsdómstól. Nýtt kröfuskjal hefur verið vistað í Auði. Sjá nánar á rettarvorslugatt.island.is.`,
)
})
@@ -202,7 +191,7 @@ describe('InternalNotificationController - Send ready for court notifications fo
it('should not send ready for court email notification to defender', () => {
expect(mockEmailService.sendEmail).not.toHaveBeenCalledWith(
expect.objectContaining({
- to: [{ name: defender.name, address: defender.email }],
+ to: [{ name: 'Saul Goodman', address: 'saul@dummy.is' }],
}),
)
})
@@ -235,8 +224,8 @@ describe('InternalNotificationController - Send ready for court notifications fo
...theCase,
notifications: [
{
- type: NotificationType.READY_FOR_COURT,
- recipients: [{ address: defender.email, success: true }],
+ type: CaseNotificationType.READY_FOR_COURT,
+ recipients: [{ address: 'saul@dummy.is', success: true }],
},
],
} as Case,
@@ -256,7 +245,7 @@ describe('InternalNotificationController - Send ready for court notifications fo
name: mockNotificationConfig.email.replyToName,
address: mockNotificationConfig.email.replyToEmail,
},
- to: [{ name: defender.name, address: defender.email }],
+ to: [{ name: 'Saul Goodman', address: 'saul@dummy.is' }],
subject: `Krafa í máli ${courtCaseNumber}`,
html: `Sækjandi í máli ${courtCaseNumber} hjá Héraðsdómi Reykjavíkur hefur breytt kröfunni og sent hana aftur á dóminn.