mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 23:00:34 +00:00
refactor: e2e
This commit is contained in:
@@ -16,10 +16,7 @@ const makeExpenseRequest = () => ({
|
||||
description: faker.lorem.sentence(),
|
||||
},
|
||||
],
|
||||
// currencyCode: faker.finance.currencyCode(),
|
||||
// userId: faker.number.int({ min: 1, max: 100 }),
|
||||
// payeeId: faker.number.int({ min: 1, max: 100 }),
|
||||
// branchId: faker.number.int({ min: 1, max: 100 }),
|
||||
branchId: 1,
|
||||
});
|
||||
|
||||
describe('Expenses (e2e)', () => {
|
||||
@@ -31,6 +28,21 @@ describe('Expenses (e2e)', () => {
|
||||
.expect(201);
|
||||
});
|
||||
|
||||
it('/expenses/:id (PUT)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/expenses')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.send(makeExpenseRequest());
|
||||
|
||||
const expenseId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.put(`/expenses/${expenseId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.send(makeExpenseRequest())
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/expenses/:id (GET)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/expenses')
|
||||
|
||||
@@ -23,7 +23,7 @@ const makeManualJournalRequest = () => ({
|
||||
],
|
||||
});
|
||||
|
||||
describe('Manual Journals (e2e)', () => {
|
||||
describe.only('Manual Journals (e2e)', () => {
|
||||
it('/manual-journals (POST)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.post('/manual-journals')
|
||||
@@ -78,7 +78,7 @@ describe('Manual Journals (e2e)', () => {
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/manual-journals/:id/publish (POST)', async () => {
|
||||
it('/manual-journals/:id/publish (PUT)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/manual-journals')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
@@ -87,7 +87,7 @@ describe('Manual Journals (e2e)', () => {
|
||||
const journalId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.post(`/manual-journals/${journalId}/publish`)
|
||||
.put(`/manual-journals/${journalId}/publish`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.send()
|
||||
.expect(200);
|
||||
|
||||
@@ -2,59 +2,93 @@ import * as request from 'supertest';
|
||||
import { faker } from '@faker-js/faker';
|
||||
import { app } from './init-app-test';
|
||||
|
||||
const makeEstimateRequest = () => ({
|
||||
customerId: 2,
|
||||
estimateDate: '2022-02-02',
|
||||
expirationDate: '2020-03-02',
|
||||
delivered: false,
|
||||
estimateNumber: faker.string.uuid(),
|
||||
discount: 100,
|
||||
discountType: 'amount',
|
||||
entries: [
|
||||
{
|
||||
index: 1,
|
||||
itemId: 1001,
|
||||
quantity: 3,
|
||||
rate: 1000,
|
||||
description: "It's description here.",
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
describe('Sale Estimates (e2e)', () => {
|
||||
it('/sales/estimates (POST)', async () => {
|
||||
it('/sale-estimates (POST)', async () => {
|
||||
return request(app.getHttpServer())
|
||||
.post('/sales/estimates')
|
||||
.post('/sale-estimates')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.send({
|
||||
customerId: 2,
|
||||
estimateDate: '2022-02-02',
|
||||
expirationDate: '2020-03-02',
|
||||
delivered: false,
|
||||
estimateNumber: faker.string.uuid(),
|
||||
discount: 100,
|
||||
discountType: 'amount',
|
||||
entries: [
|
||||
{
|
||||
index: 1,
|
||||
itemId: 1001,
|
||||
quantity: 3,
|
||||
rate: 1000,
|
||||
description: "It's description here.",
|
||||
},
|
||||
],
|
||||
})
|
||||
.send(makeEstimateRequest())
|
||||
.expect(201);
|
||||
});
|
||||
|
||||
it('/sales/estimates (DELETE)', async () => {
|
||||
it('/sale-estimates (DELETE)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/sales/estimates')
|
||||
.post('/sale-estimates')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.send({
|
||||
customerId: 2,
|
||||
estimateDate: '2022-02-02',
|
||||
expirationDate: '2020-03-02',
|
||||
delivered: false,
|
||||
estimateNumber: faker.string.uuid(),
|
||||
discount: 100,
|
||||
discountType: 'amount',
|
||||
entries: [
|
||||
{
|
||||
index: 1,
|
||||
itemId: 1001,
|
||||
quantity: 3,
|
||||
rate: 1000,
|
||||
description: "It's description here.",
|
||||
},
|
||||
],
|
||||
});
|
||||
.send(makeEstimateRequest());
|
||||
|
||||
const estimateId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.delete(`/sales/estimates/${estimateId}`)
|
||||
.delete(`/sale-estimates/${estimateId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/sale-estimates/state (GET)', async () => {
|
||||
return request(app.getHttpServer())
|
||||
.get('/sale-estimates/state')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/sale-estimates/:id (GET)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/sale-estimates')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.send(makeEstimateRequest());
|
||||
|
||||
const estimateId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.get(`/sale-estimates/${estimateId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/sale-estimates/:id/approve (PUT)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/sale-estimates')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.send({ ...makeEstimateRequest(), delivered: true });
|
||||
|
||||
const estimateId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.put(`/sale-estimates/${estimateId}/approve`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/sale-estimates/:id/reject (PUT)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/sale-estimates')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.send({ ...makeEstimateRequest(), delivered: true });
|
||||
|
||||
const estimateId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.put(`/sale-estimates/${estimateId}/reject`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user