7152-devToTest_2414 #2228

Merged
alexm merged 636 commits from 7152-devToTest_2414 into test 2024-03-28 08:26:34 +00:00
4 changed files with 53 additions and 3 deletions
Showing only changes of commit 799237e14c - Show all commits

View File

@ -212,5 +212,7 @@
"This worker does not exist": "This worker does not exist", "This worker does not exist": "This worker does not exist",
"this state does not exist": "This state does not exist", "this state does not exist": "This state does not exist",
"The line could not be marked": "The line could not be marked", "The line could not be marked": "The line could not be marked",
"The sale can not be tracked": "The sale can not be tracked" "The sale can not be tracked": "The sale can not be tracked",
"Shelving not valid": "Shelving not valid"
} }

View File

@ -350,5 +350,6 @@
"The line could not be marked": "No se ha podido marcar la línea", "The line could not be marked": "No se ha podido marcar la línea",
"No se ha podido marcar la línea": "No se ha podido marcar la línea", "No se ha podido marcar la línea": "No se ha podido marcar la línea",
"The sale can not be tracked": "La línea no puede ser rastreada", "The sale can not be tracked": "La línea no puede ser rastreada",
"La línea no puede ser rastreada": "La línea no puede ser rastreada" "Shelving not valid": "Carro no válido",
"Carro no válido": "Carro no válido"
} }

View File

@ -16,6 +16,7 @@ module.exports = Self => {
}); });
Self.addLog = async(ctx, code, options) => { Self.addLog = async(ctx, code, options) => {
const userId = ctx.req.accessToken.userId; const userId = ctx.req.accessToken.userId;
const $t = ctx.req.__;
const models = Self.app.models; const models = Self.app.models;
const myOptions = {}; const myOptions = {};
let tx; let tx;
@ -35,7 +36,7 @@ module.exports = Self => {
} }
}, myOptions); }, myOptions);
if (!shelving) throw new UserError('Shelving not valid'); if (!shelving) throw new UserError($t('Shelving not valid'));
await models.ShelvingLog.create({ await models.ShelvingLog.create({
changedModel: 'Shelving', changedModel: 'Shelving',

View File

@ -0,0 +1,46 @@
const {models} = require('vn-loopback/server/server');
describe('shelving addLog()', () => {
beforeAll(async() => {
ctx = {
req: {
headers: {origin: 'http://localhost'},
accessToken: {userId: 66},
__: value => value
}
};
});
it('should add a log', async() => {
const tx = await models.SaleTracking.beginTransaction({});
const options = {transaction: tx};
const code = 'AA6';
try {
const shelvingLogsBefore = await models.ShelvingLog.find(null, options);
await models.Shelving.addLog(ctx, code, options);
const shelvingLogsAfter = await models.ShelvingLog.find(null, options);
expect(shelvingLogsAfter.length).toEqual(shelvingLogsBefore.length + 1);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it('should throw an error when the code does not exist', async() => {
const tx = await models.SaleTracking.beginTransaction({});
const options = {transaction: tx};
const code = 'DXI345';
try {
await models.Shelving.addLog(ctx, code, options);
await tx.rollback();
} catch (e) {
expect(e.message).toEqual('Shelving not valid');
await tx.rollback();
}
});
});