Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tareq89 committed Oct 24, 2024
1 parent 5d99dce commit aefdb7f
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 121 deletions.
1 change: 1 addition & 0 deletions packages/client/src/declarations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ export type ICertificate = {
corrector?: Partial<{ type: RelationForCertificateCorrection | string }>
hasShowedVerifiedDocument?: boolean
payments?: Payment
certificateTemplateId?: string
templateConfig?: ICertificateConfigData
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,10 @@ export function setBirthRegistrationSectionTransformer(
})
}

if (
Array.isArray(draftData[sectionId].certificates) &&
draftData[sectionId].certificates.length
) {
const updatedCertificates = transformCertificateData(
(draftData[sectionId].certificates as ICertificate[]).slice(-1)
)
const certificates: ICertificate[] = draftData[sectionId]
.certificates as ICertificate[]
if (Array.isArray(certificates) && certificates.length) {
const updatedCertificates = transformCertificateData(certificates.slice(-1))
transformedData[sectionId].certificates =
updatedCertificates.length > 0 &&
Object.keys(updatedCertificates[0]).length > 0 // making sure we are not sending empty object as certificate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,11 @@ export function setDeathRegistrationSectionTransformer(
})
}

if (
Array.isArray(draftData[sectionId].certificates) &&
draftData[sectionId].certificates.length
) {
const certificates: ICertificate[] = draftData[sectionId]
.certificates as ICertificate[]
if (Array.isArray(certificates) && certificates.length) {
const updatedCertificates = transformCertificateData(
(draftData[sectionId].certificates as ICertificate[]).slice(-1)
certificates.slice(-1)
)
transformedData[sectionId].certificates =
updatedCertificates.length > 0 &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,11 @@ export function setMarriageRegistrationSectionTransformer(
})
}

if (
Array.isArray(draftData[sectionId].certificates) &&
draftData[sectionId].certificates.length > 0
) {
transformedData[sectionId].certificates =
draftData[sectionId].certificates.slice(-1)
}

if (
Array.isArray(draftData[sectionId].certificates) &&
draftData[sectionId].certificates.length
) {
const certificates: ICertificate[] = draftData[sectionId]
.certificates as ICertificate[]
if (Array.isArray(certificates) && certificates.length) {
const updatedCertificates = transformCertificateData(
(draftData[sectionId].certificates as ICertificate[]).slice(-1)
certificates.slice(-1)
)
transformedData[sectionId].certificates =
updatedCertificates.length > 0 &&
Expand Down
51 changes: 22 additions & 29 deletions packages/client/src/tests/util.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,6 @@ export const mockDeclarationData = {
},
registration: {
informantsSignature: 'data:image/png;base64,abcd',

registrationNumber: '201908122365BDSS0SE1',
regStatus: {
type: 'REGISTERED',
Expand All @@ -547,27 +546,7 @@ export const mockDeclarationData = {
officeAddressLevel3: 'Gazipur',
officeAddressLevel4: 'Dhaka'
},
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'
},

fee: {
onTime: 10,
late: 500,
delayed: 150
},
svgUrl:
'/api/countryconfig/certificates/birth-certificate-certified-copy.svg'
}
}
]
certificates: [{}]
},
documents: {}
}
Expand Down Expand Up @@ -676,7 +655,6 @@ export const mockDeathDeclarationData = {
defaultMessage: 'Death Certificate certified copy',
description: 'The label for a death certificate'
},

fee: {
onTime: 0,
late: 5.5,
Expand Down Expand Up @@ -722,7 +700,6 @@ export const mockMarriageDeclarationData = {
defaultMessage: 'Marriage Certificate certified copy',
description: 'The label for a marriage certificate'
},

fee: {
onTime: 0,
late: 5.5,
Expand Down Expand Up @@ -849,15 +826,31 @@ export const mockDeathRegistrationSectionData = {
iDType: 'PASSPORT',
iD: '123456789'
},
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'
},
fee: {
onTime: 0,
late: 5.5,
delayed: 15
},
svgUrl:
'/api/countryconfig/certificates/death-certificate-certified-copy.svg'
}
}
]
}

