Skip to content

Commit

Permalink
Merge branch 'main' into feat/move-and-improve-e2e-tests-web
Browse files Browse the repository at this point in the history
  • Loading branch information
svanaeinars committed Nov 20, 2024
2 parents 394c853 + 8c3f866 commit 03cdcb7
Show file tree
Hide file tree
Showing 680 changed files with 26,894 additions and 19,228 deletions.
9 changes: 7 additions & 2 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
/apps/icelandic-names-registry*/ @island-is/juni
/apps/web/screens/PetitionView/ @island-is/juni
/libs/cms/ @island-is/juni @island-is/stefna
/libs/clients/cms/ @island-is/juni @island-is/aranja
/libs/residence-history @island-is/juni
/libs/api/domains/endorsement-system @island-is/juni
/libs/api/domains/icelandic-names-registry/ @island-is/juni
Expand Down Expand Up @@ -130,6 +131,9 @@ codemagic.yaml
/apps/portals/my-pages*/ @island-is/hugsmidjan
/apps/services/regulations-admin-backend/ @island-is/hugsmidjan
/apps/services/user-profile/ @island-is/hugsmidjan @island-is/juni @island-is/aranja
/apps/web/components/Grant/ @island-is/hugsmidjan
/apps/web/components/PlazaCard/ @island-is/hugsmidjan
/apps/web/screens/Grants/ @island-is/hugsmidjan
/apps/web/screens/Regulations/ @island-is/hugsmidjan
/apps/web/components/Regulations/ @island-is/hugsmidjan
/apps/web/screens/OfficialJournalOfIceland/ @island-is/hugsmidjan
Expand Down Expand Up @@ -194,7 +198,8 @@ codemagic.yaml
/libs/portals/admin/regulations-admin/ @island-is/hugsmidjan
/libs/portals/admin/document-provider/ @island-is/hugsmidjan @island-is/core
/libs/clients/icelandic-health-insurance/rights-portal/ @island-is/hugsmidjan
/libs/clients/health-directorate @island-is/hugsmidjan @island-is/origo
/libs/clients/health-directorate @island-is/hugsmidjan
/libs/clients/health-directorate/src/lib/clients/occupational-license @island-is/hugsmidjan @island-is/origo
/libs/clients/mms/grade @island-is/hugsmidjan
/libs/portals/admin/air-discount-scheme @island-is/hugsmidjan
/libs/application/templates/official-journal-of-iceland/ @island-is/hugsmidjan
Expand Down Expand Up @@ -388,7 +393,7 @@ codemagic.yaml

# QA
/apps/system-e2e/ @island-is/qa
/libs/testing/e2e @island-is/qa
/libs/testing/e2e @island-is/qa

