Skip to content

Commit

Permalink
feat(j-s): Show courtRecord files in indictments to everyone once upl…
Browse files Browse the repository at this point in the history
…oaded (#15817)

* Show court records to everyone once uploaded

* Show court records when uploaded

* Add test
  • Loading branch information
oddsson authored Sep 2, 2024
1 parent ed805ae commit b74a253
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { IntlProvider } from 'react-intl'
import { ApolloClient, ApolloProvider, InMemoryCache } from '@apollo/client'
import { render, screen, within } from '@testing-library/react'
import { render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'

import {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { render, screen } from '@testing-library/react'

import {
CaseDecision,
CaseFileCategory,
CaseType,
} from '@island.is/judicial-system-web/src/graphql/schema'
import {
mockCase,
mockCaseFile,
} from '@island.is/judicial-system-web/src/utils/mocks'
import {
ApolloProviderWrapper,
IntlProviderWrapper,
} from '@island.is/judicial-system-web/src/utils/testHelpers'

import IndictmentCaseFilesList from './IndictmentCaseFilesList'

describe('IndictmentCaseFilesList', () => {
it('should render court records if there are courtRecord case files', () => {
render(
<IntlProviderWrapper>
<ApolloProviderWrapper>
<IndictmentCaseFilesList
workingCase={{
...mockCase(CaseType.INDICTMENT),
caseFiles: [mockCaseFile(CaseFileCategory.COURT_RECORD)],
}}
/>
</ApolloProviderWrapper>
</IntlProviderWrapper>,
)

expect(screen.queryByTestId('PDFButton')).not.toBeNull()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const IndictmentCaseFilesList: FC<Props> = ({
<PdfButton
caseId={workingCase.id}
title={formatMessage(caseFiles.trafficViolationIndictmentTitle)}
pdfType={'indictment'}
pdfType="indictment"
renderAs="row"
/>
</Box>
Expand Down Expand Up @@ -184,7 +184,6 @@ const IndictmentCaseFilesList: FC<Props> = ({
/>
</Box>
)}

<Box marginBottom={5}>
<Text variant="h4" as="h4" marginBottom={1}>
{formatMessage(strings.caseFileTitle)}
Expand All @@ -196,24 +195,14 @@ const IndictmentCaseFilesList: FC<Props> = ({
title={formatMessage(strings.caseFileButtonText, {
policeCaseNumber,
})}
pdfType={'caseFilesRecord'}
pdfType="caseFilesRecord"
elementId={policeCaseNumber}
renderAs="row"
/>
</Box>
))}
</Box>

{uploadedCaseFiles && uploadedCaseFiles.length > 0 && (
<Box marginBottom={5}>
<Text variant="h4" as="h4" marginBottom={3}>
{formatMessage(strings.uploadedCaseFiles)}
</Text>
<CaseFileTable caseFiles={uploadedCaseFiles} onOpenFile={onOpen} />
</Box>
)}
{(isDistrictCourtUser(user) || isCompletedCase(workingCase.state)) &&
(courtRecords?.length || rulings?.length) ? (
{courtRecords?.length || rulings?.length ? (
<Box marginBottom={5}>
<Text variant="h4" as="h4" marginBottom={1}>
{formatMessage(strings.rulingAndCourtRecordsTitle)}
Expand All @@ -225,16 +214,25 @@ const IndictmentCaseFilesList: FC<Props> = ({
workingCase={workingCase}
/>
)}
{rulings && rulings.length > 0 && (
<RenderFiles
caseFiles={rulings}
onOpenFile={onOpen}
workingCase={workingCase}
/>
)}
{(isDistrictCourtUser(user) || isCompletedCase(workingCase.state)) &&
rulings &&
rulings.length > 0 && (
<RenderFiles
caseFiles={rulings}
onOpenFile={onOpen}
workingCase={workingCase}
/>
)}
</Box>
) : null}

{uploadedCaseFiles && uploadedCaseFiles.length > 0 && (
<Box marginBottom={5}>
<Text variant="h4" as="h4" marginBottom={3}>
{formatMessage(strings.uploadedCaseFiles)}
</Text>
<CaseFileTable caseFiles={uploadedCaseFiles} onOpenFile={onOpen} />
</Box>
)}
<AnimatePresence>
{fileNotFound && <FileNotFoundModal dismiss={dismissFileNotFound} />}
</AnimatePresence>
Expand Down

0 comments on commit b74a253

Please sign in to comment.