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

View File

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

View File

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

View File

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

View File

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