Skip to content

Commit

Permalink
fix(j-s): Allow prison system users to see rulings (#15935)
Browse files Browse the repository at this point in the history
* Allow prison system users to see rulings

* Fix tests

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
oddsson and kodiakhq[bot] authored Sep 10, 2024
1 parent 2848c41 commit 4264bb3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ import {
CaseAppealState,
CaseFileCategory,
isDefenceUser,
isIndictmentCase,
isPrisonStaffUser,
isPrisonSystemUser,
isRestrictionCase,
User,
} from '@island.is/judicial-system/types'

Expand All @@ -33,15 +35,18 @@ export class CaseFileInterceptor implements NestInterceptor {

if (
isPrisonStaffUser(user) ||
data.appealState !== CaseAppealState.COMPLETED
(isRestrictionCase(data.type) &&
data.appealState !== CaseAppealState.COMPLETED)
) {
data.caseFiles?.splice(0, data.caseFiles.length)
} else if (isPrisonSystemUser(user)) {
data.caseFiles?.splice(
0,
data.caseFiles.length,
...data.caseFiles.filter(
(cf) => cf.category === CaseFileCategory.APPEAL_RULING,
...data.caseFiles.filter((cf) =>
isIndictmentCase(data.type)
? cf.category === CaseFileCategory.RULING
: cf.category === CaseFileCategory.APPEAL_RULING,
),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,7 @@ export const defenderCaseFileCategoriesForIndictmentCases = [
CaseFileCategory.DEFENDANT_CASE_FILE,
]

export const prisonAdminCaseFileCategories = [CaseFileCategory.APPEAL_RULING]
export const prisonAdminCaseFileCategories = [
CaseFileCategory.APPEAL_RULING,
CaseFileCategory.RULING,
]
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,10 @@ describe('Limited Access View Case File Guard', () => {

describe.each(Object.keys(CaseType))('for %s cases', (type) => {
describe.each(completedCaseStates)('in state %s', (state) => {
const allowedCaseFileCategories = [CaseFileCategory.APPEAL_RULING]
const allowedCaseFileCategories = [
CaseFileCategory.APPEAL_RULING,
CaseFileCategory.RULING,
]

describe.each(allowedCaseFileCategories)(
'prison system users can view %s',
Expand Down

0 comments on commit 4264bb3

Please sign in to comment.