From 54015a7c55716b9d05d5060da96303956c5e9dc2 Mon Sep 17 00:00:00 2001 From: tareq89 Date: Tue, 22 Oct 2024 15:28:29 +0600 Subject: [PATCH] certTemplateId related tests updated --- packages/client/src/tests/schema.graphql | 50 +++++++++- packages/client/src/tests/templates.json | 32 ++++++ packages/client/src/tests/util.tsx | 98 ++++++++++++++++++- .../views/PrintCertificate/Payment.test.tsx | 14 +-- .../ReviewCertificateAction.test.tsx | 8 +- .../PrintCertificate/VerifyCollector.test.tsx | 14 +-- 6 files changed, 190 insertions(+), 26 deletions(-) diff --git a/packages/client/src/tests/schema.graphql b/packages/client/src/tests/schema.graphql index ade59b35fd..036d874ddb 100644 --- a/packages/client/src/tests/schema.graphql +++ b/packages/client/src/tests/schema.graphql @@ -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 { @@ -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! +} diff --git a/packages/client/src/tests/templates.json b/packages/client/src/tests/templates.json index 6f9b93b0e9..5abc85517c 100644 --- a/packages/client/src/tests/templates.json +++ b/packages/client/src/tests/templates.json @@ -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": { @@ -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": { @@ -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": { @@ -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": { diff --git a/packages/client/src/tests/util.tsx b/packages/client/src/tests/util.tsx index 222ba3e9b5..8000adafb3 100644 --- a/packages/client/src/tests/util.tsx +++ b/packages/client/src/tests/util.tsx @@ -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: {} } @@ -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' + } } ] } @@ -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' + } } ] }, @@ -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': { @@ -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: { @@ -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': { @@ -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': { diff --git a/packages/client/src/views/PrintCertificate/Payment.test.tsx b/packages/client/src/views/PrintCertificate/Payment.test.tsx index e404ed275d..e78a70a4c6 100644 --- a/packages/client/src/views/PrintCertificate/Payment.test.tsx +++ b/packages/client/src/views/PrintCertificate/Payment.test.tsx @@ -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 @@ -90,7 +90,7 @@ async function setupPaymentTest({ match={{ params: { registrationId, - certTemplateId + eventType }, isExact: true, path: '', @@ -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, @@ -129,7 +129,7 @@ describe('verify collector tests', () => { 'Birth' ) expect(testComponent.find('#amountDue').hostNodes().text()).toContain( - '20' + '150' ) testComponent.find('#Continue').hostNodes().simulate('click') @@ -143,7 +143,7 @@ describe('verify collector tests', () => { match={{ params: { registrationId: 'mockBirth', - certTemplateId: 'birth-certificate-copy' + eventType: 'birth' }, isExact: true, path: '', @@ -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, diff --git a/packages/client/src/views/PrintCertificate/ReviewCertificateAction.test.tsx b/packages/client/src/views/PrintCertificate/ReviewCertificateAction.test.tsx index 9be3eb7852..78b3a1d253 100644 --- a/packages/client/src/views/PrintCertificate/ReviewCertificateAction.test.tsx +++ b/packages/client/src/views/PrintCertificate/ReviewCertificateAction.test.tsx @@ -78,11 +78,9 @@ const marriageDeclaration = { async function setupTest({ declaration, - certTemplateId, registrationId }: { declaration: any - certTemplateId: string registrationId: string }) { global.fetch = vi.fn().mockImplementation(() => @@ -96,8 +94,7 @@ async function setupTest({ { isNavigatedInsideApp: false }, { matchParams: { - registrationId, - certTemplateId + registrationId } } ) @@ -129,7 +126,6 @@ describe('Review Certificate Tests', () => { beforeEach(async () => { component = await setupTest({ declaration: deathDeclaration, - certTemplateId: 'death-certificate', registrationId: 'mockDeath1234' }) }) @@ -146,7 +142,6 @@ describe('Review Certificate Tests', () => { beforeEach(async () => { component = await setupTest({ declaration: birthDeclaration, - certTemplateId: 'birth-certificate', registrationId: 'mockBirth1234' }) }) @@ -184,7 +179,6 @@ describe('Review Certificate Tests', () => { beforeEach(async () => { component = await setupTest({ declaration: marriageDeclaration, - certTemplateId: 'marriage-certificate', registrationId: 'mockMarriage1234' }) }) diff --git a/packages/client/src/views/PrintCertificate/VerifyCollector.test.tsx b/packages/client/src/views/PrintCertificate/VerifyCollector.test.tsx index 1a5c134813..5ddf04e945 100644 --- a/packages/client/src/views/PrintCertificate/VerifyCollector.test.tsx +++ b/packages/client/src/views/PrintCertificate/VerifyCollector.test.tsx @@ -55,14 +55,14 @@ const deathDeclaration = { // Helper function for setting up tests async function setupTest({ registrationId, - certTemplateId, + event, collector, declaration, store, history }: { registrationId: string - certTemplateId: string + event: string collector: string declaration: any store: any @@ -78,7 +78,7 @@ async function setupTest({ match={{ params: { registrationId, - certTemplateId, + eventType: event as Event, collector }, isExact: true, @@ -101,7 +101,7 @@ describe('verify collector tests', () => { beforeAll(async () => { testComponent = await setupTest({ registrationId: 'mockBirth1234', - certTemplateId: 'birth-certificate-copy', + event: 'birth', collector: 'mother', declaration: birthDeclaration, store, @@ -132,7 +132,7 @@ describe('verify collector tests', () => { beforeAll(async () => { testComponent = await setupTest({ registrationId: 'mockDeath1234', - certTemplateId: 'death-certificate', + event: 'death', collector: 'informant', declaration: deathDeclaration, store, @@ -188,7 +188,7 @@ describe('verify collector tests', () => { beforeAll(async () => { testComponent = await setupTest({ registrationId: 'mockBirth1234', - certTemplateId: 'birth-certificate-copy', + event: 'birth', collector: 'father', declaration: birthDeclaration, store, @@ -218,7 +218,7 @@ describe('verify collector tests', () => { beforeAll(async () => { testComponent = await setupTest({ registrationId: 'mockDeath1234', - certTemplateId: 'death-certificate', + event: 'death', collector: 'informant', declaration: deathDeclaration, store,