const mockFetchCertificatesTemplatesDefinition = [
{
id: 'birth-certificate',
event: 'birth',
event: 'birth' as Event,
label: {
id: 'certificates.birth.certificate',
defaultMessage: 'Birth Certificate',
Expand All @@ -881,7 +874,7 @@ const mockFetchCertificatesTemplatesDefinition = [
},
{
id: 'birth-certificate-copy',
event: 'birth',
event: 'birth' as Event,
label: {
id: 'certificates.birth-certificate-copy',
defaultMessage: 'Birth Certificate certified copy',
Expand All @@ -906,7 +899,7 @@ const mockFetchCertificatesTemplatesDefinition = [
},
{
id: 'death-certificate',
event: 'death',
event: 'death' as Event,
label: {
id: 'certificates.death.certificate',
defaultMessage: 'Death Certificate',
Expand All @@ -930,7 +923,7 @@ const mockFetchCertificatesTemplatesDefinition = [
},
{
id: 'marriage-certificate',
event: 'marriage',
event: 'marriage' as Event,
label: {
id: 'certificates.marriage.certificate',
defaultMessage: 'Marriage Certificate',
Expand Down
140 changes: 73 additions & 67 deletions packages/client/src/utils/gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7491,76 +7491,82 @@ export type GetRegistrationsListByFilterQueryVariables = Exact<{
size: Scalars['Int']
}>

export type RegistrationsListByLocationFilter = {
__typename: 'TotalMetricsByLocation'
total?: number | null
results: Array<{
__typename?: 'EventMetricsByLocation'
total: number
late: number
delayed: number
home: number
healthFacility: number
location: { __typename?: 'Location'; name?: string | null }
}>
}

export type RegistrationsListByRegistrarFilter = {
__typename: 'TotalMetricsByRegistrar'
total?: number | null
results: Array<{
__typename?: 'EventMetricsByRegistrar'
total: number
late: number
delayed: number
registrarPractitioner?: {
__typename?: 'User'
id: string
systemRole: SystemRoleType
role: {
__typename?: 'Role'
_id: string
labels: Array<{
__typename?: 'RoleLabel'
lang: string
label: string
}>
}
primaryOffice?: {
__typename?: 'Location'
name?: string | null
id: string
} | null
name: Array<{
__typename?: 'HumanName'
firstNames?: string | null
familyName?: string | null
use?: string | null
}>
avatar?: {
__typename?: 'Avatar'
type: string
data: string
} | null
} | null
}>
}

export type RegistrationsListByTimeFilter = {
__typename: 'TotalMetricsByTime'
total?: number | null
results: Array<{
__typename?: 'EventMetricsByTime'
total: number
delayed: number
late: number
home: number
healthFacility: number
month: string
time: string
}>
}

export type GetRegistrationsListByFilterQuery = {
__typename?: 'Query'
getRegistrationsListByFilter?:
| {
__typename: 'TotalMetricsByLocation'
total?: number | null
results: Array<{
__typename?: 'EventMetricsByLocation'
total: number
late: number
delayed: number
home: number
healthFacility: number
location: { __typename?: 'Location'; name?: string | null }
}>
}
| {
__typename: 'TotalMetricsByRegistrar'
total?: number | null
results: Array<{
__typename?: 'EventMetricsByRegistrar'
total: number
late: number
delayed: number
registrarPractitioner?: {
__typename?: 'User'
id: string
systemRole: SystemRoleType
role: {
__typename?: 'Role'
_id: string
labels: Array<{
__typename?: 'RoleLabel'
lang: string
label: string
}>
}
primaryOffice?: {
__typename?: 'Location'
name?: string | null
id: string
} | null
name: Array<{
__typename?: 'HumanName'
firstNames?: string | null
familyName?: string | null
use?: string | null
}>
avatar?: {
__typename?: 'Avatar'
type: string
data: string
} | null
} | null
}>
}
| {
__typename: 'TotalMetricsByTime'
total?: number | null
results: Array<{
__typename?: 'EventMetricsByTime'
total: number
delayed: number
late: number
home: number
healthFacility: number
month: string
time: string
}>
}
| RegistrationsListByLocationFilter
| RegistrationsListByRegistrarFilter
| RegistrationsListByTimeFilter
| null
}

Expand Down

0 comments on commit aefdb7f

Please sign in to comment.