Skip to content

Commit

Permalink
test: fix quantidadeRegistrosLote result
Browse files Browse the repository at this point in the history
  • Loading branch information
yxuo committed Feb 27, 2024
1 parent 6ddc9a1 commit dc0e4a3
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 16 deletions.
5 changes: 4 additions & 1 deletion src/cnab/interfaces/cnab-field-map.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ export interface ICnabFieldMap {
*
* Represents"LoteServico" or similar fields.
*
* Each **Lote** has one unique combination of `tipoCompromisso` and `formaLancamento`.
* Each **Lote** has one unique combination of
* 1. `tipoCompromisso` ("serviceType"; e.g. payments, debit, collection etc); and
* 2. `formaLancamento` ("transactionType"; e.g. TED, DOC etc).
*
* The values must be:
* - **For Header Arquivo:** value is 0000.
* - **For Header/Trailer Lote and Detalhes:** Count current Lote. Example: (1, 2, 3).
* - **For Trailer Arquivo:** value is 9999.
Expand Down
4 changes: 2 additions & 2 deletions src/cnab/test/templates/240/104/example-240-104.rem
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
1040001300002B 000000000000000 00104APTO 315 CENTRO RIO DE JANEIRO 22544010RJ06022023000000000120012000000000000000000000000000000000000000000000000000000000000
1040001300003A0000001040095550031993933180 TEREZINHA SEVERIANA 000027 105022023BRL000000000000000000000000120012000000000 01N1060000000000000000000000000 01 0
1040001300004B 000000000000000 00104APTO 315 CENTRO RIO DE JANEIRO 22544010RJ06022023000000000120012000000000000000000000000000000000000000000000000000000000000
10400015 000004000000000000240024000000000000000000000000
10400015 000006000000000000240024000000000000000000000000
10400021C3001041 20001234560011111200702000201 0095550000000000032 CONVE DE PAGAMENTOSSA E PENSA RUA ALMIR PEDRAS 00000000000000000000 00000
1040002300001A0000001040095550031993933180 TEREZINHA SEVERIANA 000027 105022023BRL000000000000000000000000120012000000000 01N1060000000000000000000000000 01 0
1040002300002B 000000000000000 00104APTO 315 CENTRO RIO DE JANEIRO 22544010RJ06022023000000000120012000000000000000000000000000000000000000000000000000000000000
1040002300003A0000001040095550031993933180 TEREZINHA SEVERIANA 000027 105022023BRL000000000000000000000000120012000000000 01N1060000000000000000000000000 01 0
1040002300004B 000000000000000 00104APTO 315 CENTRO RIO DE JANEIRO 22544010RJ06022023000000000120012000000000000000000000000000000000000000000000000000000000000
1040002300005A0000001040095550031993933180 TEREZINHA SEVERIANA 000027 105022023BRL000000000000000000000000120012000000000 01N1060000000000000000000000000 01 0
1040002300006B 000000000000000 00104APTO 315 CENTRO RIO DE JANEIRO 22544010RJ06022023000000000120012000000000000000000000000000000000000000000000000000000000000
10400025 000006000000000000360036000000000000000000000000
10400025 000008000000000000360036000000000000000000000000
10499999 000002000016000000
6 changes: 3 additions & 3 deletions src/cnab/test/templates/240/generic/example-240-generic.rem
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
10001000000 00000000000000000
30001000000A00001000000000000
30001000000B00002000000000000
50001000002 00000000000000000
50001000004 00000000000000000
10002000000 00000000000000000
30002000000A00001000000000000
30002000000B00002000000000000
50002000002 00000000000000000
50002000004 00000000000000000
10003000000 00000000000000000
30003000000A00001000000000000
30003000000B00002000000000000
30003000000C00003000000000000
50003000003 00000000000000000
50003000005 00000000000000000
99999000000 00000000003000015
2 changes: 1 addition & 1 deletion src/cnab/utils/cnab-utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ describe('cnab-utils.ts', () => {
);
expect(
response.lotes[0].trailerLote.fields.quantidadeRegistrosLote.value,
).toEqual(2);
).toEqual(4);
expect(
response.trailerArquivo.fields.quantidadeLotesArquivo.value,
).toEqual(3);
Expand Down
2 changes: 1 addition & 1 deletion src/cnab/utils/cnab-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ function processCnabTrailerLote(lotes: CnabLote[], loteIndex: number) {
setCnabMappedValue(
lotes[loteIndex].trailerLote,
'trailerLoteRegistroCountField',
lotes[loteIndex].registros.length,
getCnabRegistros(lotes[loteIndex]).length,
);
}

Expand Down
10 changes: 10 additions & 0 deletions src/test/test.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,14 @@ export class TestController {
async getCronJobsBulkResendInvites() {
await this.testService.getCronJobsBulkResendInvites();
}

@Get('users/reset-testing-users')
@ApiOperation({
description:
'Only available in test environments.' +
"\n\nUsed by e2e tests to reset example users' state before testing.",
})
async getUsersResetTestUsers() {
await this.testService.getResetTestingUsers();
}
}
13 changes: 13 additions & 0 deletions src/test/test.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
import { subDays } from 'date-fns';
import { CronJobsService } from 'src/cron-jobs/cron-jobs.service';
import { InviteStatus } from 'src/mail-history-statuses/entities/mail-history-status.entity';
import { InviteStatusEnum } from 'src/mail-history-statuses/mail-history-status.enum';
import { MailHistoryService } from 'src/mail-history/mail-history.service';
import { In } from 'typeorm/find-options/operator/In';

Expand Down Expand Up @@ -35,4 +37,15 @@ export class TestService {
});
}
}

async getResetTestingUsers() {
const queuedMailName = 'queued.user@example.com';
const queuedMail = await this.mailHistoryService.getOne({
email: queuedMailName,
});
await this.mailHistoryService.update(queuedMail.id, {
sentAt: null,
inviteStatus: new InviteStatus(InviteStatusEnum.queued),
});
}
}
3 changes: 3 additions & 0 deletions test/admin/users.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ describe('Admin managing users (e2e)', () => {
* Requirement: 2023/11/16 {@link https://github.com/RJ-SMTR/api-cct/issues/94#issuecomment-1815016208 #94, item 7 - GitHub}
*/ async () => {
// Arrange
await request(app)
.get('/api/v1/test/users/reset-testing-users')
.expect(200);
const licensee = await request(app)
.get('/api/v1/users/')
.auth(apiToken, {
Expand Down
13 changes: 5 additions & 8 deletions test/ticket-revenues/ticket-revenues.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,16 @@ describe('Ticket revenues (e2e)', () => {

// get licenseeMaxDate
bq = new BigQuery({ credentials: BQ_JSON_CREDENTIALS() });
await bq
.query(
`
const query = `
SELECT
CAST(t.data AS STRING) AS partitionDate,
FROM \`rj-smtr-dev.br_rj_riodejaneiro_bilhetagem_cct.transacao\` t
LEFT JOIN \`rj-smtr-dev.cadastro.consorcios\` c ON c.id_consorcio = t.id_consorcio
WHERE c.cnpj = '${licenseeCnpj}' ORDER BY data DESC, hora DESC LIMIT 1
`,
)
.then((value) => {
licenseeCnpjMaxDate = new Date(value[0][0]?.['partitionDate']);
});
`;
await bq.query(query).then((value) => {
licenseeCnpjMaxDate = new Date(value[0][0]?.['partitionDate']);
});
expect(Number(licenseeCnpjMaxDate)).not.toBeNaN();
});

Expand Down

0 comments on commit dc0e4a3

Please sign in to comment.