4075-ticket_boxing #1070
|
@ -2,7 +2,7 @@ const https = require('https');
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethod('getVideo', {
|
Self.remoteMethod('getVideo', {
|
||||||
description: 'Get packing video of ticketId',
|
description: 'Get packing video',
|
||||||
accessType: 'READ',
|
accessType: 'READ',
|
||||||
accepts: [
|
accepts: [
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,7 +21,7 @@ module.exports = Self => {
|
||||||
required: false,
|
required: false,
|
||||||
}
|
}
|
||||||
], returns: {
|
], returns: {
|
||||||
type: ['Object'],
|
type: ['object'],
|
||||||
root: true
|
root: true
|
||||||
},
|
},
|
||||||
http: {
|
http: {
|
||||||
|
@ -48,7 +48,7 @@ module.exports = Self => {
|
||||||
JOIN packingSite ps ON ps.hostFk = h.id
|
JOIN packingSite ps ON ps.hostFk = h.id
|
||||||
WHERE e.id = ?;`;
|
WHERE e.id = ?;`;
|
||||||
const [expedition] = await models.PackingSiteConfig.rawSql(query, [id]);
|
const [expedition] = await models.PackingSiteConfig.rawSql(query, [id]);
|
||||||
console.log(expedition);
|
|
||||||
if (!from && !expedition) return [];
|
if (!from && !expedition) return [];
|
||||||
let start = new Date(expedition.created);
|
let start = new Date(expedition.created);
|
||||||
let end = new Date(start.getTime() + (packingSiteConfig.avgBoxingTime * 1000));
|
let end = new Date(start.getTime() + (packingSiteConfig.avgBoxingTime * 1000));
|
||||||
|
|
|
@ -1,69 +0,0 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
|
||||||
|
|
||||||
xdescribe('sale canEdit()', () => {
|
|
||||||
it('should return true if the role is production regardless of the saleTrackings', async() => {
|
|
||||||
const tx = await models.Sale.beginTransaction({});
|
|
||||||
|
|
||||||
try {
|
|
||||||
const options = {transaction: tx};
|
|
||||||
|
|
||||||
const productionUserID = 49;
|
|
||||||
const ctx = {req: {accessToken: {userId: productionUserID}}};
|
|
||||||
|
|
||||||
const sales = [{id: 3}];
|
|
||||||
|
|
||||||
const result = await models.Sale.canEdit(ctx, sales, options);
|
|
||||||
|
|
||||||
expect(result).toEqual(true);
|
|
||||||
|
|
||||||
await tx.rollback();
|
|
||||||
} catch (e) {
|
|
||||||
await tx.rollback();
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return true if the role is not production and none of the sales has saleTracking', async() => {
|
|
||||||
const tx = await models.Sale.beginTransaction({});
|
|
||||||
|
|
||||||
try {
|
|
||||||
const options = {transaction: tx};
|
|
||||||
|
|
||||||
const salesPersonUserID = 18;
|
|
||||||
const ctx = {req: {accessToken: {userId: salesPersonUserID}}};
|
|
||||||
|
|
||||||
const sales = [{id: 10}];
|
|
||||||
|
|
||||||
const result = await models.Sale.canEdit(ctx, sales, options);
|
|
||||||
|
|
||||||
expect(result).toEqual(true);
|
|
||||||
|
|
||||||
await tx.rollback();
|
|
||||||
} catch (e) {
|
|
||||||
await tx.rollback();
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return false if any of the sales has a saleTracking record', async() => {
|
|
||||||
const tx = await models.Sale.beginTransaction({});
|
|
||||||
|
|
||||||
try {
|
|
||||||
const options = {transaction: tx};
|
|
||||||
|
|
||||||
const salesPersonUserID = 18;
|
|
||||||
const ctx = {req: {accessToken: {userId: salesPersonUserID}}};
|
|
||||||
|
|
||||||
const sales = [{id: 3}];
|
|
||||||
|
|
||||||
const result = await models.Sale.canEdit(ctx, sales, options);
|
|
||||||
|
|
||||||
expect(result).toEqual(false);
|
|
||||||
|
|
||||||
await tx.rollback();
|
|
||||||
} catch (e) {
|
|
||||||
await tx.rollback();
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
const axios = require('axios');
|
||||||
|
|
||||||
|
describe('boxing getVideoList()', () => {
|
||||||
|
it('should return data', async() => {
|
||||||
|
const tx = await models.PackingSiteConfig.beginTransaction({});
|
||||||
|
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
const params = {
|
||||||
|
id: 1,
|
||||||
|
from: 1,
|
||||||
|
to: 2
|
||||||
|
};
|
||||||
|
|
||||||
|
const response = {
|
||||||
|
data: {
|
||||||
|
pipe: () => {},
|
||||||
|
on: () => {},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
spyOn(axios, 'get').and.returnValue(new Promise(resolve => resolve(response)));
|
||||||
|
|
||||||
|
const result = await models.Sale.canEdit(params, options);
|
||||||
|
|
||||||
|
expect(result).toEqual([]);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue