mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 15:20:34 +00:00
fix: e2e test cases
This commit is contained in:
@@ -4,8 +4,6 @@ import { Request, Response, NextFunction } from 'express';
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
export class LoggerMiddleware implements NestMiddleware {
|
export class LoggerMiddleware implements NestMiddleware {
|
||||||
use(req: Request, res: Response, next: NextFunction) {
|
use(req: Request, res: Response, next: NextFunction) {
|
||||||
console.log(`Request...`);
|
|
||||||
|
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
req.test = 'test';
|
req.test = 'test';
|
||||||
next();
|
next();
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Module } from '@nestjs/common';
|
import { forwardRef, Module } from '@nestjs/common';
|
||||||
import { CreateBankRuleService } from './commands/CreateBankRule.service';
|
import { CreateBankRuleService } from './commands/CreateBankRule.service';
|
||||||
import { EditBankRuleService } from './commands/EditBankRule.service';
|
import { EditBankRuleService } from './commands/EditBankRule.service';
|
||||||
import { DeleteBankRuleService } from './commands/DeleteBankRule.service';
|
import { DeleteBankRuleService } from './commands/DeleteBankRule.service';
|
||||||
@@ -11,6 +11,7 @@ import { BankRule } from './models/BankRule';
|
|||||||
import { BankRulesController } from './BankRules.controller';
|
import { BankRulesController } from './BankRules.controller';
|
||||||
import { UnlinkBankRuleOnDeleteBankRuleSubscriber } from './events/UnlinkBankRuleOnDeleteBankRule';
|
import { UnlinkBankRuleOnDeleteBankRuleSubscriber } from './events/UnlinkBankRuleOnDeleteBankRule';
|
||||||
import { DeleteBankRulesService } from './commands/DeleteBankRules.service';
|
import { DeleteBankRulesService } from './commands/DeleteBankRules.service';
|
||||||
|
import { BankingTransactionsRegonizeModule } from '../BankingTranasctionsRegonize/BankingTransactionsRegonize.module';
|
||||||
|
|
||||||
const models = [
|
const models = [
|
||||||
RegisterTenancyModel(BankRule),
|
RegisterTenancyModel(BankRule),
|
||||||
@@ -19,7 +20,7 @@ const models = [
|
|||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
controllers: [BankRulesController],
|
controllers: [BankRulesController],
|
||||||
imports: [],
|
imports: [forwardRef(() => BankingTransactionsRegonizeModule)],
|
||||||
providers: [
|
providers: [
|
||||||
...models,
|
...models,
|
||||||
CreateBankRuleService,
|
CreateBankRuleService,
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ import { OnEvent } from '@nestjs/event-emitter';
|
|||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class UnlinkBankRuleOnDeleteBankRuleSubscriber {
|
export class UnlinkBankRuleOnDeleteBankRuleSubscriber {
|
||||||
private revertRecognizedTransactionsService: RevertRecognizedTransactionsService;
|
constructor(
|
||||||
|
private readonly revertRecognizedTransactionsService: RevertRecognizedTransactionsService,
|
||||||
|
) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unlinks the bank rule out of recognized transactions.
|
* Unlinks the bank rule out of recognized transactions.
|
||||||
@@ -17,7 +19,7 @@ export class UnlinkBankRuleOnDeleteBankRuleSubscriber {
|
|||||||
oldBankRule,
|
oldBankRule,
|
||||||
}: IBankRuleEventDeletingPayload) {
|
}: IBankRuleEventDeletingPayload) {
|
||||||
await this.revertRecognizedTransactionsService.revertRecognizedTransactions(
|
await this.revertRecognizedTransactionsService.revertRecognizedTransactions(
|
||||||
oldBankRule.id
|
oldBankRule.id,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Module } from '@nestjs/common';
|
import { forwardRef, Module } from '@nestjs/common';
|
||||||
import { RegisterTenancyModel } from '../Tenancy/TenancyModels/Tenancy.module';
|
import { RegisterTenancyModel } from '../Tenancy/TenancyModels/Tenancy.module';
|
||||||
import { RecognizedBankTransaction } from './models/RecognizedBankTransaction';
|
import { RecognizedBankTransaction } from './models/RecognizedBankTransaction';
|
||||||
import { GetAutofillCategorizeTransactionService } from './queries/GetAutofillCategorizeTransaction.service';
|
import { GetAutofillCategorizeTransactionService } from './queries/GetAutofillCategorizeTransaction.service';
|
||||||
@@ -11,7 +11,7 @@ import { BankRulesModule } from '../BankRules/BankRules.module';
|
|||||||
const models = [RegisterTenancyModel(RecognizedBankTransaction)];
|
const models = [RegisterTenancyModel(RecognizedBankTransaction)];
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [BankingTransactionsModule, BankRulesModule],
|
imports: [BankingTransactionsModule, forwardRef(() => BankRulesModule)],
|
||||||
providers: [
|
providers: [
|
||||||
...models,
|
...models,
|
||||||
GetAutofillCategorizeTransactionService,
|
GetAutofillCategorizeTransactionService,
|
||||||
|
|||||||
@@ -162,9 +162,9 @@ export class CreditNoteGL {
|
|||||||
public getCreditNoteGLEntries(): ILedgerEntry[] {
|
public getCreditNoteGLEntries(): ILedgerEntry[] {
|
||||||
const AREntry = this.creditNoteAREntry;
|
const AREntry = this.creditNoteAREntry;
|
||||||
|
|
||||||
const getItemEntry = this.getCreditNoteItemEntry;
|
const itemsEntries = this.creditNoteModel.entries.map((entry, index) =>
|
||||||
const itemsEntries = this.creditNoteModel.entries.map(getItemEntry);
|
this.getCreditNoteItemEntry(entry, index),
|
||||||
|
);
|
||||||
const discountEntry = this.discountEntry;
|
const discountEntry = this.discountEntry;
|
||||||
const adjustmentEntry = this.adjustmentEntry;
|
const adjustmentEntry = this.adjustmentEntry;
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,10 @@ import { ITransactionsLockingAllDTO } from './types/TransactionsLocking.types';
|
|||||||
import { ICancelTransactionsLockingDTO } from './types/TransactionsLocking.types';
|
import { ICancelTransactionsLockingDTO } from './types/TransactionsLocking.types';
|
||||||
import { ITransactionLockingPartiallyDTO } from './types/TransactionsLocking.types';
|
import { ITransactionLockingPartiallyDTO } from './types/TransactionsLocking.types';
|
||||||
import { QueryTransactionsLocking } from './queries/QueryTransactionsLocking';
|
import { QueryTransactionsLocking } from './queries/QueryTransactionsLocking';
|
||||||
|
import { PublicRoute } from '../Auth/Jwt.guard';
|
||||||
|
|
||||||
@Controller('transactions-locking')
|
@Controller('transactions-locking')
|
||||||
|
@PublicRoute()
|
||||||
export class TransactionsLockingController {
|
export class TransactionsLockingController {
|
||||||
constructor(
|
constructor(
|
||||||
private readonly transactionsLockingService: TransactionsLockingService,
|
private readonly transactionsLockingService: TransactionsLockingService,
|
||||||
@@ -74,13 +76,15 @@ export class TransactionsLockingController {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Get(':module')
|
@Get('/')
|
||||||
// async getTransactionLockingMeta(@Param('module') module: string) {
|
|
||||||
// return await this.queryTransactionsLocking.getTransactionsLocking(module);
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Get()
|
|
||||||
async getTransactionLockingMetaList() {
|
async getTransactionLockingMetaList() {
|
||||||
return await this.queryTransactionsLocking.getTransactionsLockingAll();
|
return await this.queryTransactionsLocking.getTransactionsLockingAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Get(':module')
|
||||||
|
async getTransactionLockingMeta(@Param('module') module: string) {
|
||||||
|
return await this.queryTransactionsLocking.getTransactionsLockingModuleMeta(
|
||||||
|
module as TransactionsLockingGroup,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import * as moment from 'moment';
|
||||||
import { isUndefined } from 'lodash';
|
import { isUndefined } from 'lodash';
|
||||||
import {
|
import {
|
||||||
ITransactionMeta,
|
ITransactionMeta,
|
||||||
|
|||||||
@@ -147,9 +147,9 @@ export class VendorCreditGL {
|
|||||||
*/
|
*/
|
||||||
public getVendorCreditGLEntries(): ILedgerEntry[] {
|
public getVendorCreditGLEntries(): ILedgerEntry[] {
|
||||||
const payableEntry = this.vendorCreditPayableGLEntry;
|
const payableEntry = this.vendorCreditPayableGLEntry;
|
||||||
const getItemEntry = this.getVendorCreditGLItemEntry;
|
const itemsEntries = this.vendorCredit.entries.map((entry, index) =>
|
||||||
const itemsEntries = this.vendorCredit.entries.map(getItemEntry);
|
this.getVendorCreditGLItemEntry(entry, index),
|
||||||
|
);
|
||||||
const discountEntry = this.discountEntry;
|
const discountEntry = this.discountEntry;
|
||||||
const adjustmentEntry = this.adjustmentEntry;
|
const adjustmentEntry = this.adjustmentEntry;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
export const entriesAmountDiff = (
|
export const entriesAmountDiff = (
|
||||||
newEntries,
|
newEntries,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import * as request from 'supertest';
|
import * as request from 'supertest';
|
||||||
import { faker } from '@faker-js/faker';
|
import { faker } from '@faker-js/faker';
|
||||||
import { app } from './init-app-test';
|
import { app, orgainzationId } from './init-app-test';
|
||||||
|
|
||||||
const requestBankRule = () => ({
|
const requestBankRule = () => ({
|
||||||
name: faker.company.name(),
|
name: faker.company.name(),
|
||||||
@@ -24,7 +24,7 @@ describe('Bank Rules (e2e)', () => {
|
|||||||
it('/banking/rules (POST)', () => {
|
it('/banking/rules (POST)', () => {
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.post('/banking/rules')
|
.post('/banking/rules')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(requestBankRule())
|
.send(requestBankRule())
|
||||||
.expect(201);
|
.expect(201);
|
||||||
});
|
});
|
||||||
@@ -32,14 +32,14 @@ describe('Bank Rules (e2e)', () => {
|
|||||||
it('/banking/rules/:id (PUT)', async () => {
|
it('/banking/rules/:id (PUT)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/banking/rules')
|
.post('/banking/rules')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(requestBankRule());
|
.send(requestBankRule());
|
||||||
|
|
||||||
const ruleId = response.body.id;
|
const ruleId = response.body.id;
|
||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.put(`/banking/rules/${ruleId}`)
|
.put(`/banking/rules/${ruleId}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(requestBankRule())
|
.send(requestBankRule())
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
@@ -47,42 +47,42 @@ describe('Bank Rules (e2e)', () => {
|
|||||||
it('/banking/rules/:id (DELETE)', async () => {
|
it('/banking/rules/:id (DELETE)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/banking/rules')
|
.post('/banking/rules')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(requestBankRule());
|
.send(requestBankRule());
|
||||||
|
|
||||||
const ruleId = response.body.id;
|
const ruleId = response.body.id;
|
||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.delete(`/banking/rules/${ruleId}`)
|
.delete(`/banking/rules/${ruleId}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('/banking/rules/:id (GET)', async () => {
|
it('/banking/rules/:id (GET)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/banking/rules')
|
.post('/banking/rules')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(requestBankRule());
|
.send(requestBankRule());
|
||||||
|
|
||||||
const ruleId = response.body.id;
|
const ruleId = response.body.id;
|
||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.get(`/banking/rules/${ruleId}`)
|
.get(`/banking/rules/${ruleId}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('/banking/rules (GET)', async () => {
|
it('/banking/rules (GET)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/banking/rules')
|
.post('/banking/rules')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(requestBankRule());
|
.send(requestBankRule());
|
||||||
|
|
||||||
const ruleId = response.body.id;
|
const ruleId = response.body.id;
|
||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.get(`/banking/rules/${ruleId}`)
|
.get(`/banking/rules/${ruleId}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import * as request from 'supertest';
|
import * as request from 'supertest';
|
||||||
import { faker } from '@faker-js/faker';
|
import { faker } from '@faker-js/faker';
|
||||||
import { app } from './init-app-test';
|
import { app, orgainzationId } from './init-app-test';
|
||||||
|
|
||||||
const createOwnerContributionTransaction = () => ({
|
const createOwnerContributionTransaction = () => ({
|
||||||
date: '2024-01-01',
|
date: '2024-01-01',
|
||||||
@@ -22,7 +22,7 @@ describe('Banking Transactions (e2e)', () => {
|
|||||||
it('/banking/transactions (POST)', () => {
|
it('/banking/transactions (POST)', () => {
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.post('/banking/transactions')
|
.post('/banking/transactions')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(createOwnerContributionTransaction())
|
.send(createOwnerContributionTransaction())
|
||||||
.expect(201);
|
.expect(201);
|
||||||
});
|
});
|
||||||
@@ -31,7 +31,7 @@ describe('Banking Transactions (e2e)', () => {
|
|||||||
const transaction = createOwnerContributionTransaction();
|
const transaction = createOwnerContributionTransaction();
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/banking/transactions')
|
.post('/banking/transactions')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(transaction)
|
.send(transaction)
|
||||||
.expect(201);
|
.expect(201);
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ describe('Banking Transactions (e2e)', () => {
|
|||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.get(`/banking/transactions/${transactionId}`)
|
.get(`/banking/transactions/${transactionId}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ describe('Banking Transactions (e2e)', () => {
|
|||||||
const transaction = createOwnerContributionTransaction();
|
const transaction = createOwnerContributionTransaction();
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/banking/transactions')
|
.post('/banking/transactions')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(transaction)
|
.send(transaction)
|
||||||
.expect(201);
|
.expect(201);
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ describe('Banking Transactions (e2e)', () => {
|
|||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.delete(`/banking/transactions/${transactionId}`)
|
.delete(`/banking/transactions/${transactionId}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import * as request from 'supertest';
|
import * as request from 'supertest';
|
||||||
import { faker } from '@faker-js/faker';
|
import { faker } from '@faker-js/faker';
|
||||||
import { app } from './init-app-test';
|
import { app, orgainzationId } from './init-app-test';
|
||||||
|
|
||||||
describe('Branches (e2e)', () => {
|
describe('Branches (e2e)', () => {
|
||||||
it('/branches (POST)', () => {
|
it('/branches (POST)', () => {
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.post('/branches')
|
.post('/branches')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send({
|
.send({
|
||||||
name: faker.commerce.productName(),
|
name: faker.commerce.productName(),
|
||||||
code: faker.string.alpha(4),
|
code: faker.string.alpha(4),
|
||||||
@@ -17,7 +17,7 @@ describe('Branches (e2e)', () => {
|
|||||||
it('/branches/:id (DELETE)', async () => {
|
it('/branches/:id (DELETE)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/branches')
|
.post('/branches')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send({
|
.send({
|
||||||
name: faker.commerce.productName(),
|
name: faker.commerce.productName(),
|
||||||
code: faker.string.alpha(4),
|
code: faker.string.alpha(4),
|
||||||
@@ -26,14 +26,14 @@ describe('Branches (e2e)', () => {
|
|||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.delete(`/branches/${branchId}`)
|
.delete(`/branches/${branchId}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('/branches/:id (PUT)', async () => {
|
it('/branches/:id (PUT)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/branches')
|
.post('/branches')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send({
|
.send({
|
||||||
name: faker.commerce.productName(),
|
name: faker.commerce.productName(),
|
||||||
code: faker.string.alpha(4),
|
code: faker.string.alpha(4),
|
||||||
@@ -42,14 +42,14 @@ describe('Branches (e2e)', () => {
|
|||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.put(`/branches/${branchId}`)
|
.put(`/branches/${branchId}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('/branches/:id (GET)', async () => {
|
it('/branches/:id (GET)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/branches')
|
.post('/branches')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send({
|
.send({
|
||||||
name: faker.commerce.productName(),
|
name: faker.commerce.productName(),
|
||||||
code: faker.string.alpha(4),
|
code: faker.string.alpha(4),
|
||||||
@@ -58,14 +58,14 @@ describe('Branches (e2e)', () => {
|
|||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.get(`/branches/${branchId}`)
|
.get(`/branches/${branchId}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('/branches (GET)', async () => {
|
it('/branches (GET)', async () => {
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.get('/branches')
|
.get('/branches')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,15 +1,19 @@
|
|||||||
import * as request from 'supertest';
|
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 = () => ({
|
const requestCreditNote = () => ({
|
||||||
customerId: 2,
|
customerId: customerId,
|
||||||
creditNoteDate: '2020-02-02',
|
creditNoteDate: '2020-02-02',
|
||||||
branchId: 1,
|
branchId: 1,
|
||||||
warehouseId: 1,
|
warehouseId: 1,
|
||||||
entries: [
|
entries: [
|
||||||
{
|
{
|
||||||
index: 1,
|
index: 1,
|
||||||
itemId: 1000,
|
itemId: itemId,
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
rate: 1000,
|
rate: 1000,
|
||||||
description: "It's description here.",
|
description: "It's description here.",
|
||||||
@@ -20,10 +24,33 @@ const requestCreditNote = () => ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('Credit Notes (e2e)', () => {
|
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)', () => {
|
it('/credit-notes (POST)', () => {
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.post('/credit-notes')
|
.post('/credit-notes')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(requestCreditNote())
|
.send(requestCreditNote())
|
||||||
.expect(201);
|
.expect(201);
|
||||||
});
|
});
|
||||||
@@ -31,13 +58,13 @@ describe('Credit Notes (e2e)', () => {
|
|||||||
it('/credit-notes/:id (DELETE)', async () => {
|
it('/credit-notes/:id (DELETE)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/credit-notes')
|
.post('/credit-notes')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(requestCreditNote());
|
.send(requestCreditNote());
|
||||||
const creditNoteId = response.body.id;
|
const creditNoteId = response.body.id;
|
||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.delete(`/credit-notes/${creditNoteId}`)
|
.delete(`/credit-notes/${creditNoteId}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -45,13 +72,13 @@ describe('Credit Notes (e2e)', () => {
|
|||||||
const creditNote = requestCreditNote();
|
const creditNote = requestCreditNote();
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/credit-notes')
|
.post('/credit-notes')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(creditNote);
|
.send(creditNote);
|
||||||
const creditNoteId = response.body.id;
|
const creditNoteId = response.body.id;
|
||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.put(`/credit-notes/${creditNoteId}`)
|
.put(`/credit-notes/${creditNoteId}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(creditNote)
|
.send(creditNote)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
@@ -59,13 +86,13 @@ describe('Credit Notes (e2e)', () => {
|
|||||||
it('/credit-notes/:id/open (POST)', async () => {
|
it('/credit-notes/:id/open (POST)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/credit-notes')
|
.post('/credit-notes')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(requestCreditNote());
|
.send(requestCreditNote());
|
||||||
const creditNoteId = response.body.id;
|
const creditNoteId = response.body.id;
|
||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.put(`/credit-notes/${creditNoteId}/open`)
|
.put(`/credit-notes/${creditNoteId}/open`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import * as request from 'supertest';
|
import * as request from 'supertest';
|
||||||
import { faker } from '@faker-js/faker';
|
import { faker } from '@faker-js/faker';
|
||||||
import { app } from './init-app-test';
|
import { app, orgainzationId } from './init-app-test';
|
||||||
|
|
||||||
describe('Customers (e2e)', () => {
|
describe('Customers (e2e)', () => {
|
||||||
it('/customers (POST)', () => {
|
it('/customers (POST)', () => {
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.post('/customers')
|
.post('/customers')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send({
|
.send({
|
||||||
customerType: 'business',
|
customerType: 'business',
|
||||||
displayName: faker.commerce.productName(),
|
displayName: faker.commerce.productName(),
|
||||||
@@ -20,7 +20,7 @@ describe('Customers (e2e)', () => {
|
|||||||
it('/customers/:id (GET)', async () => {
|
it('/customers/:id (GET)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/customers')
|
.post('/customers')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send({
|
.send({
|
||||||
customerType: 'business',
|
customerType: 'business',
|
||||||
displayName: faker.commerce.productName(),
|
displayName: faker.commerce.productName(),
|
||||||
@@ -32,14 +32,14 @@ describe('Customers (e2e)', () => {
|
|||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.get(`/customers/${customerId}`)
|
.get(`/customers/${customerId}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('/customers/:id (DELETE)', async () => {
|
it('/customers/:id (DELETE)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/customers')
|
.post('/customers')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send({
|
.send({
|
||||||
customerType: 'business',
|
customerType: 'business',
|
||||||
displayName: faker.commerce.productName(),
|
displayName: faker.commerce.productName(),
|
||||||
@@ -51,14 +51,14 @@ describe('Customers (e2e)', () => {
|
|||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.delete(`/customers/${customerId}`)
|
.delete(`/customers/${customerId}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('/customers/:id (PUT)', async () => {
|
it('/customers/:id (PUT)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/customers')
|
.post('/customers')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send({
|
.send({
|
||||||
customerType: 'business',
|
customerType: 'business',
|
||||||
displayName: faker.commerce.productName(),
|
displayName: faker.commerce.productName(),
|
||||||
@@ -70,7 +70,7 @@ describe('Customers (e2e)', () => {
|
|||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.put(`/customers/${customerId}`)
|
.put(`/customers/${customerId}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send({
|
.send({
|
||||||
displayName: faker.commerce.productName(),
|
displayName: faker.commerce.productName(),
|
||||||
email: faker.internet.email(),
|
email: faker.internet.email(),
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import * as request from 'supertest';
|
import * as request from 'supertest';
|
||||||
import { faker } from '@faker-js/faker';
|
import { faker } from '@faker-js/faker';
|
||||||
import { app } from './init-app-test';
|
import { app, orgainzationId } from './init-app-test';
|
||||||
|
|
||||||
const makeExpenseRequest = () => ({
|
const makeExpenseRequest = () => ({
|
||||||
exchangeRate: 1,
|
exchangeRate: 1,
|
||||||
@@ -11,7 +11,7 @@ const makeExpenseRequest = () => ({
|
|||||||
paymentDate: faker.date.recent(),
|
paymentDate: faker.date.recent(),
|
||||||
categories: [
|
categories: [
|
||||||
{
|
{
|
||||||
expenseAccountId: 1045,
|
expenseAccountId: 1021,
|
||||||
amount: faker.number.float({ min: 10, max: 1000, precision: 0.01 }),
|
amount: faker.number.float({ min: 10, max: 1000, precision: 0.01 }),
|
||||||
description: faker.lorem.sentence(),
|
description: faker.lorem.sentence(),
|
||||||
},
|
},
|
||||||
@@ -23,7 +23,7 @@ describe('Expenses (e2e)', () => {
|
|||||||
it('/expenses (POST)', () => {
|
it('/expenses (POST)', () => {
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.post('/expenses')
|
.post('/expenses')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(makeExpenseRequest())
|
.send(makeExpenseRequest())
|
||||||
.expect(201);
|
.expect(201);
|
||||||
});
|
});
|
||||||
@@ -31,14 +31,14 @@ describe('Expenses (e2e)', () => {
|
|||||||
it('/expenses/:id (PUT)', async () => {
|
it('/expenses/:id (PUT)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/expenses')
|
.post('/expenses')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(makeExpenseRequest());
|
.send(makeExpenseRequest());
|
||||||
|
|
||||||
const expenseId = response.body.id;
|
const expenseId = response.body.id;
|
||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.put(`/expenses/${expenseId}`)
|
.put(`/expenses/${expenseId}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(makeExpenseRequest())
|
.send(makeExpenseRequest())
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
@@ -46,28 +46,28 @@ describe('Expenses (e2e)', () => {
|
|||||||
it('/expenses/:id (GET)', async () => {
|
it('/expenses/:id (GET)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/expenses')
|
.post('/expenses')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(makeExpenseRequest());
|
.send(makeExpenseRequest());
|
||||||
|
|
||||||
const expenseId = response.body.id;
|
const expenseId = response.body.id;
|
||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.get(`/expenses/${expenseId}`)
|
.get(`/expenses/${expenseId}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('/expenses/:id (DELETE)', async () => {
|
it('/expenses/:id (DELETE)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/expenses')
|
.post('/expenses')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(makeExpenseRequest());
|
.send(makeExpenseRequest());
|
||||||
|
|
||||||
const expenseId = response.body.id;
|
const expenseId = response.body.id;
|
||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.delete(`/expenses/${expenseId}`)
|
.delete(`/expenses/${expenseId}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,14 +4,15 @@ import { AppModule } from '../src/modules/App/App.module';
|
|||||||
|
|
||||||
let app: INestApplication;
|
let app: INestApplication;
|
||||||
|
|
||||||
|
let orgainzationId = 'fxdo7u419m5ryy4tb';
|
||||||
|
let authenticationToken = '';
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
const moduleFixture: TestingModule = await Test.createTestingModule({
|
const moduleFixture: TestingModule = await Test.createTestingModule({
|
||||||
imports: [AppModule],
|
imports: [AppModule],
|
||||||
}).compile();
|
}).compile();
|
||||||
|
|
||||||
app = moduleFixture.createNestApplication();
|
app = moduleFixture.createNestApplication();
|
||||||
app.useLogger(new Logger());
|
|
||||||
|
|
||||||
await app.init();
|
await app.init();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -19,4 +20,6 @@ afterAll(async () => {
|
|||||||
await app.close();
|
await app.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
export { app };
|
jest.retryTimes(3, { logErrorsBeforeRetry: true });
|
||||||
|
|
||||||
|
export { app, orgainzationId, authenticationToken };
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import * as request from 'supertest';
|
import * as request from 'supertest';
|
||||||
import { faker } from '@faker-js/faker';
|
import { faker } from '@faker-js/faker';
|
||||||
import { app } from './init-app-test';
|
import { app, orgainzationId } from './init-app-test';
|
||||||
|
|
||||||
export const createInventoryAdjustment = ({ itemId }) => ({
|
export const createInventoryAdjustment = ({ itemId }) => ({
|
||||||
date: '2020-01-01',
|
date: '2020-01-01',
|
||||||
@@ -28,7 +28,7 @@ describe('Inventory Adjustments (e2e)', () => {
|
|||||||
it('/inventory-adjustments/quick (POST)', async () => {
|
it('/inventory-adjustments/quick (POST)', async () => {
|
||||||
const itemResponse = await request(app.getHttpServer())
|
const itemResponse = await request(app.getHttpServer())
|
||||||
.post('/items')
|
.post('/items')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(makeItemRequest())
|
.send(makeItemRequest())
|
||||||
.expect(201);
|
.expect(201);
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ describe('Inventory Adjustments (e2e)', () => {
|
|||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.post('/inventory-adjustments/quick')
|
.post('/inventory-adjustments/quick')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(createInventoryAdjustment({ itemId }))
|
.send(createInventoryAdjustment({ itemId }))
|
||||||
.expect(201);
|
.expect(201);
|
||||||
});
|
});
|
||||||
@@ -44,7 +44,7 @@ describe('Inventory Adjustments (e2e)', () => {
|
|||||||
it('/inventory-adjustments/:id (DELETE)', async () => {
|
it('/inventory-adjustments/:id (DELETE)', async () => {
|
||||||
const itemResponse = await request(app.getHttpServer())
|
const itemResponse = await request(app.getHttpServer())
|
||||||
.post('/items')
|
.post('/items')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(makeItemRequest())
|
.send(makeItemRequest())
|
||||||
.expect(201);
|
.expect(201);
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ describe('Inventory Adjustments (e2e)', () => {
|
|||||||
|
|
||||||
const inventoryAdjustmentResponse = await request(app.getHttpServer())
|
const inventoryAdjustmentResponse = await request(app.getHttpServer())
|
||||||
.post('/inventory-adjustments/quick')
|
.post('/inventory-adjustments/quick')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(createInventoryAdjustment({ itemId }))
|
.send(createInventoryAdjustment({ itemId }))
|
||||||
.expect(201);
|
.expect(201);
|
||||||
|
|
||||||
@@ -60,21 +60,21 @@ describe('Inventory Adjustments (e2e)', () => {
|
|||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.delete(`/inventory-adjustments/${inventoryAdjustmentId}`)
|
.delete(`/inventory-adjustments/${inventoryAdjustmentId}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('/inventory-adjustments/:id (GET)', async () => {
|
it('/inventory-adjustments/:id (GET)', async () => {
|
||||||
const itemResponse = await request(app.getHttpServer())
|
const itemResponse = await request(app.getHttpServer())
|
||||||
.post('/items')
|
.post('/items')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(makeItemRequest())
|
.send(makeItemRequest())
|
||||||
.expect(201);
|
.expect(201);
|
||||||
|
|
||||||
const itemId = itemResponse.text;
|
const itemId = itemResponse.text;
|
||||||
const inventoryAdjustmentResponse = await request(app.getHttpServer())
|
const inventoryAdjustmentResponse = await request(app.getHttpServer())
|
||||||
.post('/inventory-adjustments/quick')
|
.post('/inventory-adjustments/quick')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(createInventoryAdjustment({ itemId }))
|
.send(createInventoryAdjustment({ itemId }))
|
||||||
.expect(201);
|
.expect(201);
|
||||||
|
|
||||||
@@ -82,21 +82,21 @@ describe('Inventory Adjustments (e2e)', () => {
|
|||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.get(`/inventory-adjustments/${inventoryAdjustmentId}`)
|
.get(`/inventory-adjustments/${inventoryAdjustmentId}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('/inventory-adjustments/:id/publish (POST)', async () => {
|
it('/inventory-adjustments/:id/publish (POST)', async () => {
|
||||||
const itemResponse = await request(app.getHttpServer())
|
const itemResponse = await request(app.getHttpServer())
|
||||||
.post('/items')
|
.post('/items')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(makeItemRequest())
|
.send(makeItemRequest())
|
||||||
.expect(201);
|
.expect(201);
|
||||||
|
|
||||||
const itemId = itemResponse.text;
|
const itemId = itemResponse.text;
|
||||||
const inventoryAdjustmentResponse = await request(app.getHttpServer())
|
const inventoryAdjustmentResponse = await request(app.getHttpServer())
|
||||||
.post('/inventory-adjustments/quick')
|
.post('/inventory-adjustments/quick')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send({
|
.send({
|
||||||
...createInventoryAdjustment({ itemId }),
|
...createInventoryAdjustment({ itemId }),
|
||||||
publish: false,
|
publish: false,
|
||||||
@@ -107,7 +107,7 @@ describe('Inventory Adjustments (e2e)', () => {
|
|||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.put(`/inventory-adjustments/${inventoryAdjustmentId}/publish`)
|
.put(`/inventory-adjustments/${inventoryAdjustmentId}/publish`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import * as request from 'supertest';
|
import * as request from 'supertest';
|
||||||
import { faker } from '@faker-js/faker';
|
import { faker } from '@faker-js/faker';
|
||||||
import { app } from './init-app-test';
|
import { app, orgainzationId } from './init-app-test';
|
||||||
|
|
||||||
describe('Item Categories(e2e)', () => {
|
describe('Item Categories(e2e)', () => {
|
||||||
it('/item-categories (POST)', () => {
|
it('/item-categories (POST)', () => {
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.post('/item-categories')
|
.post('/item-categories')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send({
|
.send({
|
||||||
name: faker.person.fullName(),
|
name: faker.person.fullName(),
|
||||||
description: faker.lorem.sentence(),
|
description: faker.lorem.sentence(),
|
||||||
@@ -17,7 +17,7 @@ describe('Item Categories(e2e)', () => {
|
|||||||
it('/item-categories/:id (GET)', async () => {
|
it('/item-categories/:id (GET)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/item-categories')
|
.post('/item-categories')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send({
|
.send({
|
||||||
name: faker.person.fullName(),
|
name: faker.person.fullName(),
|
||||||
description: faker.lorem.sentence(),
|
description: faker.lorem.sentence(),
|
||||||
@@ -26,14 +26,14 @@ describe('Item Categories(e2e)', () => {
|
|||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.get(`/item-categories/${itemCategoryId}`)
|
.get(`/item-categories/${itemCategoryId}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('/item-categories/:id (DELETE)', async () => {
|
it('/item-categories/:id (DELETE)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/item-categories')
|
.post('/item-categories')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send({
|
.send({
|
||||||
name: faker.person.fullName(),
|
name: faker.person.fullName(),
|
||||||
description: faker.lorem.sentence(),
|
description: faker.lorem.sentence(),
|
||||||
@@ -43,7 +43,7 @@ describe('Item Categories(e2e)', () => {
|
|||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.delete(`/item-categories/${itemCategoryId}`)
|
.delete(`/item-categories/${itemCategoryId}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import * as request from 'supertest';
|
import * as request from 'supertest';
|
||||||
import { faker } from '@faker-js/faker';
|
import { faker } from '@faker-js/faker';
|
||||||
import { app } from './init-app-test';
|
import { app, orgainzationId } from './init-app-test';
|
||||||
|
|
||||||
const makeItemRequest = () => ({
|
const makeItemRequest = () => ({
|
||||||
name: faker.commerce.productName(),
|
name: faker.commerce.productName(),
|
||||||
@@ -11,7 +11,7 @@ describe('Items (e2e)', () => {
|
|||||||
it('/items (POST)', () => {
|
it('/items (POST)', () => {
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.post('/items')
|
.post('/items')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(makeItemRequest())
|
.send(makeItemRequest())
|
||||||
.expect(201);
|
.expect(201);
|
||||||
});
|
});
|
||||||
@@ -19,108 +19,108 @@ describe('Items (e2e)', () => {
|
|||||||
it('/items/:id (PUT)', async () => {
|
it('/items/:id (PUT)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/items')
|
.post('/items')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(makeItemRequest());
|
.send(makeItemRequest());
|
||||||
const itemId = response.body.id;
|
const itemId = response.body.id;
|
||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.put(`/items/${itemId}`)
|
.put(`/items/${itemId}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(makeItemRequest());
|
.send(makeItemRequest());
|
||||||
});
|
});
|
||||||
|
|
||||||
it('/items/:id/inactivate (PATCH)', async () => {
|
it('/items/:id/inactivate (PATCH)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/items')
|
.post('/items')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(makeItemRequest());
|
.send(makeItemRequest());
|
||||||
const itemId = response.text;
|
const itemId = response.text;
|
||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.patch(`/items/${itemId}/inactivate`)
|
.patch(`/items/${itemId}/inactivate`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('/items/:id/activate (PATCH)', async () => {
|
it('/items/:id/activate (PATCH)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/items')
|
.post('/items')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(makeItemRequest());
|
.send(makeItemRequest());
|
||||||
const itemId = response.text;
|
const itemId = response.text;
|
||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.patch(`/items/${itemId}/activate`)
|
.patch(`/items/${itemId}/activate`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('/items/:id (DELETE)', async () => {
|
it('/items/:id (DELETE)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/items')
|
.post('/items')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(makeItemRequest());
|
.send(makeItemRequest());
|
||||||
const itemId = response.text;
|
const itemId = response.text;
|
||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.delete(`/items/${itemId}`)
|
.delete(`/items/${itemId}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('/items/:id/invoices (GET)', async () => {
|
it('/items/:id/invoices (GET)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/items')
|
.post('/items')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(makeItemRequest());
|
.send(makeItemRequest());
|
||||||
|
|
||||||
const itemId = response.text;
|
const itemId = response.text;
|
||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.get(`/items/${itemId}/invoices`)
|
.get(`/items/${itemId}/invoices`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('/items/:id/bills (GET)', async () => {
|
it('/items/:id/bills (GET)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/items')
|
.post('/items')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(makeItemRequest());
|
.send(makeItemRequest());
|
||||||
|
|
||||||
const itemId = response.text;
|
const itemId = response.text;
|
||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.get(`/items/${itemId}/bills`)
|
.get(`/items/${itemId}/bills`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('/items/:id/estimates (GET)', async () => {
|
it('/items/:id/estimates (GET)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/items')
|
.post('/items')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(makeItemRequest());
|
.send(makeItemRequest());
|
||||||
|
|
||||||
const itemId = response.text;
|
const itemId = response.text;
|
||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.get(`/items/${itemId}/estimates`)
|
.get(`/items/${itemId}/estimates`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('/items/:id/receipts (GET)', async () => {
|
it('/items/:id/receipts (GET)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/items')
|
.post('/items')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(makeItemRequest());
|
.send(makeItemRequest());
|
||||||
|
|
||||||
const itemId = response.text;
|
const itemId = response.text;
|
||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.get(`/items/${itemId}/receipts`)
|
.get(`/items/${itemId}/receipts`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,5 +8,7 @@
|
|||||||
},
|
},
|
||||||
"moduleNameMapper": {
|
"moduleNameMapper": {
|
||||||
"^@/(.*)$": "<rootDir>/../src/$1"
|
"^@/(.*)$": "<rootDir>/../src/$1"
|
||||||
}
|
},
|
||||||
|
"maxWorkers": 1,
|
||||||
|
"maxConcurrency": 1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import * as request from 'supertest';
|
import * as request from 'supertest';
|
||||||
import { faker } from '@faker-js/faker';
|
import { faker } from '@faker-js/faker';
|
||||||
import { app } from './init-app-test';
|
import { app, orgainzationId } from './init-app-test';
|
||||||
|
|
||||||
const makeManualJournalRequest = () => ({
|
const makeManualJournalRequest = () => ({
|
||||||
date: '2022-06-01',
|
date: '2022-06-01',
|
||||||
@@ -27,7 +27,7 @@ describe.only('Manual Journals (e2e)', () => {
|
|||||||
it('/manual-journals (POST)', () => {
|
it('/manual-journals (POST)', () => {
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.post('/manual-journals')
|
.post('/manual-journals')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(makeManualJournalRequest())
|
.send(makeManualJournalRequest())
|
||||||
.expect(201);
|
.expect(201);
|
||||||
});
|
});
|
||||||
@@ -35,14 +35,14 @@ describe.only('Manual Journals (e2e)', () => {
|
|||||||
it('/manual-journals/:id (DELETE)', async () => {
|
it('/manual-journals/:id (DELETE)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/manual-journals')
|
.post('/manual-journals')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(makeManualJournalRequest());
|
.send(makeManualJournalRequest());
|
||||||
|
|
||||||
const journalId = response.body.id;
|
const journalId = response.body.id;
|
||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.delete(`/manual-journals/${journalId}`)
|
.delete(`/manual-journals/${journalId}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send()
|
.send()
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
@@ -50,14 +50,14 @@ describe.only('Manual Journals (e2e)', () => {
|
|||||||
it('/manual-journals/:id (GET)', async () => {
|
it('/manual-journals/:id (GET)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/manual-journals')
|
.post('/manual-journals')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(makeManualJournalRequest());
|
.send(makeManualJournalRequest());
|
||||||
|
|
||||||
const journalId = response.body.id;
|
const journalId = response.body.id;
|
||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.get(`/manual-journals/${journalId}`)
|
.get(`/manual-journals/${journalId}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send()
|
.send()
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
@@ -66,14 +66,14 @@ describe.only('Manual Journals (e2e)', () => {
|
|||||||
const manualJournal = makeManualJournalRequest();
|
const manualJournal = makeManualJournalRequest();
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/manual-journals')
|
.post('/manual-journals')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(manualJournal);
|
.send(manualJournal);
|
||||||
|
|
||||||
const journalId = response.body.id;
|
const journalId = response.body.id;
|
||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.put(`/manual-journals/${journalId}`)
|
.put(`/manual-journals/${journalId}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(manualJournal)
|
.send(manualJournal)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
@@ -81,14 +81,14 @@ describe.only('Manual Journals (e2e)', () => {
|
|||||||
it('/manual-journals/:id/publish (PUT)', async () => {
|
it('/manual-journals/:id/publish (PUT)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/manual-journals')
|
.post('/manual-journals')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(makeManualJournalRequest());
|
.send(makeManualJournalRequest());
|
||||||
|
|
||||||
const journalId = response.body.id;
|
const journalId = response.body.id;
|
||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.put(`/manual-journals/${journalId}/publish`)
|
.put(`/manual-journals/${journalId}/publish`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send()
|
.send()
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
import * as request from 'supertest';
|
import * as request from 'supertest';
|
||||||
import { faker } from '@faker-js/faker';
|
import { faker } from '@faker-js/faker';
|
||||||
import { app } from './init-app-test';
|
import { app, orgainzationId } from './init-app-test';
|
||||||
|
|
||||||
|
let invoice;
|
||||||
|
let customerId;
|
||||||
|
let itemId;
|
||||||
|
|
||||||
const requestPaymentReceivedBody = (invoiceId: number) => ({
|
const requestPaymentReceivedBody = (invoiceId: number) => ({
|
||||||
customerId: 2,
|
customerId: customerId,
|
||||||
paymentDate: '2023-01-01',
|
paymentDate: '2023-01-01',
|
||||||
exchangeRate: 1,
|
exchangeRate: 1,
|
||||||
referenceNo: faker.string.uuid(),
|
referenceNo: faker.string.uuid(),
|
||||||
@@ -15,7 +19,7 @@ const requestPaymentReceivedBody = (invoiceId: number) => ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const requestSaleInvoiceBody = () => ({
|
const requestSaleInvoiceBody = () => ({
|
||||||
customerId: 2,
|
customerId: customerId,
|
||||||
invoiceDate: '2023-01-01',
|
invoiceDate: '2023-01-01',
|
||||||
dueDate: '2023-02-01',
|
dueDate: '2023-02-01',
|
||||||
invoiceNo: faker.string.uuid(),
|
invoiceNo: faker.string.uuid(),
|
||||||
@@ -28,7 +32,7 @@ const requestSaleInvoiceBody = () => ({
|
|||||||
entries: [
|
entries: [
|
||||||
{
|
{
|
||||||
index: 1,
|
index: 1,
|
||||||
itemId: 1001,
|
itemId: itemId,
|
||||||
quantity: 100,
|
quantity: 100,
|
||||||
rate: 1000,
|
rate: 1000,
|
||||||
description: 'Item description...',
|
description: 'Item description...',
|
||||||
@@ -36,22 +40,43 @@ const requestSaleInvoiceBody = () => ({
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
let invoice;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
const response = await request(app.getHttpServer())
|
|
||||||
.post('/sale-invoices')
|
|
||||||
.set('organization-id', '4064541lv40nhca')
|
|
||||||
.send(requestSaleInvoiceBody());
|
|
||||||
|
|
||||||
invoice = response.body;
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Payment Received (e2e)', () => {
|
describe('Payment Received (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);
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const response = await request(app.getHttpServer())
|
||||||
|
.post('/sale-invoices')
|
||||||
|
.set('organization-id', orgainzationId)
|
||||||
|
.send(requestSaleInvoiceBody());
|
||||||
|
|
||||||
|
invoice = response.body;
|
||||||
|
});
|
||||||
|
|
||||||
it('/payments-received (POST)', () => {
|
it('/payments-received (POST)', () => {
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.post('/payments-received')
|
.post('/payments-received')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(requestPaymentReceivedBody(invoice.id))
|
.send(requestPaymentReceivedBody(invoice.id))
|
||||||
.expect(201);
|
.expect(201);
|
||||||
});
|
});
|
||||||
@@ -59,49 +84,49 @@ describe('Payment Received (e2e)', () => {
|
|||||||
it('/payments-received/:id (DELETE)', async () => {
|
it('/payments-received/:id (DELETE)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/payments-received')
|
.post('/payments-received')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(requestPaymentReceivedBody(invoice.id));
|
.send(requestPaymentReceivedBody(invoice.id));
|
||||||
|
|
||||||
const paymentReceivedId = response.body.id;
|
const paymentReceivedId = response.body.id;
|
||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.delete(`/payments-received/${paymentReceivedId}`)
|
.delete(`/payments-received/${paymentReceivedId}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('/payments-received/:id (GET)', async () => {
|
it('/payments-received/:id (GET)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/payments-received')
|
.post('/payments-received')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(requestPaymentReceivedBody(invoice.id));
|
.send(requestPaymentReceivedBody(invoice.id));
|
||||||
|
|
||||||
const paymentReceivedId = response.body.id;
|
const paymentReceivedId = response.body.id;
|
||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.get(`/payments-received/${paymentReceivedId}`)
|
.get(`/payments-received/${paymentReceivedId}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('/payments-received/:id/invoices (GET)', async () => {
|
it('/payments-received/:id/invoices (GET)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/payments-received')
|
.post('/payments-received')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(requestPaymentReceivedBody(invoice.id));
|
.send(requestPaymentReceivedBody(invoice.id));
|
||||||
|
|
||||||
const paymentReceivedId = response.body.id;
|
const paymentReceivedId = response.body.id;
|
||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.get(`/payments-received/${paymentReceivedId}/invoices`)
|
.get(`/payments-received/${paymentReceivedId}/invoices`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('/payments-received/state (GET)', () => {
|
it('/payments-received/state (GET)', () => {
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.get('/payments-received/state')
|
.get('/payments-received/state')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import * as request from 'supertest';
|
import * as request from 'supertest';
|
||||||
import { faker } from '@faker-js/faker';
|
import { faker } from '@faker-js/faker';
|
||||||
import { app } from './init-app-test';
|
import { app, orgainzationId } from './init-app-test';
|
||||||
|
|
||||||
describe('Pdf Templates (e2e)', () => {
|
describe('Pdf Templates (e2e)', () => {
|
||||||
it('/pdf-templates (POST)', () => {
|
it('/pdf-templates (POST)', () => {
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.post('/pdf-templates')
|
.post('/pdf-templates')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send({
|
.send({
|
||||||
template_name: 'Standard',
|
template_name: 'Standard',
|
||||||
resource: 'SaleInvoice',
|
resource: 'SaleInvoice',
|
||||||
@@ -18,7 +18,7 @@ describe('Pdf Templates (e2e)', () => {
|
|||||||
it('/pdf-templates (DELETE)', async () => {
|
it('/pdf-templates (DELETE)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/pdf-templates')
|
.post('/pdf-templates')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send({
|
.send({
|
||||||
template_name: 'Standard',
|
template_name: 'Standard',
|
||||||
resource: 'SaleInvoice',
|
resource: 'SaleInvoice',
|
||||||
@@ -28,14 +28,14 @@ describe('Pdf Templates (e2e)', () => {
|
|||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.delete(`/pdf-templates/${pdfTemplateId}`)
|
.delete(`/pdf-templates/${pdfTemplateId}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('/pdf-templates/:id (GET)', async () => {
|
it('/pdf-templates/:id (GET)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/pdf-templates')
|
.post('/pdf-templates')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send({
|
.send({
|
||||||
template_name: 'Standard',
|
template_name: 'Standard',
|
||||||
resource: 'SaleInvoice',
|
resource: 'SaleInvoice',
|
||||||
@@ -45,14 +45,14 @@ describe('Pdf Templates (e2e)', () => {
|
|||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.get(`/pdf-templates/${pdfTemplateId}`)
|
.get(`/pdf-templates/${pdfTemplateId}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('/pdf-templates/:id/assign-default (POST)', async () => {
|
it('/pdf-templates/:id/assign-default (POST)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/pdf-templates')
|
.post('/pdf-templates')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send({
|
.send({
|
||||||
template_name: 'Standard',
|
template_name: 'Standard',
|
||||||
resource: 'SaleInvoice',
|
resource: 'SaleInvoice',
|
||||||
@@ -62,7 +62,7 @@ describe('Pdf Templates (e2e)', () => {
|
|||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.put(`/pdf-templates/${pdfTemplateId}/assign-default`)
|
.put(`/pdf-templates/${pdfTemplateId}/assign-default`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
import * as request from 'supertest';
|
import * as request from 'supertest';
|
||||||
import { faker } from '@faker-js/faker';
|
import { faker } from '@faker-js/faker';
|
||||||
import { app } from './init-app-test';
|
import { app, orgainzationId } from './init-app-test';
|
||||||
|
|
||||||
const makeEstimateRequest = () => ({
|
let customerId;
|
||||||
customerId: 2,
|
let itemId;
|
||||||
|
|
||||||
|
const makeEstimateRequest = ({ ...props } = {}) => ({
|
||||||
|
customerId: customerId,
|
||||||
estimateDate: '2022-02-02',
|
estimateDate: '2022-02-02',
|
||||||
expirationDate: '2020-03-02',
|
expirationDate: '2020-03-02',
|
||||||
delivered: false,
|
delivered: false,
|
||||||
@@ -13,19 +16,43 @@ const makeEstimateRequest = () => ({
|
|||||||
entries: [
|
entries: [
|
||||||
{
|
{
|
||||||
index: 1,
|
index: 1,
|
||||||
itemId: 1001,
|
itemId: itemId,
|
||||||
quantity: 3,
|
quantity: 3,
|
||||||
rate: 1000,
|
rate: 1000,
|
||||||
description: "It's description here.",
|
description: "It's description here.",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
...props,
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Sale Estimates (e2e)', () => {
|
describe('Sale Estimates (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('/sale-estimates (POST)', async () => {
|
it('/sale-estimates (POST)', async () => {
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.post('/sale-estimates')
|
.post('/sale-estimates')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(makeEstimateRequest())
|
.send(makeEstimateRequest())
|
||||||
.expect(201);
|
.expect(201);
|
||||||
});
|
});
|
||||||
@@ -33,63 +60,63 @@ describe('Sale Estimates (e2e)', () => {
|
|||||||
it('/sale-estimates (DELETE)', async () => {
|
it('/sale-estimates (DELETE)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/sale-estimates')
|
.post('/sale-estimates')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(makeEstimateRequest());
|
.send(makeEstimateRequest());
|
||||||
|
|
||||||
const estimateId = response.body.id;
|
const estimateId = response.body.id;
|
||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.delete(`/sale-estimates/${estimateId}`)
|
.delete(`/sale-estimates/${estimateId}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('/sale-estimates/state (GET)', async () => {
|
it('/sale-estimates/state (GET)', async () => {
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.get('/sale-estimates/state')
|
.get('/sale-estimates/state')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('/sale-estimates/:id (GET)', async () => {
|
it('/sale-estimates/:id (GET)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/sale-estimates')
|
.post('/sale-estimates')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(makeEstimateRequest());
|
.send(makeEstimateRequest());
|
||||||
|
|
||||||
const estimateId = response.body.id;
|
const estimateId = response.body.id;
|
||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.get(`/sale-estimates/${estimateId}`)
|
.get(`/sale-estimates/${estimateId}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('/sale-estimates/:id/approve (PUT)', async () => {
|
it('/sale-estimates/:id/approve (PUT)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/sale-estimates')
|
.post('/sale-estimates')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send({ ...makeEstimateRequest(), delivered: true });
|
.send({ ...makeEstimateRequest(), delivered: true });
|
||||||
|
|
||||||
const estimateId = response.body.id;
|
const estimateId = response.body.id;
|
||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.put(`/sale-estimates/${estimateId}/approve`)
|
.put(`/sale-estimates/${estimateId}/approve`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('/sale-estimates/:id/reject (PUT)', async () => {
|
it('/sale-estimates/:id/reject (PUT)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/sale-estimates')
|
.post('/sale-estimates')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send({ ...makeEstimateRequest(), delivered: true });
|
.send({ ...makeEstimateRequest(), delivered: true });
|
||||||
|
|
||||||
const estimateId = response.body.id;
|
const estimateId = response.body.id;
|
||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.put(`/sale-estimates/${estimateId}/reject`)
|
.put(`/sale-estimates/${estimateId}/reject`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
import * as request from 'supertest';
|
import * as request from 'supertest';
|
||||||
import { faker } from '@faker-js/faker';
|
import { faker } from '@faker-js/faker';
|
||||||
import { app } from './init-app-test';
|
import { app, orgainzationId } from './init-app-test';
|
||||||
|
|
||||||
|
let customerId;
|
||||||
|
let itemId;
|
||||||
|
|
||||||
const requestSaleInvoiceBody = () => ({
|
const requestSaleInvoiceBody = () => ({
|
||||||
customerId: 2,
|
customerId: customerId,
|
||||||
invoiceDate: '2023-01-01',
|
invoiceDate: '2023-01-01',
|
||||||
dueDate: '2023-02-01',
|
dueDate: '2023-02-01',
|
||||||
invoiceNo: faker.string.uuid(),
|
invoiceNo: faker.string.uuid(),
|
||||||
@@ -16,7 +19,7 @@ const requestSaleInvoiceBody = () => ({
|
|||||||
entries: [
|
entries: [
|
||||||
{
|
{
|
||||||
index: 1,
|
index: 1,
|
||||||
itemId: 1001,
|
itemId: itemId,
|
||||||
quantity: 2,
|
quantity: 2,
|
||||||
rate: 1000,
|
rate: 1000,
|
||||||
description: 'Item description...',
|
description: 'Item description...',
|
||||||
@@ -25,10 +28,33 @@ const requestSaleInvoiceBody = () => ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('Sale Invoices (e2e)', () => {
|
describe('Sale Invoices (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('/sale-invoices (POST)', () => {
|
it('/sale-invoices (POST)', () => {
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.post('/sale-invoices')
|
.post('/sale-invoices')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(requestSaleInvoiceBody())
|
.send(requestSaleInvoiceBody())
|
||||||
.expect(201);
|
.expect(201);
|
||||||
});
|
});
|
||||||
@@ -36,24 +62,24 @@ describe('Sale Invoices (e2e)', () => {
|
|||||||
it('/sale-invoices/:id (DELETE)', async () => {
|
it('/sale-invoices/:id (DELETE)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/sale-invoices')
|
.post('/sale-invoices')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(requestSaleInvoiceBody());
|
.send(requestSaleInvoiceBody());
|
||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.delete(`/sale-invoices/${response.body.id}`)
|
.delete(`/sale-invoices/${response.body.id}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('/sale-invoices/:id (PUT)', async () => {
|
it('/sale-invoices/:id (PUT)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/sale-invoices')
|
.post('/sale-invoices')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(requestSaleInvoiceBody());
|
.send(requestSaleInvoiceBody());
|
||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.put(`/sale-invoices/${response.body.id}`)
|
.put(`/sale-invoices/${response.body.id}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(requestSaleInvoiceBody())
|
.send(requestSaleInvoiceBody())
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
@@ -61,48 +87,48 @@ describe('Sale Invoices (e2e)', () => {
|
|||||||
it('/sale-invoices/:id (GET)', async () => {
|
it('/sale-invoices/:id (GET)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/sale-invoices')
|
.post('/sale-invoices')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(requestSaleInvoiceBody());
|
.send(requestSaleInvoiceBody());
|
||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.get(`/sale-invoices/${response.body.id}`)
|
.get(`/sale-invoices/${response.body.id}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('/sale-invoices/:id/state (GET)', async () => {
|
it('/sale-invoices/:id/state (GET)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/sale-invoices')
|
.post('/sale-invoices')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(requestSaleInvoiceBody());
|
.send(requestSaleInvoiceBody());
|
||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.get(`/sale-invoices/${response.body.id}/state`)
|
.get(`/sale-invoices/${response.body.id}/state`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('/sale-invoices/:id/payments (GET)', async () => {
|
it('/sale-invoices/:id/payments (GET)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/sale-invoices')
|
.post('/sale-invoices')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(requestSaleInvoiceBody());
|
.send(requestSaleInvoiceBody());
|
||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.get(`/sale-invoices/${response.body.id}/payments`)
|
.get(`/sale-invoices/${response.body.id}/payments`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('/sale-invoices/:id/writeoff (POST)', async () => {
|
it('/sale-invoices/:id/writeoff (POST)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/sale-invoices')
|
.post('/sale-invoices')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(requestSaleInvoiceBody());
|
.send(requestSaleInvoiceBody());
|
||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.post(`/sale-invoices/${response.body.id}/writeoff`)
|
.post(`/sale-invoices/${response.body.id}/writeoff`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send({
|
.send({
|
||||||
expenseAccountId: 1024,
|
expenseAccountId: 1024,
|
||||||
date: '2023-01-01',
|
date: '2023-01-01',
|
||||||
@@ -114,12 +140,12 @@ describe('Sale Invoices (e2e)', () => {
|
|||||||
it('/sale-invoices/:id/cancel-writeoff (POST)', async () => {
|
it('/sale-invoices/:id/cancel-writeoff (POST)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/sale-invoices')
|
.post('/sale-invoices')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(requestSaleInvoiceBody());
|
.send(requestSaleInvoiceBody());
|
||||||
|
|
||||||
await request(app.getHttpServer())
|
await request(app.getHttpServer())
|
||||||
.post(`/sale-invoices/${response.body.id}/writeoff`)
|
.post(`/sale-invoices/${response.body.id}/writeoff`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send({
|
.send({
|
||||||
expenseAccountId: 1024,
|
expenseAccountId: 1024,
|
||||||
date: '2023-01-01',
|
date: '2023-01-01',
|
||||||
@@ -128,14 +154,14 @@ describe('Sale Invoices (e2e)', () => {
|
|||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.post(`/sale-invoices/${response.body.id}/cancel-writeoff`)
|
.post(`/sale-invoices/${response.body.id}/cancel-writeoff`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('/sale-invoices/:id/deliver (PUT)', async () => {
|
it('/sale-invoices/:id/deliver (PUT)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/sale-invoices')
|
.post('/sale-invoices')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send({
|
.send({
|
||||||
...requestSaleInvoiceBody(),
|
...requestSaleInvoiceBody(),
|
||||||
delivered: false,
|
delivered: false,
|
||||||
@@ -143,7 +169,7 @@ describe('Sale Invoices (e2e)', () => {
|
|||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.post(`/sale-invoices/${response.body.id}/deliver`)
|
.post(`/sale-invoices/${response.body.id}/deliver`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
import * as request from 'supertest';
|
import * as request from 'supertest';
|
||||||
import { faker } from '@faker-js/faker';
|
import { faker } from '@faker-js/faker';
|
||||||
import { app } from './init-app-test';
|
import { app, orgainzationId } from './init-app-test';
|
||||||
|
|
||||||
const receiptRequest = {
|
let customerId;
|
||||||
customerId: 2,
|
let itemId;
|
||||||
|
|
||||||
|
const makeReceiptRequest = () => ({
|
||||||
|
customerId: customerId,
|
||||||
depositAccountId: 1000,
|
depositAccountId: 1000,
|
||||||
receiptDate: '2022-02-02',
|
receiptDate: '2022-02-02',
|
||||||
referenceNo: '123',
|
referenceNo: '123',
|
||||||
@@ -15,50 +18,73 @@ const receiptRequest = {
|
|||||||
entries: [
|
entries: [
|
||||||
{
|
{
|
||||||
index: 1,
|
index: 1,
|
||||||
itemId: 1001,
|
itemId: itemId,
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
rate: 2000,
|
rate: 2000,
|
||||||
description: 'asdfsadf',
|
description: 'asdfsadf',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
});
|
||||||
|
|
||||||
describe('Sale Receipts (e2e)', () => {
|
describe('Sale Receipts (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('/sale-reeipts (POST)', () => {
|
it('/sale-reeipts (POST)', () => {
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.post('/sale-receipts')
|
.post('/sale-receipts')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(receiptRequest)
|
.send(makeReceiptRequest())
|
||||||
.expect(201);
|
.expect(201);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('/sale-receipts/:id (DELETE)', async () => {
|
it('/sale-receipts/:id (DELETE)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/sale-receipts')
|
.post('/sale-receipts')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(receiptRequest);
|
.send(makeReceiptRequest());
|
||||||
|
|
||||||
const receiptId = response.body.id;
|
const receiptId = response.body.id;
|
||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.delete(`/sale-receipts/${receiptId}`)
|
.delete(`/sale-receipts/${receiptId}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send();
|
.send();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('/sale-receipts/:id (PUT)', async () => {
|
it('/sale-receipts/:id (PUT)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/sale-receipts')
|
.post('/sale-receipts')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(receiptRequest);
|
.send(makeReceiptRequest());
|
||||||
|
|
||||||
const receiptId = response.body.id;
|
const receiptId = response.body.id;
|
||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.delete(`/sale-receipts/${receiptId}`)
|
.delete(`/sale-receipts/${receiptId}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send({
|
.send({
|
||||||
...receiptRequest,
|
...makeReceiptRequest(),
|
||||||
referenceNo: '321',
|
referenceNo: '321',
|
||||||
})
|
})
|
||||||
.expect(200);
|
.expect(200);
|
||||||
@@ -67,14 +93,14 @@ describe('Sale Receipts (e2e)', () => {
|
|||||||
it('/sale-receipts/:id (GET)', async () => {
|
it('/sale-receipts/:id (GET)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/sale-receipts')
|
.post('/sale-receipts')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(receiptRequest);
|
.send(makeReceiptRequest());
|
||||||
|
|
||||||
const receiptId = response.body.id;
|
const receiptId = response.body.id;
|
||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.get(`/sale-receipts/${receiptId}`)
|
.get(`/sale-receipts/${receiptId}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import * as request from 'supertest';
|
import * as request from 'supertest';
|
||||||
import { app } from './init-app-test';
|
import { app, orgainzationId } from './init-app-test';
|
||||||
|
|
||||||
const makeSettingsRequest = () => ({
|
const makeSettingsRequest = () => ({
|
||||||
options: [
|
options: [
|
||||||
@@ -20,7 +20,7 @@ describe('Settings (e2e)', () => {
|
|||||||
it('/settings (PUT)', () => {
|
it('/settings (PUT)', () => {
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.put('/settings')
|
.put('/settings')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(makeSettingsRequest())
|
.send(makeSettingsRequest())
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
@@ -28,7 +28,7 @@ describe('Settings (e2e)', () => {
|
|||||||
it('/settings (GET)', () => {
|
it('/settings (GET)', () => {
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.get('/settings')
|
.get('/settings')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import * as request from 'supertest';
|
import * as request from 'supertest';
|
||||||
import { faker } from '@faker-js/faker';
|
import { faker } from '@faker-js/faker';
|
||||||
import { app } from './init-app-test';
|
import { app, orgainzationId } from './init-app-test';
|
||||||
|
|
||||||
describe('Item Categories(e2e)', () => {
|
describe('Item Categories(e2e)', () => {
|
||||||
it('/tax-rates (POST)', () => {
|
it('/tax-rates (POST)', () => {
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.post('/tax-rates')
|
.post('/tax-rates')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send({
|
.send({
|
||||||
name: faker.person.fullName(),
|
name: faker.person.fullName(),
|
||||||
rate: 2,
|
rate: 2,
|
||||||
@@ -19,7 +19,7 @@ describe('Item Categories(e2e)', () => {
|
|||||||
it('/tax-rates/:id (DELETE)', async () => {
|
it('/tax-rates/:id (DELETE)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/tax-rates')
|
.post('/tax-rates')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send({
|
.send({
|
||||||
name: faker.person.fullName(),
|
name: faker.person.fullName(),
|
||||||
rate: 2,
|
rate: 2,
|
||||||
@@ -30,7 +30,7 @@ describe('Item Categories(e2e)', () => {
|
|||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.delete(`/tax-rates/${taxRateId}`)
|
.delete(`/tax-rates/${taxRateId}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
|
|
||||||
import * as request from 'supertest';
|
import * as request from 'supertest';
|
||||||
import { app } from './init-app-test';
|
import { app, orgainzationId } from './init-app-test';
|
||||||
|
|
||||||
describe('Transactions Locking (e2e)', () => {
|
describe.only('Transactions Locking (e2e)', () => {
|
||||||
it('/transactions-locking (PUT)', () => {
|
it('/transactions-locking/lock (PUT)', () => {
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.put('/transactions-locking')
|
.put('/transactions-locking/lock')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send({
|
.send({
|
||||||
module: 'all',
|
module: 'all',
|
||||||
lock_to_date: '2025-01-01',
|
lock_to_date: '2025-01-01',
|
||||||
@@ -14,4 +13,92 @@ describe('Transactions Locking (e2e)', () => {
|
|||||||
})
|
})
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
it('/transactions-locking/cancel-lock (PUT)', async () => {
|
||||||
|
await request(app.getHttpServer())
|
||||||
|
.put('/transactions-locking/lock')
|
||||||
|
.set('organization-id', orgainzationId)
|
||||||
|
.send({
|
||||||
|
module: 'all',
|
||||||
|
lock_to_date: '2025-01-01',
|
||||||
|
reason: 'test',
|
||||||
|
})
|
||||||
|
.expect(200);
|
||||||
|
|
||||||
|
return request(app.getHttpServer())
|
||||||
|
.put('/transactions-locking/cancel-lock')
|
||||||
|
.set('organization-id', orgainzationId)
|
||||||
|
.expect(200);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('/transactions-locking/unlock-partial (PUT)', async () => {
|
||||||
|
await request(app.getHttpServer())
|
||||||
|
.put('/transactions-locking/lock')
|
||||||
|
.set('organization-id', orgainzationId)
|
||||||
|
.send({
|
||||||
|
module: 'all',
|
||||||
|
lock_to_date: '2025-01-01',
|
||||||
|
reason: 'test',
|
||||||
|
})
|
||||||
|
.expect(200);
|
||||||
|
|
||||||
|
return request(app.getHttpServer())
|
||||||
|
.put('/transactions-locking/cancel-lock')
|
||||||
|
.set('organization-id', orgainzationId)
|
||||||
|
.send({
|
||||||
|
module: 'all',
|
||||||
|
unlockFromDate: '2025-01-01',
|
||||||
|
unlockToDate: '2025-12-31',
|
||||||
|
reason: 'test partial unlock',
|
||||||
|
})
|
||||||
|
.expect(200);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('/transactions-locking/cancel-unlock-partial (PUT)', async () => {
|
||||||
|
await request(app.getHttpServer())
|
||||||
|
.put('/transactions-locking/lock')
|
||||||
|
.set('organization-id', orgainzationId)
|
||||||
|
.send({
|
||||||
|
module: 'all',
|
||||||
|
lock_to_date: '2025-01-01',
|
||||||
|
reason: 'test',
|
||||||
|
})
|
||||||
|
.expect(200);
|
||||||
|
|
||||||
|
await request(app.getHttpServer())
|
||||||
|
.put('/transactions-locking/unlock-partial')
|
||||||
|
.set('organization-id', orgainzationId)
|
||||||
|
.send({
|
||||||
|
module: 'all',
|
||||||
|
unlockFromDate: '2025-01-01',
|
||||||
|
unlockToDate: '2025-12-31',
|
||||||
|
reason: 'test partial unlock',
|
||||||
|
})
|
||||||
|
.expect(200);
|
||||||
|
|
||||||
|
return request(app.getHttpServer())
|
||||||
|
.put('/transactions-locking/cancel-unlock-partial')
|
||||||
|
.set('organization-id', orgainzationId)
|
||||||
|
.send({
|
||||||
|
module: 'all',
|
||||||
|
unlockFromDate: '2025-01-01',
|
||||||
|
unlockToDate: '2025-12-31',
|
||||||
|
reason: 'test partial unlock',
|
||||||
|
})
|
||||||
|
.expect(200);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('/transactions-locking (GET)', () => {
|
||||||
|
return request(app.getHttpServer())
|
||||||
|
.get('/transactions-locking')
|
||||||
|
.set('organization-id', orgainzationId)
|
||||||
|
.expect(200);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('/transactions-locking/:module (GET)', () => {
|
||||||
|
return request(app.getHttpServer())
|
||||||
|
.get('/transactions-locking/all')
|
||||||
|
.set('organization-id', orgainzationId)
|
||||||
|
.expect(200);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
@@ -1,16 +1,19 @@
|
|||||||
import * as request from 'supertest';
|
import * as request from 'supertest';
|
||||||
import { app } from './init-app-test';
|
|
||||||
import { faker } from '@faker-js/faker';
|
import { faker } from '@faker-js/faker';
|
||||||
|
import { app, orgainzationId } from './init-app-test';
|
||||||
|
|
||||||
|
let vendorId;
|
||||||
|
let itemId;
|
||||||
|
|
||||||
const requestVendorCredit = () => ({
|
const requestVendorCredit = () => ({
|
||||||
vendorId: 3,
|
vendorId: vendorId,
|
||||||
exchangeRate: 1,
|
exchangeRate: 1,
|
||||||
vendorCreditNumber: faker.string.uuid(),
|
vendorCreditNumber: faker.string.uuid(),
|
||||||
vendorCreditDate: '2025-01-01',
|
vendorCreditDate: '2025-01-01',
|
||||||
entries: [
|
entries: [
|
||||||
{
|
{
|
||||||
index: 1,
|
index: 1,
|
||||||
item_id: 1000,
|
item_id: itemId,
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
rate: 1000,
|
rate: 1000,
|
||||||
description: "It's description here.",
|
description: "It's description here.",
|
||||||
@@ -21,10 +24,33 @@ const requestVendorCredit = () => ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('Vendor Credits (e2e)', () => {
|
describe('Vendor Credits (e2e)', () => {
|
||||||
|
beforeAll(async () => {
|
||||||
|
const vendor = await request(app.getHttpServer())
|
||||||
|
.post('/vendors')
|
||||||
|
.set('organization-id', orgainzationId)
|
||||||
|
.send({ displayName: 'Test Customer' });
|
||||||
|
|
||||||
|
vendorId = vendor.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('/vendor-credits (POST)', () => {
|
it('/vendor-credits (POST)', () => {
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.post('/vendor-credits')
|
.post('/vendor-credits')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(requestVendorCredit())
|
.send(requestVendorCredit())
|
||||||
.expect(201);
|
.expect(201);
|
||||||
});
|
});
|
||||||
@@ -32,42 +58,42 @@ describe('Vendor Credits (e2e)', () => {
|
|||||||
it('/vendor-credits/:id (DELETE)', async () => {
|
it('/vendor-credits/:id (DELETE)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/vendor-credits')
|
.post('/vendor-credits')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(requestVendorCredit());
|
.send(requestVendorCredit());
|
||||||
|
|
||||||
const vendorCreditId = response.body.id;
|
const vendorCreditId = response.body.id;
|
||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.delete(`/vendor-credits/${vendorCreditId}`)
|
.delete(`/vendor-credits/${vendorCreditId}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('/vendor-credits/:id/open (POST)', async () => {
|
it('/vendor-credits/:id/open (POST)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/vendor-credits')
|
.post('/vendor-credits')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(requestVendorCredit());
|
.send(requestVendorCredit());
|
||||||
|
|
||||||
const vendorCreditId = response.body.id;
|
const vendorCreditId = response.body.id;
|
||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.put(`/vendor-credits/${vendorCreditId}/open`)
|
.put(`/vendor-credits/${vendorCreditId}/open`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('/vendor-credits/:id (GET)', async () => {
|
it('/vendor-credits/:id (GET)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/vendor-credits')
|
.post('/vendor-credits')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send(requestVendorCredit());
|
.send(requestVendorCredit());
|
||||||
|
|
||||||
const vendorCreditId = response.body.id;
|
const vendorCreditId = response.body.id;
|
||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.get(`/vendor-credits/${vendorCreditId}`)
|
.get(`/vendor-credits/${vendorCreditId}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import * as request from 'supertest';
|
import * as request from 'supertest';
|
||||||
import { faker } from '@faker-js/faker';
|
import { faker } from '@faker-js/faker';
|
||||||
import { app } from './init-app-test';
|
import { app, orgainzationId } from './init-app-test';
|
||||||
|
|
||||||
describe('Vendors (e2e)', () => {
|
describe.only('Vendors (e2e)', () => {
|
||||||
it('/vendors (POST)', () => {
|
it('/vendors (POST)', () => {
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.post('/vendors')
|
.post('/vendors')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send({
|
.send({
|
||||||
displayName: faker.commerce.productName(),
|
displayName: faker.commerce.productName(),
|
||||||
email: faker.internet.email(),
|
email: faker.internet.email(),
|
||||||
@@ -19,7 +19,7 @@ describe('Vendors (e2e)', () => {
|
|||||||
it('/vendors/:id (PUT)', async () => {
|
it('/vendors/:id (PUT)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/vendors')
|
.post('/vendors')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send({
|
.send({
|
||||||
displayName: faker.commerce.productName(),
|
displayName: faker.commerce.productName(),
|
||||||
email: faker.internet.email(),
|
email: faker.internet.email(),
|
||||||
@@ -30,7 +30,7 @@ describe('Vendors (e2e)', () => {
|
|||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.put(`/vendors/${vendorId}`)
|
.put(`/vendors/${vendorId}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send({
|
.send({
|
||||||
displayName: faker.commerce.productName(),
|
displayName: faker.commerce.productName(),
|
||||||
email: faker.internet.email(),
|
email: faker.internet.email(),
|
||||||
@@ -43,7 +43,7 @@ describe('Vendors (e2e)', () => {
|
|||||||
it('/vendors/:id (GET)', async () => {
|
it('/vendors/:id (GET)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/vendors')
|
.post('/vendors')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send({
|
.send({
|
||||||
displayName: faker.commerce.productName(),
|
displayName: faker.commerce.productName(),
|
||||||
email: faker.internet.email(),
|
email: faker.internet.email(),
|
||||||
@@ -54,14 +54,14 @@ describe('Vendors (e2e)', () => {
|
|||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.get(`/vendors/${vendorId}`)
|
.get(`/vendors/${vendorId}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('/vendors/:id (DELETE)', async () => {
|
it('/vendors/:id (DELETE)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/vendors')
|
.post('/vendors')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send({
|
.send({
|
||||||
displayName: faker.commerce.productName(),
|
displayName: faker.commerce.productName(),
|
||||||
});
|
});
|
||||||
@@ -69,7 +69,7 @@ describe('Vendors (e2e)', () => {
|
|||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.delete(`/vendors/${vendorId}`)
|
.delete(`/vendors/${vendorId}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import * as request from 'supertest';
|
import * as request from 'supertest';
|
||||||
import { faker } from '@faker-js/faker';
|
import { faker } from '@faker-js/faker';
|
||||||
import { app } from './init-app-test';
|
import { app, orgainzationId } from './init-app-test';
|
||||||
|
|
||||||
describe('Warehouses (e2e)', () => {
|
describe('Warehouses (e2e)', () => {
|
||||||
it('/warehouses (POST)', () => {
|
it('/warehouses (POST)', () => {
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.post('/warehouses')
|
.post('/warehouses')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send({
|
.send({
|
||||||
name: faker.commerce.productName(),
|
name: faker.commerce.productName(),
|
||||||
code: faker.string.alpha(4),
|
code: faker.string.alpha(4),
|
||||||
@@ -17,7 +17,7 @@ describe('Warehouses (e2e)', () => {
|
|||||||
it('/warehouses/:id (DELETE)', async () => {
|
it('/warehouses/:id (DELETE)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/warehouses')
|
.post('/warehouses')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send({
|
.send({
|
||||||
name: faker.commerce.productName(),
|
name: faker.commerce.productName(),
|
||||||
code: faker.string.alpha(4),
|
code: faker.string.alpha(4),
|
||||||
@@ -26,14 +26,14 @@ describe('Warehouses (e2e)', () => {
|
|||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.delete(`/warehouses/${warehouseId}`)
|
.delete(`/warehouses/${warehouseId}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('/warehouses/:id (PUT)', async () => {
|
it('/warehouses/:id (PUT)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/warehouses')
|
.post('/warehouses')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send({
|
.send({
|
||||||
name: faker.commerce.productName(),
|
name: faker.commerce.productName(),
|
||||||
code: faker.string.alpha(4),
|
code: faker.string.alpha(4),
|
||||||
@@ -42,14 +42,14 @@ describe('Warehouses (e2e)', () => {
|
|||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.put(`/warehouses/${warehouseId}`)
|
.put(`/warehouses/${warehouseId}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('/warehouses/:id (GET)', async () => {
|
it('/warehouses/:id (GET)', async () => {
|
||||||
const response = await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.post('/warehouses')
|
.post('/warehouses')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.send({
|
.send({
|
||||||
name: faker.commerce.productName(),
|
name: faker.commerce.productName(),
|
||||||
code: faker.string.alpha(4),
|
code: faker.string.alpha(4),
|
||||||
@@ -58,14 +58,14 @@ describe('Warehouses (e2e)', () => {
|
|||||||
|
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.get(`/warehouses/${warehouseId}`)
|
.get(`/warehouses/${warehouseId}`)
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('/warehouses (GET)', async () => {
|
it('/warehouses (GET)', async () => {
|
||||||
return request(app.getHttpServer())
|
return request(app.getHttpServer())
|
||||||
.get('/warehouses')
|
.get('/warehouses')
|
||||||
.set('organization-id', '4064541lv40nhca')
|
.set('organization-id', orgainzationId)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user