fix(auth): correct seeder pepper and add backoffice e2e tests
This commit is contained in:
parent
1d79276e13
commit
c8a281ef06
3 changed files with 98 additions and 0 deletions
53
backoffice/test/admin.e2e-spec.ts
Normal file
53
backoffice/test/admin.e2e-spec.ts
Normal file
|
|
@ -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');
|
||||
});
|
||||
});
|
||||
});
|
||||
44
backoffice/test/plans.e2e-spec.ts
Normal file
44
backoffice/test/plans.e2e-spec.ts
Normal file
|
|
@ -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');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue