Skip to content

Commit

Permalink
fix: query to ticket-revenues
Browse files Browse the repository at this point in the history
- test: ticket-revenues should return results
  • Loading branch information
yxuo committed Jan 24, 2024
1 parent a181430 commit 48de08b
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/ticket-revenues/ticket-revenues.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,9 @@ export class TicketRevenuesService {
t.stop_lon AS stopLon,
t.valor_transacao AS transactionValue,
t.versao AS bqDataVersion
FROM \`rj-smtr.br_rj_riodejaneiro_bilhetagem.transacao\` t` +
`\nLEFT JOIN \`rj-smtr.cadastro.operadoras\` o ON o.id_operadora = t.operadora ` +
FROM \`rj-smtr.br_rj_riodejaneiro_bilhetagem.transacao\` t
LEFT JOIN \`rj-smtr.cadastro.operadoras\` o ON o.id_operadora = t.id_operadora` +
' ' +
(queryBuilderStr.length ? `\nWHERE ${queryBuilderStr}` : '') +
`\nORDER BY data DESC, hora DESC` +
(args?.limit !== undefined ? `\nLIMIT ${args.limit}` : '') +
Expand Down
47 changes: 47 additions & 0 deletions test/ticket-revenues/ticket-revenues.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { subDays } from 'date-fns';
import * as request from 'supertest';
import { getDateYMDString } from '../../src/utils/date-utils';
import {
APP_URL,
LICENSEE_PASSWORD,
LICENSEE_PERMIT_CODE,
} from '../utils/constants';

describe('Ticket revenues (e2e)', () => {
const app = APP_URL;
let apiToken: any;

beforeAll(async () => {
await request(app)
.post('/api/v1/auth/licensee/login')
.send({ permitCode: LICENSEE_PERMIT_CODE, password: LICENSEE_PASSWORD })
.expect(200)
.then(({ body }) => {
apiToken = body.token;
});
});

it('should return some user result in /ticket-revenues/me', async () => {
// Arrange
const startDate = subDays(new Date(), 366);

// Act
let ticketRevenuesMe: any;
await request(app)
.get('/api/v1/ticket-revenues/me')
.auth(apiToken, {
type: 'bearer',
})
.query({
startDate: getDateYMDString(startDate),
endDate: getDateYMDString(new Date()),
})
.expect(200)
.then(({ body }) => {
ticketRevenuesMe = body;
});

// Assert
expect(ticketRevenuesMe.data.length).toBeGreaterThan(0);
}, 60000);
});

0 comments on commit 48de08b

Please sign in to comment.