From c8a281ef0626a570a48c3fcf4b135bb680ae60c8 Mon Sep 17 00:00:00 2001 From: Tiago Yamamoto Date: Wed, 24 Dec 2025 13:53:30 -0300 Subject: [PATCH] fix(auth): correct seeder pepper and add backoffice e2e tests --- backoffice/test/admin.e2e-spec.ts | 53 +++++++++++++++++++++++++++++++ backoffice/test/plans.e2e-spec.ts | 44 +++++++++++++++++++++++++ seeder-api/.env.example | 1 + 3 files changed, 98 insertions(+) create mode 100644 backoffice/test/admin.e2e-spec.ts create mode 100644 backoffice/test/plans.e2e-spec.ts diff --git a/backoffice/test/admin.e2e-spec.ts b/backoffice/test/admin.e2e-spec.ts new file mode 100644 index 0000000..9fef7f6 --- /dev/null +++ b/backoffice/test/admin.e2e-spec.ts @@ -0,0 +1,53 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { INestApplication } from '@nestjs/common'; +import request from 'supertest'; +import { AppModule } from './../src/app.module'; + +describe('AdminController (e2e)', () => { + let app: INestApplication; + + beforeEach(async () => { + const moduleFixture: TestingModule = await Test.createTestingModule({ + imports: [AppModule], + }).compile(); + + app = moduleFixture.createNestApplication(); + await app.init(); + }); + + afterEach(async () => { + await app.close(); + }); + + it('/admin/stats (GET)', () => { + return request(app.getHttpServer()) + .get('/admin/stats') + .expect(200) + .expect(res => { + expect(res.body).toHaveProperty('totalCompanies'); + expect(res.body).toHaveProperty('monthlyRevenue'); + }); + }); + + it('/admin/revenue (GET)', () => { + return request(app.getHttpServer()) + .get('/admin/revenue') + .expect(200) + .expect(res => { + expect(Array.isArray(res.body)).toBe(true); + expect(res.body[0]).toHaveProperty('month'); + expect(res.body[0]).toHaveProperty('revenue'); + }); + }); + + it('/admin/subscriptions-by-plan (GET)', () => { + return request(app.getHttpServer()) + .get('/admin/subscriptions-by-plan') + .expect(200) + .expect(res => { + expect(Array.isArray(res.body)).toBe(true); + expect(res.body[0]).toHaveProperty('plan'); + expect(res.body[0]).toHaveProperty('count'); + }); + }); +}); diff --git a/backoffice/test/plans.e2e-spec.ts b/backoffice/test/plans.e2e-spec.ts new file mode 100644 index 0000000..57f0bf0 --- /dev/null +++ b/backoffice/test/plans.e2e-spec.ts @@ -0,0 +1,44 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { INestApplication } from '@nestjs/common'; +import request from 'supertest'; +import { AppModule } from './../src/app.module'; + +describe('PlansController (e2e)', () => { + let app: INestApplication; + + beforeEach(async () => { + const moduleFixture: TestingModule = await Test.createTestingModule({ + imports: [AppModule], + }).compile(); + + app = moduleFixture.createNestApplication(); + await app.init(); + }); + + afterEach(async () => { + await app.close(); + }); + + it('/plans (GET)', () => { + return request(app.getHttpServer()) + .get('/plans') + .expect(200) + .expect(res => { + expect(Array.isArray(res.body)).toBe(true); + expect(res.body.length).toBeGreaterThan(0); + expect(res.body[0]).toHaveProperty('id'); + expect(res.body[0]).toHaveProperty('name'); + expect(res.body[0]).toHaveProperty('monthlyPrice'); + }); + }); + + it('/plans/:id (GET)', () => { + return request(app.getHttpServer()) + .get('/plans/starter') + .expect(200) + .expect(res => { + expect(res.body.id).toBe('starter'); + expect(res.body.name).toBe('Starter'); + }); + }); +}); diff --git a/seeder-api/.env.example b/seeder-api/.env.example index b3e815e..c4727b7 100644 --- a/seeder-api/.env.example +++ b/seeder-api/.env.example @@ -20,3 +20,4 @@ BACKEND_API_URL=http://localhost:8521/api/v1 # MUST match backend PASSWORD_PEPPER for login to work PASSWORD_PEPPER=some-random-string-for-password-hashing +PASSWORD_PEPPER=some-random-string-for-password-hashing