mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 14:50:32 +00:00
fix: e2e test cases
This commit is contained in:
@@ -1,15 +1,19 @@
|
||||
import * as request from 'supertest';
|
||||
import { app } from './init-app-test';
|
||||
import { app, orgainzationId } from './init-app-test';
|
||||
import { faker } from '@faker-js/faker';
|
||||
|
||||
let customerId;
|
||||
let itemId;
|
||||
|
||||
const requestCreditNote = () => ({
|
||||
customerId: 2,
|
||||
customerId: customerId,
|
||||
creditNoteDate: '2020-02-02',
|
||||
branchId: 1,
|
||||
warehouseId: 1,
|
||||
entries: [
|
||||
{
|
||||
index: 1,
|
||||
itemId: 1000,
|
||||
itemId: itemId,
|
||||
quantity: 1,
|
||||
rate: 1000,
|
||||
description: "It's description here.",
|
||||
@@ -20,10 +24,33 @@ const requestCreditNote = () => ({
|
||||
});
|
||||
|
||||
describe('Credit Notes (e2e)', () => {
|
||||
beforeAll(async () => {
|
||||
const customer = await request(app.getHttpServer())
|
||||
.post('/customers')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({ displayName: 'Test Customer' });
|
||||
|
||||
customerId = customer.body.id;
|
||||
|
||||
const item = await request(app.getHttpServer())
|
||||
.post('/items')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send({
|
||||
name: faker.commerce.productName(),
|
||||
sellable: true,
|
||||
purchasable: true,
|
||||
sellAccountId: 1026,
|
||||
costAccountId: 1019,
|
||||
costPrice: 100,
|
||||
sellPrice: 100,
|
||||
});
|
||||
itemId = parseInt(item.text, 10);
|
||||
});
|
||||
|
||||
it('/credit-notes (POST)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.post('/credit-notes')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(requestCreditNote())
|
||||
.expect(201);
|
||||
});
|
||||
@@ -31,13 +58,13 @@ describe('Credit Notes (e2e)', () => {
|
||||
it('/credit-notes/:id (DELETE)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/credit-notes')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(requestCreditNote());
|
||||
const creditNoteId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.delete(`/credit-notes/${creditNoteId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
@@ -45,13 +72,13 @@ describe('Credit Notes (e2e)', () => {
|
||||
const creditNote = requestCreditNote();
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/credit-notes')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(creditNote);
|
||||
const creditNoteId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.put(`/credit-notes/${creditNoteId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(creditNote)
|
||||
.expect(200);
|
||||
});
|
||||
@@ -59,13 +86,13 @@ describe('Credit Notes (e2e)', () => {
|
||||
it('/credit-notes/:id/open (POST)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/credit-notes')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.send(requestCreditNote());
|
||||
const creditNoteId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.put(`/credit-notes/${creditNoteId}/open`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.set('organization-id', orgainzationId)
|
||||
.expect(200);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user