mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
feat(nestjs): migrate to NestJS
This commit is contained in:
148
packages/server/test/items.e2e-spec.ts
Normal file
148
packages/server/test/items.e2e-spec.ts
Normal file
@@ -0,0 +1,148 @@
|
||||
import * as request from 'supertest';
|
||||
import { faker } from '@faker-js/faker';
|
||||
import {
|
||||
app,
|
||||
authenticationToken,
|
||||
AuthorizationHeader,
|
||||
orgainzationId,
|
||||
} from './init-app-test';
|
||||
|
||||
const makeItemRequest = () => ({
|
||||
name: faker.commerce.productName(),
|
||||
type: 'service',
|
||||
});
|
||||
|
||||
describe('Items (e2e)', () => {
|
||||
it('/items (POST)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.post('/items')
|
||||
.set('organization-id', orgainzationId)
|
||||
.set('Authorization', `Bearer ${authenticationToken}`)
|
||||
.send(makeItemRequest())
|
||||
.expect(201);
|
||||
});
|
||||
|
||||
it('/items/:id (PUT)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/items')
|
||||
.set('organization-id', orgainzationId)
|
||||
.set('Authorization', AuthorizationHeader)
|
||||
.send(makeItemRequest());
|
||||
const itemId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.put(`/items/${itemId}`)
|
||||
.set('organization-id', orgainzationId)
|
||||
.set('Authorization', AuthorizationHeader)
|
||||
.send(makeItemRequest());
|
||||
});
|
||||
|
||||
it('/items/:id/inactivate (PATCH)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/items')
|
||||
.set('organization-id', orgainzationId)
|
||||
.set('Authorization', AuthorizationHeader)
|
||||
.send(makeItemRequest());
|
||||
const itemId = response.text;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.patch(`/items/${itemId}/inactivate`)
|
||||
.set('organization-id', orgainzationId)
|
||||
.set('Authorization', AuthorizationHeader)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/items/:id/activate (PATCH)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/items')
|
||||
.set('organization-id', orgainzationId)
|
||||
.set('Authorization', AuthorizationHeader)
|
||||
.send(makeItemRequest());
|
||||
const itemId = response.text;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.patch(`/items/${itemId}/activate`)
|
||||
.set('organization-id', orgainzationId)
|
||||
.set('Authorization', AuthorizationHeader)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/items/:id (DELETE)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/items')
|
||||
.set('organization-id', orgainzationId)
|
||||
.set('Authorization', AuthorizationHeader)
|
||||
.send(makeItemRequest());
|
||||
const itemId = response.text;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.delete(`/items/${itemId}`)
|
||||
.set('organization-id', orgainzationId)
|
||||
.set('Authorization', AuthorizationHeader)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/items/:id/invoices (GET)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/items')
|
||||
.set('organization-id', orgainzationId)
|
||||
.set('Authorization', AuthorizationHeader)
|
||||
.send(makeItemRequest());
|
||||
|
||||
const itemId = response.text;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.get(`/items/${itemId}/invoices`)
|
||||
.set('organization-id', orgainzationId)
|
||||
.set('Authorization', AuthorizationHeader)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/items/:id/bills (GET)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/items')
|
||||
.set('organization-id', orgainzationId)
|
||||
.set('Authorization', AuthorizationHeader)
|
||||
.send(makeItemRequest());
|
||||
|
||||
const itemId = response.text;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.get(`/items/${itemId}/bills`)
|
||||
.set('organization-id', orgainzationId)
|
||||
.set('Authorization', AuthorizationHeader)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/items/:id/estimates (GET)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/items')
|
||||
.set('organization-id', orgainzationId)
|
||||
.set('Authorization', AuthorizationHeader)
|
||||
.send(makeItemRequest());
|
||||
|
||||
const itemId = response.text;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.get(`/items/${itemId}/estimates`)
|
||||
.set('organization-id', orgainzationId)
|
||||
.set('Authorization', AuthorizationHeader)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/items/:id/receipts (GET)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/items')
|
||||
.set('organization-id', orgainzationId)
|
||||
.set('Authorization', AuthorizationHeader)
|
||||
.send(makeItemRequest());
|
||||
|
||||
const itemId = response.text;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.get(`/items/${itemId}/receipts`)
|
||||
.set('organization-id', orgainzationId)
|
||||
.set('Authorization', AuthorizationHeader)
|
||||
.expect(200);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user