Skip to content

Commit

Permalink
test codes adjusted certificates
Browse files Browse the repository at this point in the history
  • Loading branch information
tareq89 committed Oct 24, 2024
1 parent aefdb7f commit 0277651
Show file tree
Hide file tree
Showing 8 changed files with 140 additions and 81 deletions.
35 changes: 20 additions & 15 deletions packages/client/src/declarations/submissionMiddleware.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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([])
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
])
})
Expand All @@ -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' }]
}
}
])
})
Expand Down
79 changes: 67 additions & 12 deletions packages/client/src/tests/util.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}
}
Expand Down Expand Up @@ -644,7 +674,7 @@ export const mockDeathDeclarationData = {
certificates: [
{
collector: {
type: 'MOTHER'
relationship: 'MOTHER'
},
hasShowedVerifiedDocument: true,
templateConfig: {
Expand Down Expand Up @@ -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'
}
}
]
}
Expand Down Expand Up @@ -827,6 +881,7 @@ export const mockDeathRegistrationSectionData = {
iD: '123456789'
},
hasShowedVerifiedDocument: true,
certificateTemplateId: 'certified-death-certificate',
templateConfig: {
id: 'certified-death-certificate',
event: 'death',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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')
})

Expand Down Expand Up @@ -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')
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ describe('verify collector tests', () => {
'Birth'
)
expect(testComponent.find('#amountDue').hostNodes().text()).toContain(
'150'
'15'
)

testComponent.find('#Continue').hostNodes().simulate('click')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
)
})

Expand Down Expand Up @@ -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'
)
})
})
Expand Down Expand Up @@ -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'
)
})

Expand Down Expand Up @@ -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'
)
})

Expand All @@ -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'
)
})

Expand Down Expand Up @@ -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'
)
})
})
Expand Down Expand Up @@ -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'
)
})
})
Expand Down

0 comments on commit 0277651

Please sign in to comment.