refs #5094 test(docuware): adapt tests
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Alex Moreno 2023-06-13 11:37:35 +02:00
parent a07ca62476
commit 92953b9aa8
5 changed files with 24 additions and 20 deletions

View File

@ -20,8 +20,8 @@ module.exports = Self => {
const options = await Self.getOptions(); const options = await Self.getOptions();
// if (!process.env.NODE_ENV) if (!process.env.NODE_ENV)
// return Math.round(); return Math.round();
const response = await axios.get(`${options.url}/FileCabinets/${fileCabinetId}/dialogs`, options.headers); const response = await axios.get(`${options.url}/FileCabinets/${fileCabinetId}/dialogs`, options.headers);
const dialogs = response.data.Dialog; const dialogs = response.data.Dialog;
@ -44,8 +44,8 @@ module.exports = Self => {
} }
}); });
// if (!process.env.NODE_ENV) if (!process.env.NODE_ENV)
// return Math.round(); return Math.round();
const fileCabinetResponse = await axios.get(`${options.url}/FileCabinets`, options.headers); const fileCabinetResponse = await axios.get(`${options.url}/FileCabinets`, options.headers);
const fileCabinets = fileCabinetResponse.data.FileCabinet; const fileCabinets = fileCabinetResponse.data.FileCabinet;

View File

@ -2,8 +2,9 @@ const models = require('vn-loopback/server/server').models;
describe('docuware upload()', () => { describe('docuware upload()', () => {
const userId = 9; const userId = 9;
const ticketId = 10; const ticketIds = [10];
const ctx = { const ctx = {
args: {ticketIds},
req: { req: {
getLocale: () => { getLocale: () => {
return 'en'; return 'en';
@ -27,7 +28,7 @@ describe('docuware upload()', () => {
let error; let error;
try { try {
await models.Docuware.upload(ctx, ticketId, fileCabinetName); await models.Docuware.upload(ctx, ticketIds, fileCabinetName);
} catch (e) { } catch (e) {
error = e.message; error = e.message;
} }

View File

@ -19,7 +19,10 @@ module.exports = Self => {
required: true required: true
} }
], ],
returns: [], returns: {
type: 'object',
root: true
},
http: { http: {
path: `/upload`, path: `/upload`,
verb: 'POST' verb: 'POST'
@ -106,8 +109,8 @@ module.exports = Self => {
] ]
}; };
// if (process.env.NODE_ENV != 'production') if (process.env.NODE_ENV != 'production')
// throw new UserError('Action not allowed on the test environment'); throw new UserError('Action not allowed on the test environment');
// delete old // delete old
const docuwareFile = await models.Docuware.checkFile(ctx, id, fileCabinet, false); const docuwareFile = await models.Docuware.checkFile(ctx, id, fileCabinet, false);

View File

@ -308,7 +308,7 @@ describe('Ticket Component vnTicketDescriptorMenu', () => {
controller.$.balanceCreate = {show: () => {}}; controller.$.balanceCreate = {show: () => {}};
jest.spyOn(controller.vnApp, 'showSuccess'); jest.spyOn(controller.vnApp, 'showSuccess');
$httpBackend.whenPOST(`Docuwares/${ticket.id}/upload`).respond(true); $httpBackend.whenPOST(`Docuwares/upload`).respond(true);
controller.uploadDocuware(true); controller.uploadDocuware(true);
$httpBackend.flush(); $httpBackend.flush();

View File

@ -12,12 +12,14 @@ describe('Component vnTicketIndex', () => {
id: 2, id: 2,
clientFk: 1, clientFk: 1,
checked: true, checked: true,
totalWithVat: 20.5 totalWithVat: 20.5,
stateFk: 1
}, { }, {
id: 3, id: 3,
clientFk: 1, clientFk: 1,
checked: true, checked: true,
totalWithVat: 30 totalWithVat: 30,
stateFk: 1
}]; }];
beforeEach(ngModule('ticket')); beforeEach(ngModule('ticket'));
@ -86,18 +88,16 @@ describe('Component vnTicketIndex', () => {
}); });
}); });
describe('setDelivered()/openDeliveryNotes()', () => { describe('sendDocuware()', () => {
it('should perform a post to setDelivered and open tabs with the delivery notes', () => { it('should perform a post to sendDocuware and change tickets state', () => {
controller.$.model = {data: tickets, refresh: () => {}}; controller.$.model = {data: tickets, refresh: () => {}};
const newState = {id: 2};
$window.open = jest.fn(); $httpBackend.expect('POST', 'Docuwares/upload').respond({id: newState.id});
controller.sendDocuware();
$httpBackend.expect('POST', 'TicketTrackings/setDelivered').respond('ok');
controller.setDelivered();
$httpBackend.flush(); $httpBackend.flush();
expect($window.open).toHaveBeenCalledWith(`api/Tickets/${tickets[1].id}/delivery-note-pdf`); expect(controller.$.model.data[1].stateFk).toEqual(newState.id);
expect($window.open).toHaveBeenCalledWith(`api/Tickets/${tickets[2].id}/delivery-note-pdf`);
}); });
}); });