Files
bigcapital/packages/server-nest/test/pdf-templates.e2e-spec.ts
2025-01-11 18:03:59 +02:00

69 lines
2.0 KiB
TypeScript

import * as request from 'supertest';
import { faker } from '@faker-js/faker';
import { app, orgainzationId } from './init-app-test';
describe('Pdf Templates (e2e)', () => {
it('/pdf-templates (POST)', () => {
return request(app.getHttpServer())
.post('/pdf-templates')
.set('organization-id', orgainzationId)
.send({
template_name: 'Standard',
resource: 'SaleInvoice',
attributes: {},
})
.expect(201);
});
it('/pdf-templates (DELETE)', async () => {
const response = await request(app.getHttpServer())
.post('/pdf-templates')
.set('organization-id', orgainzationId)
.send({
template_name: 'Standard',
resource: 'SaleInvoice',
attributes: {},
});
const pdfTemplateId = response.body.id;
return request(app.getHttpServer())
.delete(`/pdf-templates/${pdfTemplateId}`)
.set('organization-id', orgainzationId)
.expect(200);
});
it('/pdf-templates/:id (GET)', async () => {
const response = await request(app.getHttpServer())
.post('/pdf-templates')
.set('organization-id', orgainzationId)
.send({
template_name: 'Standard',
resource: 'SaleInvoice',
attributes: {},
});
const pdfTemplateId = response.body.id;
return request(app.getHttpServer())
.get(`/pdf-templates/${pdfTemplateId}`)
.set('organization-id', orgainzationId)
.expect(200);
});
it('/pdf-templates/:id/assign-default (POST)', async () => {
const response = await request(app.getHttpServer())
.post('/pdf-templates')
.set('organization-id', orgainzationId)
.send({
template_name: 'Standard',
resource: 'SaleInvoice',
attributes: {},
});
const pdfTemplateId = response.body.id;
return request(app.getHttpServer())
.put(`/pdf-templates/${pdfTemplateId}/assign-default`)
.set('organization-id', orgainzationId)
.expect(200);
});
});