feat: refs #6276 test itemShelvingMake_multi
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Jorge Penadés 2024-01-18 13:28:22 +01:00
parent 6f35c62cd5
commit c8bfb35cf6
6 changed files with 62 additions and 6 deletions

View File

@ -6,7 +6,7 @@ module.exports = Self => {
accepts: [ accepts: [
{ {
arg: 'code', arg: 'code',
type: 'number', type: 'string',
required: true required: true
}, },
{ {

View File

@ -1,7 +1,7 @@
const {models} = require('vn-loopback/server/server'); const {models} = require('vn-loopback/server/server');
const LoopBackContext = require('loopback-context'); const LoopBackContext = require('loopback-context');
fdescribe('collection addItem()', () => { describe('collection addItem()', () => {
const quantity = 3; const quantity = 3;
const ticketFk = 24; const ticketFk = 24;
const warehouseFk = 1; const warehouseFk = 1;

View File

@ -205,5 +205,6 @@
"It was not able to remove the next expeditions:": "It was not able to remove the next expeditions: {{expeditions}}", "It was not able to remove the next expeditions:": "It was not able to remove the next expeditions: {{expeditions}}",
"Incorrect pin": "Incorrect pin.", "Incorrect pin": "Incorrect pin.",
"This machine is already in use.": "This machine is already in use.", "This machine is already in use.": "This machine is already in use.",
"This pallet does not exist": "This pallet does not exist" "This pallet does not exist": "This pallet does not exist",
"We do not have availability for the selected item": "We do not have availability for the selected item"
} }

View File

@ -341,5 +341,6 @@
"No hay tickets para sacar": "No hay tickets para sacar", "No hay tickets para sacar": "No hay tickets para sacar",
"There is no zone for these parameters 999999": "There is no zone for these parameters 999999", "There is no zone for these parameters 999999": "There is no zone for these parameters 999999",
"This machine is already in use.": "Esta máquina ya está en uso.", "This machine is already in use.": "Esta máquina ya está en uso.",
"This pallet does not exist": "Este palet no existe" "This pallet does not exist": "Este palet no existe",
"We do not have availability for the selected item": "No tenemos disponible el item seleccionado",
} }

View File

@ -47,10 +47,10 @@ module.exports = Self => {
}, 0); }, 0);
discardItems.push(item); discardItems.push(item);
let [result] = await Self.rawSql('SELECT vn.itemPacking(?, ?)', [item, warehouseFk]); const [result] = await Self.rawSql('SELECT vn.itemPacking(?, ?) itemPacking', [item, warehouseFk]);
let packing; let packing;
if (result) packing = Object.values(result)[0]; if (result) packing = result.itemPacking;
if (!packing) packing = 1; if (!packing) packing = 1;
quantity = quantity * packing; quantity = quantity * packing;

View File

@ -0,0 +1,54 @@
const {models} = require('vn-loopback/server/server');
describe('item makeMulti()', () => {
const warehouseFk = 1;
beforeAll(async() => {
ctx = {
accessToken: {userId: 9},
req: {
headers: {origin: 'http://localhost'},
}
};
});
it('should add two new records', async() => {
const shelvingFk = 'ZPP';
const items = [1, 1, 1, 2];
const tx = await models.ItemShelving.beginTransaction({});
const options = {transaction: tx};
try {
await models.ItemShelving.makeMulti(shelvingFk, items, warehouseFk, options);
const itemShelvings = await models.ItemShelving.find({where: {shelvingFk}}, options);
expect(itemShelvings.length).toEqual(2);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it('should update the visible items', async() => {
const shelvingFk = 'GVC';
const items = [2, 2];
const tx = await models.ItemShelving.beginTransaction({});
const options = {transaction: tx};
try {
const {visible: itemsBefore} = await models.ItemShelving.findOne({
where: {shelvingFk, itemFk: items[0]}
}, options);
await models.ItemShelving.makeMulti(shelvingFk, items, warehouseFk, options);
const {visible: itemsAfter} = await models.ItemShelving.findOne({
where: {shelvingFk, itemFk: items[0]}
}, options);
expect(itemsAfter).toEqual(itemsBefore + 2);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});