-
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): Deliver assigned court roles for indictments to court (#15205
) * feat(j-s): Robot email for assigned roles in indictment case * Update message.ts * feat(j-s): Trigger for updating court role * Update deliverIndictmentAssignedRolesToCourt.spec.ts * Merge conflicts resolved * fix(j-s): test cleanup --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
- Loading branch information
1 parent
17a146e
commit ec6c19e
Showing
7 changed files
with
248 additions
and
1 deletion.
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
86 changes: 86 additions & 0 deletions
86
...pp/modules/case/test/internalCaseController/deliverIndictmentAssignedRolesToCourt.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,86 @@ | ||
import { uuid } from 'uuidv4' | ||
|
||
import { CaseType, User, UserRole } from '@island.is/judicial-system/types' | ||
|
||
import { createTestingCaseModule } from '../createTestingCaseModule' | ||
|
||
import { CourtService } from '../../../court' | ||
import { Case } from '../../models/case.model' | ||
import { DeliverResponse } from '../../models/deliver.response' | ||
|
||
interface Then { | ||
result: DeliverResponse | ||
error: Error | ||
} | ||
|
||
type GivenWhenThen = ( | ||
caseId: string, | ||
theCase: Case, | ||
nationalId: string, | ||
) => Promise<Then> | ||
|
||
describe('InternalCaseController - Deliver assigned roles for indictment case to court', () => { | ||
const user = { id: uuid() } as User | ||
const caseId = uuid() | ||
const courtCaseNumber = uuid() | ||
|
||
const theCase = { | ||
id: caseId, | ||
type: CaseType.INDICTMENT, | ||
courtCaseNumber, | ||
judge: { name: 'Test Dómari', nationalId: '0101010101' }, | ||
registrar: { name: 'Test Ritari', nationalId: '0202020202' }, | ||
} as Case | ||
|
||
let mockCourtService: CourtService | ||
let givenWhenThen: GivenWhenThen | ||
|
||
beforeAll(async () => { | ||
const { courtService, internalCaseController } = | ||
await createTestingCaseModule() | ||
|
||
mockCourtService = courtService | ||
const mockUpdateIndictmentCaseWithAssignedRoles = | ||
mockCourtService.updateIndictmentCaseWithAssignedRoles as jest.Mock | ||
mockUpdateIndictmentCaseWithAssignedRoles.mockResolvedValue(uuid()) | ||
|
||
givenWhenThen = async ( | ||
caseId: string, | ||
theCase: Case, | ||
nationalId: string, | ||
) => { | ||
const then = {} as Then | ||
|
||
await internalCaseController | ||
.deliverIndictmentAssignedRoleToCourt( | ||
caseId, | ||
theCase, | ||
{ user }, | ||
nationalId, | ||
) | ||
.then((result) => (then.result = result)) | ||
.catch((error) => (then.error = error)) | ||
|
||
return then | ||
} | ||
}) | ||
|
||
describe('deliver assigned roles in indictment case to court', () => { | ||
let then: Then | ||
|
||
beforeAll(async () => { | ||
then = await givenWhenThen(caseId, theCase, '0101010101') | ||
}) | ||
|
||
it('should deliver the assigned roles to the court', () => { | ||
expect( | ||
mockCourtService.updateIndictmentCaseWithAssignedRoles, | ||
).toHaveBeenCalledWith(user, theCase.id, theCase.courtCaseNumber, { | ||
name: theCase.judge?.name, | ||
role: UserRole.DISTRICT_COURT_JUDGE, | ||
}) | ||
|
||
expect(then.result).toEqual({ delivered: true }) | ||
}) | ||
}) | ||
}) |
25 changes: 25 additions & 0 deletions
25
...ules/case/test/internalCaseController/deliverIndictmentAssignedRolesToCourtGuards.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,25 @@ | ||
import { indictmentCases } from '@island.is/judicial-system/types' | ||
|
||
import { CaseExistsGuard } from '../../guards/caseExists.guard' | ||
import { CaseTypeGuard } from '../../guards/caseType.guard' | ||
import { InternalCaseController } from '../../internalCase.controller' | ||
|
||
describe('InternalCaseController - Deliver assigned roles in indictment case to court guards', () => { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
let guards: any[] | ||
|
||
beforeEach(() => { | ||
guards = Reflect.getMetadata( | ||
'__guards__', | ||
InternalCaseController.prototype.deliverIndictmentAssignedRoleToCourt, | ||
) | ||
}) | ||
|
||
it('should have the right guard configuration', () => { | ||
expect(new guards[0]()).toBeInstanceOf(CaseExistsGuard) | ||
expect(guards[1]).toBeInstanceOf(CaseTypeGuard) | ||
expect(guards[1]).toEqual({ | ||
allowedCaseTypes: indictmentCases, | ||
}) | ||
}) | ||
}) |
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