From 83928f7fa6d212359e3fc16dc7e990b3c8da51fc Mon Sep 17 00:00:00 2001 From: hfhelgason Date: Thu, 12 Dec 2024 16:06:35 +0000 Subject: [PATCH 1/3] feat(new-primary-school): Add mock users for testing application --- .../national-registry-x-road/src/index.ts | 1 + .../new-primary-school-mock-users.ts | 56 +++++++++++++++++++ .../new-primary-school.service.ts | 11 +++- 3 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 libs/application/template-api-modules/src/lib/modules/templates/new-primary-school/new-primary-school-mock-users.ts diff --git a/libs/api/domains/national-registry-x-road/src/index.ts b/libs/api/domains/national-registry-x-road/src/index.ts index 0f9952169cac..a29e3dc34fbe 100644 --- a/libs/api/domains/national-registry-x-road/src/index.ts +++ b/libs/api/domains/national-registry-x-road/src/index.ts @@ -1,2 +1,3 @@ export * from './lib/nationalRegistryXRoad.module' export * from './lib/nationalRegistryXRoad.service' +export { NationalRegistryPerson } from './models/nationalRegistryPerson.model' diff --git a/libs/application/template-api-modules/src/lib/modules/templates/new-primary-school/new-primary-school-mock-users.ts b/libs/application/template-api-modules/src/lib/modules/templates/new-primary-school/new-primary-school-mock-users.ts new file mode 100644 index 000000000000..f21a216a854b --- /dev/null +++ b/libs/application/template-api-modules/src/lib/modules/templates/new-primary-school/new-primary-school-mock-users.ts @@ -0,0 +1,56 @@ +import { NationalRegistryPerson } from '@island.is/api/domains/national-registry-x-road' + +export const mockedUsers: Record = { + '0101303019': [ + { + nationalId: '1111111119', + fullName: 'Stubbur Maack', + genderCode: '3', + livesWithApplicant: true, + livesWithBothParents: true, + }, + ], + '0101302989': [ + { + nationalId: '2222222229', + fullName: 'Stúfur Maack ', + genderCode: '3', + livesWithApplicant: true, + livesWithBothParents: true, + otherParent: { + nationalId: '0101302399', + fullName: 'Gervimaður Færeyjar', + address: { + streetName: 'Hvassaleiti 5', + postalCode: '103', + city: 'Reykjavík', + municipalityCode: '0000', + }, + genderCode: '2', + }, + }, + { + nationalId: '5555555559', + fullName: 'Bína Maack ', + genderCode: '4', + livesWithApplicant: true, + livesWithBothParents: true, + }, + { + nationalId: '6666666669', + fullName: 'Snúður Maack', + genderCode: '3', + livesWithApplicant: true, + livesWithBothParents: true, + }, + ], + '0101304929': [ + { + nationalId: '6666666669', + fullName: 'Snúður Maack', + genderCode: '3', + livesWithApplicant: true, + livesWithBothParents: true, + }, + ], +} diff --git a/libs/application/template-api-modules/src/lib/modules/templates/new-primary-school/new-primary-school.service.ts b/libs/application/template-api-modules/src/lib/modules/templates/new-primary-school/new-primary-school.service.ts index 80ce338d5cd2..c18b4c7327c7 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/new-primary-school/new-primary-school.service.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/new-primary-school/new-primary-school.service.ts @@ -13,6 +13,8 @@ import { TemplateApiModuleActionProps } from '../../../types' import { BaseTemplateApiService } from '../../base-template-api.service' import { transformApplicationToNewPrimarySchoolDTO } from './new-primary-school.utils' import { isRunningOnEnvironment } from '@island.is/shared/utils' +import { isRunningInProduction } from '../parental-leave/constants' +import { mockedUsers } from './new-primary-school-mock-users' @Injectable() export class NewPrimarySchoolService extends BaseTemplateApiService { @@ -38,6 +40,12 @@ export class NewPrimarySchoolService extends BaseTemplateApiService { } async getChildren({ auth }: TemplateApiModuleActionProps) { + if (!isRunningInProduction) { + const mockedUser = mockedUsers[auth.nationalId] + if (mockedUser) { + return mockedUser + } + } const children = await this.nationalRegistryService.getChildrenCustodyInformation(auth) @@ -85,7 +93,8 @@ export class NewPrimarySchoolService extends BaseTemplateApiService { 400, ) } - + console.log({ filteredChildren }) + filteredChildren[0].genderCode return filteredChildren } From bb0ad16b2914ea5528be22164760146949c457ef Mon Sep 17 00:00:00 2001 From: hfhelgason Date: Thu, 12 Dec 2024 16:08:44 +0000 Subject: [PATCH 2/3] remove console log --- .../templates/new-primary-school/new-primary-school.service.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libs/application/template-api-modules/src/lib/modules/templates/new-primary-school/new-primary-school.service.ts b/libs/application/template-api-modules/src/lib/modules/templates/new-primary-school/new-primary-school.service.ts index c18b4c7327c7..1b1389715cab 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/new-primary-school/new-primary-school.service.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/new-primary-school/new-primary-school.service.ts @@ -93,8 +93,7 @@ export class NewPrimarySchoolService extends BaseTemplateApiService { 400, ) } - console.log({ filteredChildren }) - filteredChildren[0].genderCode + return filteredChildren } From 0db5122f4859382272adac8545f7413831bc0a2e Mon Sep 17 00:00:00 2001 From: hfhelgason Date: Mon, 16 Dec 2024 09:51:43 +0000 Subject: [PATCH 3/3] Removed mock user file --- .../national-registry-x-road/src/index.ts | 1 - .../new-primary-school-mock-users.ts | 56 ----------------- .../new-primary-school.service.ts | 61 +++++++++++++++++-- 3 files changed, 57 insertions(+), 61 deletions(-) delete mode 100644 libs/application/template-api-modules/src/lib/modules/templates/new-primary-school/new-primary-school-mock-users.ts diff --git a/libs/api/domains/national-registry-x-road/src/index.ts b/libs/api/domains/national-registry-x-road/src/index.ts index a29e3dc34fbe..0f9952169cac 100644 --- a/libs/api/domains/national-registry-x-road/src/index.ts +++ b/libs/api/domains/national-registry-x-road/src/index.ts @@ -1,3 +1,2 @@ export * from './lib/nationalRegistryXRoad.module' export * from './lib/nationalRegistryXRoad.service' -export { NationalRegistryPerson } from './models/nationalRegistryPerson.model' diff --git a/libs/application/template-api-modules/src/lib/modules/templates/new-primary-school/new-primary-school-mock-users.ts b/libs/application/template-api-modules/src/lib/modules/templates/new-primary-school/new-primary-school-mock-users.ts deleted file mode 100644 index f21a216a854b..000000000000 --- a/libs/application/template-api-modules/src/lib/modules/templates/new-primary-school/new-primary-school-mock-users.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { NationalRegistryPerson } from '@island.is/api/domains/national-registry-x-road' - -export const mockedUsers: Record = { - '0101303019': [ - { - nationalId: '1111111119', - fullName: 'Stubbur Maack', - genderCode: '3', - livesWithApplicant: true, - livesWithBothParents: true, - }, - ], - '0101302989': [ - { - nationalId: '2222222229', - fullName: 'Stúfur Maack ', - genderCode: '3', - livesWithApplicant: true, - livesWithBothParents: true, - otherParent: { - nationalId: '0101302399', - fullName: 'Gervimaður Færeyjar', - address: { - streetName: 'Hvassaleiti 5', - postalCode: '103', - city: 'Reykjavík', - municipalityCode: '0000', - }, - genderCode: '2', - }, - }, - { - nationalId: '5555555559', - fullName: 'Bína Maack ', - genderCode: '4', - livesWithApplicant: true, - livesWithBothParents: true, - }, - { - nationalId: '6666666669', - fullName: 'Snúður Maack', - genderCode: '3', - livesWithApplicant: true, - livesWithBothParents: true, - }, - ], - '0101304929': [ - { - nationalId: '6666666669', - fullName: 'Snúður Maack', - genderCode: '3', - livesWithApplicant: true, - livesWithBothParents: true, - }, - ], -} diff --git a/libs/application/template-api-modules/src/lib/modules/templates/new-primary-school/new-primary-school.service.ts b/libs/application/template-api-modules/src/lib/modules/templates/new-primary-school/new-primary-school.service.ts index 1b1389715cab..15b415938eec 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/new-primary-school/new-primary-school.service.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/new-primary-school/new-primary-school.service.ts @@ -14,7 +14,6 @@ import { BaseTemplateApiService } from '../../base-template-api.service' import { transformApplicationToNewPrimarySchoolDTO } from './new-primary-school.utils' import { isRunningOnEnvironment } from '@island.is/shared/utils' import { isRunningInProduction } from '../parental-leave/constants' -import { mockedUsers } from './new-primary-school-mock-users' @Injectable() export class NewPrimarySchoolService extends BaseTemplateApiService { @@ -41,9 +40,63 @@ export class NewPrimarySchoolService extends BaseTemplateApiService { async getChildren({ auth }: TemplateApiModuleActionProps) { if (!isRunningInProduction) { - const mockedUser = mockedUsers[auth.nationalId] - if (mockedUser) { - return mockedUser + if (auth.nationalId === '0101303019') { + return [ + { + nationalId: '1111111119', + fullName: 'Stubbur Maack', + genderCode: '3', + livesWithApplicant: true, + livesWithBothParents: true, + }, + ] + } + if (auth.nationalId === '0101302989') { + return [ + { + nationalId: '2222222229', + fullName: 'Stúfur Maack ', + genderCode: '3', + livesWithApplicant: true, + livesWithBothParents: true, + otherParent: { + nationalId: '0101302399', + fullName: 'Gervimaður Færeyjar', + address: { + streetName: 'Hvassaleiti 5', + postalCode: '103', + city: 'Reykjavík', + municipalityCode: '0000', + }, + genderCode: '2', + }, + }, + { + nationalId: '5555555559', + fullName: 'Bína Maack ', + genderCode: '4', + livesWithApplicant: true, + livesWithBothParents: true, + }, + { + nationalId: '6666666669', + fullName: 'Snúður Maack', + genderCode: '3', + livesWithApplicant: true, + livesWithBothParents: true, + }, + ] + } + if (auth.nationalId === '0101304929') { + return [ + { + nationalId: '6666666669', + fullName: 'Snúður Maack', + genderCode: '3', + livesWithApplicant: true, + livesWithBothParents: true, + }, + ] } } const children =