# Islandis
/apps/system-e2e/src/tests/islandis/admin-portal/ @island-is/aranja
Expand Down
8 changes: 4 additions & 4 deletions apps/application-system/api/infra/application-system-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,11 @@ export const serviceSetup = (services: {
})
.db()
.migrations()
.liveness('/liveness')
.readiness('/liveness')
.liveness({ path: '/liveness', initialDelaySeconds: 20 })
.readiness({ path: '/liveness', initialDelaySeconds: 20 })
.resources({
limits: { cpu: '400m', memory: '1024Mi' },
requests: { cpu: '75m', memory: '512Mi' },
limits: { cpu: '600m', memory: '1024Mi' },
requests: { cpu: '200m', memory: '512Mi' },
})
.replicaCount({
default: 2,
Expand Down
12 changes: 0 additions & 12 deletions apps/judicial-system/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,18 +226,6 @@ You can serve this service locally by running:
yarn start judicial-system-xrd-api
```

## Robot API

This service is for access through xRoad.

### Running locally

You can serve this service locally by running:

```bash
yarn start judicial-system-robot-api
```

## Digital Mailbox API

This service is for access through xRoad.
Expand Down
36 changes: 36 additions & 0 deletions apps/judicial-system/backend/src/app/formatters/formatters.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
} from '@island.is/judicial-system/types'

import {
filterWhitelistEmails,
formatCourtHeadsUpSmsNotification,
formatCourtReadyForCourtSmsNotification,
formatCourtResubmittedToCourtSmsNotification,
Expand Down Expand Up @@ -1982,3 +1983,38 @@ describe('formatDefenderResubmittedToCourtEmailNotification', () => {
expect(result.subject).toEqual('Krafa í máli R-2022/999')
})
})

describe('filterWhitelistEmails', () => {
const emails = [
'test@rvg.is',
'test2@rvg.is',
'test3@rvg.is',
'test4@example.com',
]

it('should return only whitelisted emails', () => {
const whitelist = `${emails[0]}, ${emails[2]}`
const domainWhitelist = 'example.com'

const result = filterWhitelistEmails(emails, domainWhitelist, whitelist)

expect(result).toEqual([emails[0], emails[2], emails[3]])
})

it('should return empty array if no emails are whitelisted', () => {
const whitelist = ''
const domainWhitelist = ''

const result = filterWhitelistEmails(emails, domainWhitelist, whitelist)

expect(result).toEqual([])
})
it('should return domain whitelisted emails', () => {
const whitelist = ''
const domainWhitelist = 'rvg.is'

const result = filterWhitelistEmails(emails, domainWhitelist, whitelist)

expect(result).toEqual([emails[0], emails[1], emails[2]])
})
})
71 changes: 28 additions & 43 deletions apps/judicial-system/backend/src/app/formatters/formatters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -668,49 +668,6 @@ export const formatCustodyRestrictions = (
})
}

export const formatAdvocateAssignedEmailNotification = (
formatMessage: FormatMessage,
theCase: Case,
advocateType: AdvocateType,
overviewUrl?: string,
): SubjectAndBody => {
const subject =
advocateType === AdvocateType.DEFENDER
? formatMessage(
notifications.advocateAssignedEmail.subjectAccessToCaseFiles,
{
court: capitalize(theCase.court?.name ?? ''),
},
)
: formatMessage(notifications.advocateAssignedEmail.subjectAccess, {
courtCaseNumber: theCase.courtCaseNumber,
})

const body =
advocateType === AdvocateType.DEFENDER
? formatMessage(
notifications.advocateAssignedEmail.bodyAccessToCaseFiles,
{
defenderHasAccessToRVG: Boolean(overviewUrl),
courtCaseNumber: capitalize(theCase.courtCaseNumber ?? ''),
court: theCase.court?.name ?? '',
courtName: theCase.court?.name.replace('dómur', 'dómi') ?? '',
linkStart: `<a href="${overviewUrl}">`,
linkEnd: '</a>',
},
)
: formatMessage(notifications.advocateAssignedEmail.bodyAccess, {
defenderHasAccessToRVG: Boolean(overviewUrl),
court: theCase.court?.name,
advocateType,
courtCaseNumber: capitalize(theCase.courtCaseNumber ?? ''),
linkStart: `<a href="${overviewUrl}">`,
linkEnd: '</a>',
})

return { body, subject }
}

export const formatCourtOfAppealJudgeAssignedEmailNotification = (
formatMessage: FormatMessage,
caseNumber: string,
Expand Down Expand Up @@ -802,3 +759,31 @@ export const formatDefenderRoute = (

export const formatConfirmedIndictmentKey = (key?: string) =>
key?.replace(/\/([^/]*)$/, '/confirmed/$1') ?? ''

export const filterWhitelistEmails = (
emails: string[],
domainWhitelist: string,
emailWhitelist: string,
) => {
if (!emails || emails.length === 0) return []

const allowedDomains = new Set(
domainWhitelist
.split(',')
.map((d) => d.trim())
.filter(Boolean),
)
const allowedEmails = new Set(
emailWhitelist
.split(',')
.map((e) => e.trim())
.filter(Boolean),
)

return emails.filter((email) => {
const domain = email.split('@')[1]
return (
domain && (allowedDomains.has(domain) || allowedEmails.has(email.trim()))
)
})
}
2 changes: 1 addition & 1 deletion apps/judicial-system/backend/src/app/formatters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ export {
formatProsecutorReceivedByCourtSmsNotification,
formatDefenderCourtDateLinkEmailNotification,
formatDefenderResubmittedToCourtEmailNotification,
formatAdvocateAssignedEmailNotification,
formatCourtIndictmentReadyForCourtEmailNotification,
formatDefenderRoute,
formatDefenderReadyForCourtEmailNotification,
formatCourtOfAppealJudgeAssignedEmailNotification,
formatPostponedCourtDateEmailNotification,
stripHtmlTags,
filterWhitelistEmails,
} from './formatters'
export { Confirmation } from './pdfHelpers'
export { getRequestPdfAsBuffer, getRequestPdfAsString } from './requestPdf'
Expand Down
36 changes: 10 additions & 26 deletions apps/judicial-system/backend/src/app/messages/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ export const notifications = {
'Hægt er að nálgast yfirlitssíðu málsins á <a href="https://rettarvorslugatt.island.is">rettarvorslugatt.island.is</a>.',
description: 'Notaður sem texti í email til þess að tilgreina slóð á RVG',
}),
emailWhitelist: defineMessage({
id: 'judicial.system.backend:notifications.email_whitelist',
defaultMessage: '',
description: 'Notað til að tilgreina hvort póstfang sé í hvítlista',
}),
emailWhitelistDomains: defineMessage({
id: 'judicial.system.backend:notifications.email_whitelist_domains',
defaultMessage: 'omnitrix.is,kolibri.is',
description: 'Notað til að tilgreina hvort póstfang sé í hvítlista',
}),
readyForCourt: defineMessages({
subject: {
id: 'judicial.system.backend:notifications.ready_for_court.subjectV2',
Expand Down Expand Up @@ -607,32 +617,6 @@ export const notifications = {
'Notaður sem texti í tölvupósti til verjanda vegna breytingar á lengd gæslu/einangrunar/vistunar þar sem úrskurðað var í einangrun.',
},
}),
advocateAssignedEmail: defineMessages({
subjectAccessToCaseFiles: {
id: 'judicial.system.backend:notifications.defender_assigned_email.subject_access_to_case_files',
defaultMessage: '{court} - aðgangur að málsgögnum',
description:
'Fyrirsögn í pósti til verjanda þegar hann er skráður á mál.',
},
subjectAccess: {
id: 'judicial.system.backend:notifications.defender_assigned_email.subject_access',
defaultMessage: 'Skráning í máli {courtCaseNumber}',
description:
'Fyrirsögn í pósti til verjanda þegar hann er skráður á mál.',
},
bodyAccessToCaseFiles: {
id: 'judicial.system.backend:notifications.defender_assigned_email.body_access_to_case_files',
defaultMessage:
'{court} hefur skráð þig verjanda í máli {courtCaseNumber}.<br /><br />{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}.<br /><br />{defenderHasAccessToRVG, select, true {Sjá nánar á {linkStart}yfirlitssíðu málsins í Réttarvörslugátt{linkEnd}} other {Þú getur nálgast málið hjá {courtName}.}}.',
description: 'Texti í pósti til verjanda þegar hann er skráður á mál.',
},
}),
defendantsNotUpdatedAtCourt: defineMessages({
subject: {
id: 'judicial.system.backend:notifications.defendants_not_updated_at_court.subject',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,10 @@ import {
} from '@island.is/judicial-system/formatters'
import type { User } from '@island.is/judicial-system/types'
import {
CaseAppealRulingDecision,
CaseDecision,
CaseState,
CaseTransition,
CaseType,
indictmentCases,
investigationCases,
isRestrictionCase,
restrictionCases,
UserRole,
} from '@island.is/judicial-system/types'
Expand Down
Loading

0 comments on commit 03cdcb7

Please sign in to comment.