Skip to content

Commit

Permalink
fix(condo): DOMA-10698 fixed qr test to work with fake address client
Browse files Browse the repository at this point in the history
  • Loading branch information
dkoviazin committed Nov 25, 2024
1 parent e2552d1 commit dc05336
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
1 change: 0 additions & 1 deletion apps/condo/domains/billing/utils/receiptQRCodeUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ async function findAuxiliaryData (qrCodeFields, errors) {
const normalizedAddress = await addressServiceClient.search(getQRCodeField(qrCodeFields, 'PayerAddress'), { extractUnit: true })

if (!normalizedAddress.addressKey || !normalizedAddress.unitType || !normalizedAddress.unitName) throw errors.address

const properties = await find('Property', {
organization: { tin: getQRCodeField(qrCodeFields, 'PayeeINN'), deletedAt: null },
addressKey: normalizedAddress.addressKey,
Expand Down
12 changes: 6 additions & 6 deletions apps/condo/domains/billing/utils/receiptQRCodeUtils.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,8 @@ describe('receiptQRCodeUtils', () => {
})

test('Auxiliary data: throw an error if address not found', async () => {
const [o10n] = await createTestOrganization(adminClient)
const [property] = await createTestProperty(adminClient, o10n)
const [organization] = await createTestOrganization(adminClient)
const [property] = await createTestProperty(adminClient, organization)

const bic = createValidRuRoutingNumber()
const qrCodeObj = {
Expand All @@ -316,15 +316,15 @@ describe('receiptQRCodeUtils', () => {
PaymPeriod: '06.2024',
Sum: '10000',
PersAcc: faker.random.numeric(8),
PayeeINN: o10n.tin,
PayeeINN: organization.tin,
PersonalAcc: createValidRuNumber(bic),
}

await addBillingIntegrationAndContext(adminClient, o10n, {}, { status: CONTEXT_FINISHED_STATUS })
await addAcquiringIntegrationAndContext(adminClient, o10n, {}, { status: CONTEXT_FINISHED_STATUS })
await addBillingIntegrationAndContext(adminClient, organization, {}, { status: CONTEXT_FINISHED_STATUS })
await addAcquiringIntegrationAndContext(adminClient, organization, {}, { status: CONTEXT_FINISHED_STATUS })

await catchErrorFrom(
async () => await findAuxiliaryData({ ...qrCodeObj, PayerAddress: `${property.address}, кв` }, { address: new Error('error about address') }),
async () => await findAuxiliaryData({ ...qrCodeObj, PayerAddress: 'some-property-address' }, { address: new Error('error about address') }),
(err) => {
expect(err.message).toMatch('error about address')
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ class AddressFromStringParser {
* @returns {{housePart: string, unitPart: string}}
*/
splitByComma (input = '') {
if (input.indexOf(',') === -1) {
return {
housePart: input,
unitPart: '',
}
}
const addressParts = input.split(',').map(part => part.trim())
const unit = addressParts.pop()
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const ADDRESS_USE_CASES = [
['пр-т 100-летия Владивостока, д.32Д, НП10', 'пр-т 100-летия Владивостока, д.32Д', 'warehouse', 'НП10'],
['пр-т 100-летия Владивостока, д.32Д, НП 10', 'пр-т 100-летия Владивостока, д.32Д', 'warehouse', '10'],
['пр-т 100-летия Владивостока, домовладение 32Д клад. 10', 'пр-т 100-летия Владивостока, домовладение 32Д', 'warehouse', '10'],
['не-распознаваемая-ерунда-без-ничего', 'не-распознаваемая-ерунда-без-ничего', 'flat', ''],
]

describe('AddressFromStringParser', () => {
Expand Down

0 comments on commit dc05336

Please sign in to comment.