Skip to content

Commit

Permalink
Merge branch 'main' into feat/admin-signature-lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
juni-haukur committed Oct 3, 2024
2 parents 548a498 + a31e5ff commit 782e435
Show file tree
Hide file tree
Showing 216 changed files with 7,551 additions and 639 deletions.
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ codemagic.yaml
/libs/api/domains/official-journal-of-iceland-application/ @island-is/hugsmidjan
/libs/api/domains/document-provider/ @island-is/hugsmidjan @island-is/core
/libs/api/domains/housing-benefits/ @island-is/hugsmidjan
/libs/api/domains/law-and-order/ @island-is/hugsmidjan
/libs/clients/documents/ @island-is/hugsmidjan
/libs/clients/documents-v2/ @island-is/hugsmidjan
/libs/clients/finance/ @island-is/hugsmidjan
Expand Down Expand Up @@ -198,6 +199,7 @@ codemagic.yaml
/libs/portals/admin/air-discount-scheme @island-is/hugsmidjan
/libs/application/templates/official-journal-of-iceland/ @island-is/hugsmidjan
/libs/application/template-api-modules/src/lib/modules/templates/official-journal-of-iceland/ @island-is/hugsmidjan
/libs/clients/judicial-system-sp/ @island-is/hugsmidjan
/libs/application/templates/data-protection-complaint/ @island-is/norda
/libs/application/templates/institution-collaboration/ @island-is/norda @island-is/fuglar
/libs/application/templates/login-service/ @island-is/norda
Expand Down
2 changes: 2 additions & 0 deletions apps/api/infra/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import {
UniversityCareers,
OfficialJournalOfIceland,
OfficialJournalOfIcelandApplication,
JudicialSystemServicePortal,
Frigg,
HealthDirectorateOrganDonation,
HealthDirectorateVaccination,
Expand Down Expand Up @@ -432,6 +433,7 @@ export const serviceSetup = (services: {
SignatureCollection,
SocialInsuranceAdministration,
OfficialJournalOfIceland,
JudicialSystemServicePortal,
OfficialJournalOfIcelandApplication,
Frigg,
HealthDirectorateOrganDonation,
Expand Down
6 changes: 5 additions & 1 deletion apps/api/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@ import {
} from '@island.is/clients/university-careers'
import { HousingBenefitsConfig } from '@island.is/clients/hms-housing-benefits'
import { UserProfileClientConfig } from '@island.is/clients/user-profile'
import { LawAndOrderModule } from '@island.is/api/domains/law-and-order'
import { UltravioletRadiationClientConfig } from '@island.is/clients/ultraviolet-radiation'
import { JudicialSystemSPClientConfig } from '@island.is/clients/judicial-system-sp'
import { CriminalRecordClientConfig } from '@island.is/clients/criminal-record'
import { HealthInsuranceV2ClientConfig } from '@island.is/clients/icelandic-health-insurance/health-insurance'
import { VmstClientConfig } from '@island.is/clients/vmst'
Expand Down Expand Up @@ -328,6 +330,7 @@ const environment = getConfig
AuthAdminModule,
HousingBenefitCalculatorModule,
SignatureCollectionModule,
LawAndOrderModule,
UmbodsmadurSkuldaraModule,
HealthDirectorateModule,
ConfigModule.forRoot({
Expand Down Expand Up @@ -419,11 +422,12 @@ const environment = getConfig
LicenseConfig,
UserProfileClientConfig,
UltravioletRadiationClientConfig,
JudicialSystemSPClientConfig,
FriggClientConfig,
GradeClientConfig,
VmstClientConfig,
HealthInsuranceV2ClientConfig,
CriminalRecordClientConfig,
HealthInsuranceV2ClientConfig,
UmbodsmadurSkuldaraClientConfig,
emailModuleConfig,
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,114 +1,199 @@
import {
getApplicantName,
getApplicationNameTranslationString,
getApplicationStatisticsNameTranslationString,
getPaymentStatusForAdmin,
} from './application'
import {
createApplication,
createApplicationTemplate,
} from '@island.is/application/testing'

describe('Testing utility functions for applicatios', () => {
it('Should return unpaid when not fulfilled and payment created date defined', () => {
expect(
getPaymentStatusForAdmin({ fulfilled: false, created: new Date() }),
).toEqual('unpaid')
})
describe('Testing utility functions for applications', () => {
describe('getPaymentStatusForAdmin', () => {
it('Should return unpaid when not fulfilled and payment created date defined', () => {
expect(
getPaymentStatusForAdmin({ fulfilled: false, created: new Date() }),
).toEqual('unpaid')
})

it('Should return paid when fulfilled and payment created date defined', () => {
expect(
getPaymentStatusForAdmin({ fulfilled: true, created: new Date() }),
).toEqual('paid')
})
it('Should return paid when fulfilled and payment created date defined', () => {
expect(
getPaymentStatusForAdmin({ fulfilled: true, created: new Date() }),
).toEqual('paid')
})

it('Should return null when payment object is not defined', () => {
expect(getPaymentStatusForAdmin(null)).toEqual(null)
it('Should return null when payment object is not defined', () => {
expect(getPaymentStatusForAdmin(null)).toEqual(null)
})
})

it('Should return the applicant name when nationalRegistry has a fullName', () => {
expect(
getApplicantName(
createApplication({
externalData: {
nationalRegistry: {
data: {
fullName: 'Test User',
describe('getApplicantName', () => {
it('Should return the applicant name when nationalRegistry has a fullName', () => {
expect(
getApplicantName(
createApplication({
externalData: {
nationalRegistry: {
data: {
fullName: 'Test User',
},
date: new Date(),
status: 'success',
},
date: new Date(),
status: 'success',
},
},
}),
),
).toEqual('Test User')
})
}),
),
).toEqual('Test User')
})

it('Should return name of the applicant when identity external data is defined', () => {
expect(
getApplicantName(
createApplication({
externalData: {
identity: {
data: {
name: 'Test User',
},
date: new Date(),
status: 'success',
},
},
}),
),
).toEqual('Test User')
})

it('Should return name of the applicantt when identity external data is defined', () => {
expect(
getApplicantName(
createApplication({
externalData: {
identity: {
data: {
name: 'Test User',
it('Should return name of the applicant when person external data is defined', () => {
expect(
getApplicantName(
createApplication({
externalData: {
person: {
data: {
fullname: 'Test User',
},
date: new Date(),
status: 'success',
},
date: new Date(),
status: 'success',
},
},
}),
),
).toEqual('Test User')
}),
),
).toEqual('Test User')
})

it('Should return null when no external data is defined', () => {
expect(
getApplicantName(
createApplication({
externalData: {},
}),
),
).toBeNull()
})
})
})

it('Should return the name of the application when defined with a string', () => {
expect(
getApplicationNameTranslationString(
createApplicationTemplate(),
createApplication({
externalData: {
identity: {
data: {
name: 'Test User',
describe('getApplicationNameTranslationString', () => {
it('Should return the name of the application when defined with a string', () => {
expect(
getApplicationNameTranslationString(
createApplicationTemplate(),
createApplication({
externalData: {
identity: {
data: {
name: 'Test User',
},
date: new Date(),
status: 'success',
},
},
date: new Date(),
status: 'success',
},
},
}),
(message) => message as any,
),
).toEqual('Test application')
})
}),
(message) => message as any,
),
).toEqual('Test application')
})

it('Should return name of the application according to applicant age', () => {
expect(
getApplicationNameTranslationString(
createApplicationTemplate({
name: (application) =>
Number(application.answers.age) >= 20
? 'Adult Application'
: 'Child Application',
}),
createApplication({
answers: {
age: 20,
},
}),
(message) => message as any,
),
).toEqual('Adult Application')
})
it('Should return the correct application name based on a predefined age threshold', () => {
expect(
getApplicationNameTranslationString(
createApplicationTemplate({
name: (application) =>
Number(application.answers.age) >= 20
? 'Adult Application'
: 'Child Application',
}),
createApplication({
answers: {
age: 20,
},
}),
(message) => message as any,
),
).toEqual('Adult Application')
})

it('Should return name of the application according to applicant age', () => {
expect(
getApplicationNameTranslationString(
createApplicationTemplate({
name: 'Normal Application',
}),
createApplication(),
(message) => message as any,
),
).toEqual('Normal Application')
it('Should return the name of the application when defined with a static string', () => {
expect(
getApplicationNameTranslationString(
createApplicationTemplate({
name: 'Normal Application',
}),
createApplication(),
(message) => message as any,
),
).toEqual('Normal Application')
})

describe('getApplicationStatisticsNameTranslationString', () => {
const applicationStatistics = {
typeid: 'test',
count: 1,
draft: 1,
inprogress: 1,
completed: 1,
rejected: 1,
approved: 1,
}
it('Should return the translated name of the application statistics when defined with a string', () => {
expect(
getApplicationStatisticsNameTranslationString(
createApplicationTemplate({
name: 'test name',
}),
applicationStatistics,
(message) => (message + ' formatted') as string,
),
).toEqual('test name formatted')
})

it('Should return the translated name of the application statistics when defined with a function', () => {
expect(
getApplicationStatisticsNameTranslationString(
createApplicationTemplate({
name: (application) => application.typeId + ' name',
}),
applicationStatistics,
(message) => (message + ' formatted') as string,
),
).toEqual('test name formatted')
})

it('Should return the translated name of the application statistics when defined with a function that returns an object', () => {
expect(
getApplicationStatisticsNameTranslationString(
createApplicationTemplate({
name: (application) => ({
name: application.typeId + ' name',
value: '1',
}),
}),
applicationStatistics,
(message, value) => `${message} ${value?.value} formatted`,
),
).toEqual('test name 1 formatted')
})
})
})
})
Loading

0 comments on commit 782e435

Please sign in to comment.