2023-01-12 14:16:38 +00:00
|
|
|
const models = require('vn-loopback/server/server').models;
|
|
|
|
|
2023-01-13 12:33:59 +00:00
|
|
|
describe('docuware upload()', () => {
|
2023-01-12 14:16:38 +00:00
|
|
|
const userId = 9;
|
2023-06-13 09:37:35 +00:00
|
|
|
const ticketIds = [10];
|
2023-01-12 14:16:38 +00:00
|
|
|
const ctx = {
|
2023-06-13 09:37:35 +00:00
|
|
|
args: {ticketIds},
|
2023-01-12 14:16:38 +00:00
|
|
|
req: {
|
2023-01-13 12:33:59 +00:00
|
|
|
getLocale: () => {
|
|
|
|
return 'en';
|
|
|
|
},
|
2023-01-12 14:16:38 +00:00
|
|
|
accessToken: {userId: userId},
|
|
|
|
headers: {origin: 'http://localhost:5000'},
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const docuwareModel = models.Docuware;
|
2023-01-13 12:33:59 +00:00
|
|
|
const ticketModel = models.Ticket;
|
2023-01-12 14:16:38 +00:00
|
|
|
const fileCabinetName = 'deliveryNote';
|
|
|
|
|
|
|
|
beforeAll(() => {
|
2023-01-13 12:33:59 +00:00
|
|
|
spyOn(docuwareModel, 'getFileCabinet').and.returnValue(new Promise(resolve => resolve(Math.random())));
|
|
|
|
spyOn(docuwareModel, 'getDialog').and.returnValue(new Promise(resolve => resolve(Math.random())));
|
2023-01-12 14:16:38 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should try upload file', async() => {
|
2023-01-13 12:33:59 +00:00
|
|
|
spyOn(ticketModel, 'deliveryNotePdf').and.returnValue(new Promise(resolve => resolve({})));
|
2023-01-12 14:16:38 +00:00
|
|
|
|
|
|
|
let error;
|
|
|
|
try {
|
2023-06-13 09:37:35 +00:00
|
|
|
await models.Docuware.upload(ctx, ticketIds, fileCabinetName);
|
2023-01-12 14:16:38 +00:00
|
|
|
} catch (e) {
|
|
|
|
error = e.message;
|
|
|
|
}
|
|
|
|
|
2023-01-13 12:33:59 +00:00
|
|
|
expect(error).toEqual('Action not allowed on the test environment');
|
2023-01-12 14:16:38 +00:00
|
|
|
});
|
|
|
|
});
|