From 0277651a9e4f7b7deaa1e8dc95065b207d5e8b4e Mon Sep 17 00:00:00 2001 From: tareq89 Date: Thu, 24 Oct 2024 21:51:48 +0600 Subject: [PATCH] test codes adjusted certificates --- .../declarations/submissionMiddleware.test.ts | 35 ++++---- .../mutation/registration-mappings.test.ts | 52 ++++++------ .../death/mutation/deceased-mappings.test.ts | 27 +++---- packages/client/src/tests/util.tsx | 79 ++++++++++++++++--- .../IssueCollectorForm/IssuePayment.test.tsx | 4 +- .../views/PrintCertificate/Payment.test.tsx | 2 +- .../PrintCertificate/VerifyCollector.test.tsx | 8 +- .../collectorForm/CollectorForm.test.tsx | 14 ++-- 8 files changed, 140 insertions(+), 81 deletions(-) diff --git a/packages/client/src/declarations/submissionMiddleware.test.ts b/packages/client/src/declarations/submissionMiddleware.test.ts index a74b063b0a9..6d55d52f3a4 100644 --- a/packages/client/src/declarations/submissionMiddleware.test.ts +++ b/packages/client/src/declarations/submissionMiddleware.test.ts @@ -143,26 +143,31 @@ describe('Submission middleware', () => { mockDeclarationData.registration.certificates[0] = { collector: { relationship: 'OTHER', - affidavit: { + affidavitFile: { contentType: 'image/jpg', data: 'data:image/png;base64,2324256' }, - individual: { - name: [{ firstNames: 'Doe', familyName: 'Jane', use: 'en' }], - identifier: [{ id: '123456', type: 'PASSPORT' }] - } + name: [{ firstNames: 'Doe', familyName: 'Jane', use: 'en' }], + identifier: [{ id: '123456', type: 'PASSPORT' }] }, hasShowedVerifiedDocument: true, - payments: [ - { - paymentId: '1234', - type: 'MANUAL', - amount: 50, - outcome: 'COMPLETED', - date: '2018-10-22' - } - ], - data: 'data:image/png;base64,2324256' + certificateTemplateId: 'certified-birth-certificate', + templateConfig: { + id: 'certified-birth-certificate', + event: 'birth', + label: { + id: 'certificates.birth.certificate.copy', + defaultMessage: 'birth Certificate certified copy', + description: 'The label for a birth certificate' + }, + fee: { + onTime: 0, + late: 5.5, + delayed: 15 + }, + svgUrl: + '/api/countryconfig/certificates/birth-certificate-certified-copy.svg' + } } const action = declarationReadyForStatusChange({ id: 'mockDeclaration', diff --git a/packages/client/src/forms/register/mappings/event-specific-fields/birth/mutation/registration-mappings.test.ts b/packages/client/src/forms/register/mappings/event-specific-fields/birth/mutation/registration-mappings.test.ts index fcedb64513c..568f3eb5177 100644 --- a/packages/client/src/forms/register/mappings/event-specific-fields/birth/mutation/registration-mappings.test.ts +++ b/packages/client/src/forms/register/mappings/event-specific-fields/birth/mutation/registration-mappings.test.ts @@ -32,46 +32,46 @@ describe('Birth registration mutation mapping related tests', () => { expect(transformedData.registration.trackingId).toEqual('BDSS0SE') expect(transformedData.registration.certificates).toEqual([ { + hasShowedVerifiedDocument: true, + certificateTemplateId: 'certified-birth-certificate', + payments: [ + { + paymentId: '1234', + type: 'MANUAL', + amount: 50, + outcome: 'COMPLETED', + date: '2018-10-22' + } + ], collector: { - relationship: 'OTHER', - otherRelationship: 'Uncle', - name: [ - { - use: 'en', - firstNames: 'Mushraful', - familyName: 'Hoque' - } - ], - identifier: [ - { - id: '123456789', - type: 'PASSPORT' - } - ], - affidavit: [ - { - contentType: 'abc', - data: 'BASE64 data' - } - ] - }, - hasShowedVerifiedDocument: true + otherRelationship: 'OTHER', + name: [{ use: 'en' }], + identifier: [{}], + affidavit: [{ data: 'data:image/png;base64,2324256' }] + } } ]) }) - it('Test certificate mapping without any data', () => { + it('Test certificate mapping template config data', () => { const transformedData: TransformedData = { registration: {} } + const mockBirthDeclaration = cloneDeep({ + ...mockDeclarationData, + registration: { + ...mockDeclarationData.registration, + certificates: [{}] + } + }) setBirthRegistrationSectionTransformer( transformedData, - mockDeclarationData, + mockBirthDeclaration, 'registration' ) expect(transformedData.registration).toBeDefined() expect(transformedData.registration.registrationNumber).toEqual( '201908122365BDSS0SE1' ) - expect(transformedData.registration.certificates).toEqual([{}]) + expect(transformedData.registration.certificates).toEqual([]) }) }) diff --git a/packages/client/src/forms/register/mappings/event-specific-fields/death/mutation/deceased-mappings.test.ts b/packages/client/src/forms/register/mappings/event-specific-fields/death/mutation/deceased-mappings.test.ts index 26fbe52da1b..2f6b31ba61b 100644 --- a/packages/client/src/forms/register/mappings/event-specific-fields/death/mutation/deceased-mappings.test.ts +++ b/packages/client/src/forms/register/mappings/event-specific-fields/death/mutation/deceased-mappings.test.ts @@ -32,10 +32,13 @@ describe('Death registration mutation mapping related tests', () => { ) expect(transformedData.registration.certificates).toEqual([ { + hasShowedVerifiedDocument: true, collector: { - relationship: 'MOTHER' + otherRelationship: 'MOTHER', + name: [{ use: 'en' }], + identifier: [{}] }, - hasShowedVerifiedDocument: true + certificateTemplateId: 'certified-death-certificate' } ]) }) @@ -54,24 +57,14 @@ describe('Death registration mutation mapping related tests', () => { expect(transformedData.registration.trackingId).toEqual('DDSS0SE') expect(transformedData.registration.certificates).toEqual([ { + hasShowedVerifiedDocument: true, + certificateTemplateId: 'certified-death-certificate', collector: { relationship: 'OTHER', otherRelationship: 'Uncle', - name: [ - { - use: 'en', - firstNames: 'Mushraful', - familyName: 'Hoque' - } - ], - identifier: [ - { - id: '123456789', - type: 'PASSPORT' - } - ] - }, - hasShowedVerifiedDocument: true + name: [{ use: 'en', firstNames: 'Mushraful', familyName: 'Hoque' }], + identifier: [{ id: '123456789', type: 'PASSPORT' }] + } } ]) }) diff --git a/packages/client/src/tests/util.tsx b/packages/client/src/tests/util.tsx index 0e2fe470d14..10699c9b275 100644 --- a/packages/client/src/tests/util.tsx +++ b/packages/client/src/tests/util.tsx @@ -546,7 +546,37 @@ export const mockDeclarationData = { officeAddressLevel3: 'Gazipur', officeAddressLevel4: 'Dhaka' }, - certificates: [{}] + certificates: [ + { + collector: { + relationship: 'OTHER', + affidavitFile: { + contentType: 'image/jpg', + data: 'data:image/png;base64,2324256' + }, + name: [{ firstNames: 'Doe', familyName: 'Jane', use: 'en' }], + identifier: [{ id: '123456', type: 'PASSPORT' }] + }, + certificateTemplateId: 'certified-birth-certificate', + hasShowedVerifiedDocument: true, + templateConfig: { + id: 'certified-birth-certificate', + event: 'birth', + label: { + id: 'certificates.birth.certificate.copy', + defaultMessage: 'birth Certificate certified copy', + description: 'The label for a birth certificate' + }, + fee: { + onTime: 0, + late: 5.5, + delayed: 15 + }, + svgUrl: + '/api/countryconfig/certificates/birth-certificate-certified-copy.svg' + } + } + ] }, documents: {} } @@ -644,7 +674,7 @@ export const mockDeathDeclarationData = { certificates: [ { collector: { - type: 'MOTHER' + relationship: 'MOTHER' }, hasShowedVerifiedDocument: true, templateConfig: { @@ -788,18 +818,42 @@ export const mockBirthRegistrationSectionData = { certificates: [ { collector: { - type: 'OTHER', - relationship: 'Uncle', - firstName: 'Mushraful', - lastName: 'Hoque', - iDType: 'PASSPORT', - iD: '123456789', + relationship: 'OTHER', affidavitFile: { - type: 'abc', - data: 'BASE64 data' - } + contentType: 'image/jpg', + data: 'data:image/png;base64,2324256' + }, + + name: [{ firstNames: 'Doe', familyName: 'Jane', use: 'en' }], + identifier: [{ id: '123456', type: 'PASSPORT' }] }, - hasShowedVerifiedDocument: true + hasShowedVerifiedDocument: true, + certificateTemplateId: 'certified-birth-certificate', + payments: [ + { + paymentId: '1234', + type: 'MANUAL', + amount: 50, + outcome: 'COMPLETED', + date: '2018-10-22' + } + ], + templateConfig: { + id: 'certified-birth-certificate', + event: 'birth', + label: { + id: 'certificates.birth.certificate.copy', + defaultMessage: 'birth Certificate certified copy', + description: 'The label for a birth certificate' + }, + fee: { + onTime: 0, + late: 5.5, + delayed: 15 + }, + svgUrl: + '/api/countryconfig/certificates/birth-certificate-certified-copy.svg' + } } ] } @@ -827,6 +881,7 @@ export const mockDeathRegistrationSectionData = { iD: '123456789' }, hasShowedVerifiedDocument: true, + certificateTemplateId: 'certified-death-certificate', templateConfig: { id: 'certified-death-certificate', event: 'death', diff --git a/packages/client/src/views/IssueCertificate/IssueCollectorForm/IssuePayment.test.tsx b/packages/client/src/views/IssueCertificate/IssueCollectorForm/IssuePayment.test.tsx index 1a8c4a62b94..4affe015586 100644 --- a/packages/client/src/views/IssueCertificate/IssueCollectorForm/IssuePayment.test.tsx +++ b/packages/client/src/views/IssueCertificate/IssueCollectorForm/IssuePayment.test.tsx @@ -88,7 +88,7 @@ describe('verify collector tests for issuance', () => { history }) expect(testComponent.find('#service').hostNodes().text()).toContain('Birth') - expect(testComponent.find('#amountDue').hostNodes().text()).toContain('20') + expect(testComponent.find('#amountDue').hostNodes().text()).toContain('15') testComponent.find('#Continue').hostNodes().simulate('click') }) @@ -140,7 +140,7 @@ describe('in case of death declaration renders issue payment component', () => { history }) expect(testComponent.find('#service').hostNodes().text()).toContain('Death') - expect(testComponent.find('#amountDue').hostNodes().text()).toContain('0.0') + expect(testComponent.find('#amountDue').hostNodes().text()).toContain('15') testComponent.find('#Continue').hostNodes().simulate('click') }) }) diff --git a/packages/client/src/views/PrintCertificate/Payment.test.tsx b/packages/client/src/views/PrintCertificate/Payment.test.tsx index e78a70a4c6e..9e9772f8973 100644 --- a/packages/client/src/views/PrintCertificate/Payment.test.tsx +++ b/packages/client/src/views/PrintCertificate/Payment.test.tsx @@ -129,7 +129,7 @@ describe('verify collector tests', () => { 'Birth' ) expect(testComponent.find('#amountDue').hostNodes().text()).toContain( - '150' + '15' ) testComponent.find('#Continue').hostNodes().simulate('click') diff --git a/packages/client/src/views/PrintCertificate/VerifyCollector.test.tsx b/packages/client/src/views/PrintCertificate/VerifyCollector.test.tsx index 5ddf04e9454..2106a1407f1 100644 --- a/packages/client/src/views/PrintCertificate/VerifyCollector.test.tsx +++ b/packages/client/src/views/PrintCertificate/VerifyCollector.test.tsx @@ -40,7 +40,13 @@ const birthDeclaration = { const deathDeclaration = { id: 'mockDeath1234', data: { - ...mockDeathDeclarationData, + ...{ + ...mockDeathDeclarationData, + deathEvent: { + ...mockDeathDeclarationData.deathEvent, + deathDate: new Date().toISOString().slice(0, 10) + } + }, history: [ { date: '2022-03-21T08:16:24.467+00:00', diff --git a/packages/client/src/views/PrintCertificate/collectorForm/CollectorForm.test.tsx b/packages/client/src/views/PrintCertificate/collectorForm/CollectorForm.test.tsx index c2325c3583a..32b2dbf0184 100644 --- a/packages/client/src/views/PrintCertificate/collectorForm/CollectorForm.test.tsx +++ b/packages/client/src/views/PrintCertificate/collectorForm/CollectorForm.test.tsx @@ -229,7 +229,7 @@ describe('Certificate collector test for a birth registration without father det }) component.update() expect(history.location.pathname).toBe( - '/print/check/6a5fd35d-01ec-4c37-976e-e055107a74a1/birth-certificate/father' + '/print/check/6a5fd35d-01ec-4c37-976e-e055107a74a1/birth/father' ) }) @@ -270,7 +270,7 @@ describe('Certificate collector test for a birth registration without father det }) component.update() expect(history.location.pathname).toBe( - '/cert/collector/6a5fd35d-01ec-4c37-976e-e055107a74a1/birth-certificate/otherCertCollector' + '/cert/collector/6a5fd35d-01ec-4c37-976e-e055107a74a1/birth/otherCertCollector' ) }) }) @@ -387,7 +387,7 @@ describe('Certificate collector test for a birth registration without father det }) it('takes the user to affedavit view', async () => { expect(history.location.pathname).toBe( - '/cert/collector/6a5fd35d-01ec-4c37-976e-e055107a74a1/birth-certificate/affidavit' + '/cert/collector/6a5fd35d-01ec-4c37-976e-e055107a74a1/birth/affidavit' ) }) @@ -439,7 +439,7 @@ describe('Certificate collector test for a birth registration without father det component.find('#submit_confirm').hostNodes().simulate('click') expect(history.location.pathname).toBe( - '/print/payment/6a5fd35d-01ec-4c37-976e-e055107a74a1/birth-certificate' + '/print/payment/6a5fd35d-01ec-4c37-976e-e055107a74a1/birth' ) }) @@ -464,7 +464,7 @@ describe('Certificate collector test for a birth registration without father det ).toHaveLength(1) component.find('#submit_confirm').hostNodes().simulate('click') expect(history.location.pathname).toBe( - '/review/6a5fd35d-01ec-4c37-976e-e055107a74a1/birth-certificate' + '/review/6a5fd35d-01ec-4c37-976e-e055107a74a1/birth' ) }) @@ -575,7 +575,7 @@ describe('Certificate collector test for a death registration', () => { $confirm.hostNodes().simulate('click') expect(history.location.pathname).toBe( - '/review/16ff35e1-3f92-4db3-b812-c402e609fb00/death-certificate' + '/review/16ff35e1-3f92-4db3-b812-c402e609fb00/death' ) }) }) @@ -632,7 +632,7 @@ describe('Certificate collector test for a marriage registration', () => { $confirm.hostNodes().simulate('click') expect(history.location.pathname).toBe( - '/review/18ff35e1-3d92-4db3-b815-c4d2e609fb23/marriage-certificate' + '/review/18ff35e1-3d92-4db3-b815-c4d2e609fb23/marriage' ) }) })