Skip to content

Commit

Permalink
certTemplateId related tests updated
Browse files Browse the repository at this point in the history
  • Loading branch information
tareq89 committed Oct 22, 2024
1 parent d5e9783 commit 54015a7
Show file tree
Hide file tree
Showing 6 changed files with 190 additions and 26 deletions.
50 changes: 48 additions & 2 deletions packages/client/src/tests/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -403,14 +403,14 @@ type Certificate {
collector: RelatedPerson
hasShowedVerifiedDocument: Boolean
payments: [Payment]
data: String
certTemplateId: String
}

input CertificateInput {
collector: RelatedPersonInput
hasShowedVerifiedDocument: Boolean
payments: [PaymentInput]
data: String
certTemplateId: String
}

enum CertificateStatus {
Expand Down Expand Up @@ -1993,3 +1993,49 @@ type WebhookPermission {
event: String!
permissions: [String!]!
}

type CertificateConfigData {
id: String!
event: String!
label: CertificateLabel!
registrationTarget: Int!
lateRegistrationTarget: Int!
printInAdvance: Boolean!
fee: CertificateFee!
svgUrl: String!
}

type CertificateLabel {
id: String!
defaultMessage: String!
description: String!
}

type CertificateFee {
onTime: Float!
late: Float!
delayed: Float!
}

input CertificateConfigDataInput {
id: String!
event: String!
label: CertificateLabelInput!
registrationTarget: Int!
lateRegistrationTarget: Int!
printInAdvance: Boolean!
fee: CertificateFeeInput!
svgUrl: String!
}

input CertificateLabelInput {
id: String!
defaultMessage: String!
description: String!
}

input CertificateFeeInput {
onTime: Float!
late: Float!
delayed: Float!
}
32 changes: 32 additions & 0 deletions packages/client/src/tests/templates.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@
"defaultMessage": "Birth Certificate",
"description": "The label for a birth certificate"
},
"registrationTarget": 30,
"lateRegistrationTarget": 365,
"printInAdvance": false,
"fee": {
"onTime": 0,
"late": 5.5,
"delayed": 15
},
"svgUrl": "/api/countryconfig/certificates/birth-certificate.svg",
"fonts": {
"Noto Sans": {
Expand All @@ -34,6 +42,14 @@
"defaultMessage": "Birth Certificate certified copy",
"description": "The label for a birth certificate"
},
"registrationTarget": 30,
"lateRegistrationTarget": 365,
"printInAdvance": false,
"fee": {
"onTime": 0,
"late": 5.5,
"delayed": 15
},
"svgUrl": "/api/countryconfig/certificates/birth-certificate-certified-copy.svg",
"fonts": {
"Noto Sans": {
Expand All @@ -52,6 +68,14 @@
"defaultMessage": "Death Certificate",
"description": "The label for a death certificate"
},
"registrationTarget": 30,
"lateRegistrationTarget": 365,
"printInAdvance": false,
"fee": {
"onTime": 0,
"late": 5.5,
"delayed": 15
},
"svgUrl": "/api/countryconfig/certificates/death-certificate.svg",
"fonts": {
"Noto Sans": {
Expand All @@ -70,6 +94,14 @@
"defaultMessage": "Marriage Certificate",
"description": "The label for a marriage certificate"
},
"registrationTarget": 30,
"lateRegistrationTarget": 365,
"printInAdvance": false,
"fee": {
"onTime": 0,
"late": 5.5,
"delayed": 15
},
"svgUrl": "/api/countryconfig/certificates/marriage-certificate.svg",
"fonts": {
"Noto Sans": {
Expand Down
98 changes: 95 additions & 3 deletions packages/client/src/tests/util.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,29 @@ export const mockDeclarationData = {
officeAddressLevel3: 'Gazipur',
officeAddressLevel4: 'Dhaka'
},
certificates: [{}]
certificates: [
{
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'
},
registrationTarget: 30,
lateRegistrationTarget: 365,
printInAdvance: true,
fee: {
onTime: 10,
late: 500,
delayed: 150
},
svgUrl:
'/api/countryconfig/certificates/birth-certificate-certified-copy.svg'
}
}
]
},
documents: {}
}
Expand Down Expand Up @@ -647,7 +669,26 @@ export const mockDeathDeclarationData = {
collector: {
type: 'MOTHER'
},
hasShowedVerifiedDocument: true
hasShowedVerifiedDocument: true,
templateConfig: {
id: 'certified-death-certificate',
event: 'death',
label: {
id: 'certificates.death.certificate.copy',
defaultMessage: 'Death Certificate certified copy',
description: 'The label for a death certificate'
},
registrationTarget: 30,
lateRegistrationTarget: 365,
printInAdvance: true,
fee: {
onTime: 0,
late: 5.5,
delayed: 15
},
svgUrl:
'/api/countryconfig/certificates/death-certificate-certified-copy.svg'
}
}
]
}
Expand Down Expand Up @@ -676,7 +717,26 @@ export const mockMarriageDeclarationData = {
collector: {
type: 'BRIDE'
},
hasShowedVerifiedDocument: true
hasShowedVerifiedDocument: true,
templateConfig: {
id: 'certified-marriage-certificate',
event: 'marriage',
label: {
id: 'certificates.marriage.certificate.copy',
defaultMessage: 'Marriage Certificate certified copy',
description: 'The label for a marriage certificate'
},
registrationTarget: 30,
lateRegistrationTarget: 365,
printInAdvance: true,
fee: {
onTime: 0,
late: 5.5,
delayed: 15
},
svgUrl:
'/api/countryconfig/certificates/marriage-certificate-certified-copy.svg'
}
}
]
},
Expand Down Expand Up @@ -809,6 +869,14 @@ const mockFetchCertificatesTemplatesDefinition = [
defaultMessage: 'Birth Certificate',
description: 'The label for a birth certificate'
},
registrationTarget: 30,
lateRegistrationTarget: 365,
printInAdvance: false,
fee: {
onTime: 0,
late: 5.5,
delayed: 15
},
svgUrl: '/api/countryconfig/certificates/birth-certificate.svg',
fonts: {
'Noto Sans': {
Expand All @@ -827,6 +895,14 @@ const mockFetchCertificatesTemplatesDefinition = [
defaultMessage: 'Birth Certificate certified copy',
description: 'The label for a birth certificate'
},
registrationTarget: 30,
lateRegistrationTarget: 365,
printInAdvance: false,
fee: {
onTime: 0,
late: 5.5,
delayed: 15
},
svgUrl:
'/api/countryconfig/certificates/birth-certificate-certified-copy.svg',
fonts: {
Expand All @@ -846,6 +922,14 @@ const mockFetchCertificatesTemplatesDefinition = [
defaultMessage: 'Death Certificate',
description: 'The label for a death certificate'
},
registrationTarget: 30,
lateRegistrationTarget: 365,
printInAdvance: false,
fee: {
onTime: 0,
late: 5.5,
delayed: 15
},
svgUrl: '/api/countryconfig/certificates/death-certificate.svg',
fonts: {
'Noto Sans': {
Expand All @@ -864,6 +948,14 @@ const mockFetchCertificatesTemplatesDefinition = [
defaultMessage: 'Marriage Certificate',
description: 'The label for a marriage certificate'
},
registrationTarget: 30,
lateRegistrationTarget: 365,
printInAdvance: false,
fee: {
onTime: 0,
late: 5.5,
delayed: 15
},
svgUrl: '/api/countryconfig/certificates/marriage-certificate.svg',
fonts: {
'Noto Sans': {
Expand Down
14 changes: 7 additions & 7 deletions packages/client/src/views/PrintCertificate/Payment.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ const deathDeclaration = {
// Helper function to set up test
async function setupPaymentTest({
registrationId,
certTemplateId,
eventType,
declaration,
store,
history,
mockLocation
}: {
registrationId: string
certTemplateId: string
eventType: string
declaration: any
store: any
history: any
Expand All @@ -90,7 +90,7 @@ async function setupPaymentTest({
match={{
params: {
registrationId,
certTemplateId
eventType
},
isExact: true,
path: '',
Expand Down Expand Up @@ -118,7 +118,7 @@ describe('verify collector tests', () => {
it('renders Payment component when mother is collector', async () => {
const testComponent = await setupPaymentTest({
registrationId: 'mockBirth1234',
certTemplateId: 'birth-certificate-copy',
eventType: 'birth',
declaration: birthDeclaration,
store,
history,
Expand All @@ -129,7 +129,7 @@ describe('verify collector tests', () => {
'Birth'
)
expect(testComponent.find('#amountDue').hostNodes().text()).toContain(
'20'
'150'
)

testComponent.find('#Continue').hostNodes().simulate('click')
Expand All @@ -143,7 +143,7 @@ describe('verify collector tests', () => {
match={{
params: {
registrationId: 'mockBirth',
certTemplateId: 'birth-certificate-copy'
eventType: 'birth'
},
isExact: true,
path: '',
Expand All @@ -170,7 +170,7 @@ describe('verify collector tests', () => {
it('renders Payment component when informant is collector', async () => {
const testComponent = await setupPaymentTest({
registrationId: 'mockDeath1234',
certTemplateId: 'death-certificate',
eventType: 'death',
declaration: deathDeclaration,
store,
history,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,9 @@ const marriageDeclaration = {

async function setupTest({
declaration,
certTemplateId,
registrationId
}: {
declaration: any
certTemplateId: string
registrationId: string
}) {
global.fetch = vi.fn().mockImplementation(() =>
Expand All @@ -96,8 +94,7 @@ async function setupTest({
{ isNavigatedInsideApp: false },
{
matchParams: {
registrationId,
certTemplateId
registrationId
}
}
)
Expand Down Expand Up @@ -129,7 +126,6 @@ describe('Review Certificate Tests', () => {
beforeEach(async () => {
component = await setupTest({
declaration: deathDeclaration,
certTemplateId: 'death-certificate',
registrationId: 'mockDeath1234'
})
})
Expand All @@ -146,7 +142,6 @@ describe('Review Certificate Tests', () => {
beforeEach(async () => {
component = await setupTest({
declaration: birthDeclaration,
certTemplateId: 'birth-certificate',
registrationId: 'mockBirth1234'
})
})
Expand Down Expand Up @@ -184,7 +179,6 @@ describe('Review Certificate Tests', () => {
beforeEach(async () => {
component = await setupTest({
declaration: marriageDeclaration,
certTemplateId: 'marriage-certificate',
registrationId: 'mockMarriage1234'
})
})
Expand Down
Loading

0 comments on commit 54015a7

Please sign in to comment.