mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
refactor(nestjs): organization module e2e
This commit is contained in:
@@ -23,7 +23,6 @@ export class AuthenticationApplication {
|
||||
|
||||
/**
|
||||
* Signin and generates JWT token.
|
||||
* @throws {ServiceError}
|
||||
* @param {string} email - Email address.
|
||||
* @param {string} password - Password.
|
||||
*/
|
||||
|
||||
@@ -80,6 +80,7 @@ export class AuthSignupService {
|
||||
return {
|
||||
userId: user.id,
|
||||
tenantId: user.tenantId,
|
||||
organizationId: tenant.organizationId,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ export class OrganizationController {
|
||||
});
|
||||
}
|
||||
|
||||
@Get()
|
||||
@Get('current')
|
||||
@ApiOperation({ summary: 'Get current organization' })
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
|
||||
@@ -25,7 +25,7 @@ export class OrganizationBuildProcessor extends WorkerHost {
|
||||
@Process(OrganizationBuildQueueJob)
|
||||
@UseCls()
|
||||
async process(job: Job<OrganizationBuildQueueJobPayload>) {
|
||||
console.log('Processing organization build job:', job.data);
|
||||
console.log('Processing organization build job:', job.id);
|
||||
|
||||
this.clsService.set('organizationId', job.data.organizationId);
|
||||
this.clsService.set('userId', job.data.userId);
|
||||
|
||||
@@ -126,7 +126,6 @@ class GetInvoiceMailTemplateItemAttrsTransformer extends Transformer {
|
||||
}
|
||||
|
||||
public label(entry): string {
|
||||
console.log(entry);
|
||||
return entry?.item?.name;
|
||||
}
|
||||
|
||||
|
||||
74
packages/server-nest/test/organization.e2e-spec.ts
Normal file
74
packages/server-nest/test/organization.e2e-spec.ts
Normal file
@@ -0,0 +1,74 @@
|
||||
import * as request from 'supertest';
|
||||
import { faker } from '@faker-js/faker';
|
||||
import { app } from './init-app-test';
|
||||
|
||||
let signinResponse = null;
|
||||
let signupResponse = null;
|
||||
|
||||
describe('Organization (e2e)', () => {
|
||||
beforeAll(async () => {
|
||||
const signupBody = {
|
||||
firstName: faker.person.firstName(),
|
||||
lastName: faker.person.lastName(),
|
||||
email: faker.internet.email(),
|
||||
password: '123123123',
|
||||
};
|
||||
signupResponse = await request(app.getHttpServer())
|
||||
.post('/auth/signup')
|
||||
.send(signupBody);
|
||||
|
||||
signinResponse = await request(app.getHttpServer())
|
||||
.post('/auth/signin')
|
||||
.send({
|
||||
email: signupBody.email,
|
||||
password: signupBody.password,
|
||||
});
|
||||
});
|
||||
|
||||
it('/organization (POST)', async () => {
|
||||
return request(app.getHttpServer())
|
||||
.post('/organization/build')
|
||||
.set('Accept', 'application/json')
|
||||
.set('Content-Type', 'application/json')
|
||||
.set('Authorization', `Bearer ${signinResponse.body.access_token}`)
|
||||
.set('organization-id', signupResponse.body.organization_id)
|
||||
.send({
|
||||
name: 'BIGCAPITAL, INC',
|
||||
baseCurrency: 'USD',
|
||||
location: 'US',
|
||||
language: 'en',
|
||||
fiscalYear: 'march',
|
||||
timezone: 'US/Central',
|
||||
})
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/organization (GET)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.get('/organization/current')
|
||||
.set('Accept', 'application/json')
|
||||
.set('Content-Type', 'application/json')
|
||||
.set('Authorization', `Bearer ${signinResponse.body.access_token}`)
|
||||
.set('organization-id', signupResponse.body.organization_id)
|
||||
.send()
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/organization (PUT)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.put('/organization')
|
||||
.set('Accept', 'application/json')
|
||||
.set('Content-Type', 'application/json')
|
||||
.set('Authorization', `Bearer ${signinResponse.body.access_token}`)
|
||||
.set('organization-id', signupResponse.body.organization_id)
|
||||
.send({
|
||||
name: 'BIGCAPITAL, INC',
|
||||
baseCurrency: 'USD',
|
||||
location: 'US',
|
||||
language: 'en',
|
||||
fiscalYear: 'march',
|
||||
timezone: 'US/Central',
|
||||
})
|
||||
.expect(200);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user