From eb932cfc2941dc04f034146ee03fbae30c2574d6 Mon Sep 17 00:00:00 2001 From: muntaxir4 Date: Sun, 28 Jul 2024 15:06:01 +0530 Subject: [PATCH] Improve e2e test and fix explicit number conversions --- apps/api/src/integration/integration.e2e.spec.ts | 6 +++++- apps/api/src/integration/service/integration.service.ts | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/apps/api/src/integration/integration.e2e.spec.ts b/apps/api/src/integration/integration.e2e.spec.ts index 28057620..ec15adaa 100644 --- a/apps/api/src/integration/integration.e2e.spec.ts +++ b/apps/api/src/integration/integration.e2e.spec.ts @@ -26,6 +26,7 @@ import { MAIL_SERVICE } from '../mail/services/interface.service' import { MockMailService } from '../mail/services/mock.service' import { EnvironmentModule } from '../environment/environment.module' import { EnvironmentService } from '../environment/service/environment.service' +import { QueryTransformPipe } from '../common/query.transform.pipe' describe('Integration Controller Tests', () => { let app: NestFastifyApplication @@ -66,6 +67,8 @@ describe('Integration Controller Tests', () => { projectService = moduleRef.get(ProjectService) environmentService = moduleRef.get(EnvironmentService) + app.useGlobalPipes(new QueryTransformPipe()) + await app.init() await app.getHttpAdapter().getInstance().ready() }) @@ -602,7 +605,7 @@ describe('Integration Controller Tests', () => { it('should be able to fetch all integrations on first page', async () => { const result = await app.inject({ method: 'GET', - url: `/integration/all/${workspace1.id}`, + url: `/integration/all/${workspace1.id}?page=0&limit=10`, headers: { 'x-e2e-user-email': user1.email } @@ -613,6 +616,7 @@ describe('Integration Controller Tests', () => { //check metadata const metadata = result.json().metadata + expect(metadata.totalCount).toEqual(1) expect(metadata.links.self).toEqual( `/integration/all/${workspace1.id}?page=0&limit=10&sort=name&order=asc&search=` ) diff --git a/apps/api/src/integration/service/integration.service.ts b/apps/api/src/integration/service/integration.service.ts index 6640b378..e54f0b0e 100644 --- a/apps/api/src/integration/service/integration.service.ts +++ b/apps/api/src/integration/service/integration.service.ts @@ -297,7 +297,7 @@ export class IntegrationService { ] }, skip: page * limit, - take: Number(limit), + take: limit, orderBy: { [sort]: order } @@ -323,8 +323,8 @@ export class IntegrationService { } }) const metadata = paginate(totalCount, `/integration/all/${workspaceId}`, { - page: Number(page), - limit: Number(limit), + page, + limit, sort, order, search