2024-12-05 11:39:20 +00:00
|
|
|
|
|
|
|
const {models} = require('vn-loopback/server/server');
|
|
|
|
|
|
|
|
describe('itemShelving getItemsByReviewOrder()', () => {
|
2024-12-05 11:42:17 +00:00
|
|
|
it('should return empty because hoursToReview = 0', async() => {
|
2024-12-05 11:39:20 +00:00
|
|
|
const shelving = 'NBB';
|
|
|
|
const parking = '700-01';
|
|
|
|
|
|
|
|
const tx = await models.Sector.beginTransaction({});
|
|
|
|
const myOptions = {transaction: tx};
|
|
|
|
|
|
|
|
try {
|
|
|
|
const config = await models.ProductionConfig.findOne();
|
|
|
|
await config.updateAttributes({
|
|
|
|
itemOrderReviewHours: null,
|
|
|
|
});
|
|
|
|
|
|
|
|
const result = await models.ItemShelving.getItemsByReviewOrder(shelving, parking, myOptions);
|
|
|
|
|
|
|
|
expect(result.length).toEqual(0);
|
|
|
|
await tx.rollback();
|
|
|
|
} catch (e) {
|
|
|
|
await tx.rollback();
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2024-12-05 11:42:17 +00:00
|
|
|
it('should return an item because you are trying parking a shelving and there is an older item', async() => {
|
2024-12-05 11:39:20 +00:00
|
|
|
const shelving = 'NBB';
|
|
|
|
const parking = 'K-26-2';
|
|
|
|
const itemFk = 1000000;
|
|
|
|
|
|
|
|
const tx = await models.Sector.beginTransaction({});
|
|
|
|
const myOptions = {transaction: tx};
|
|
|
|
|
|
|
|
try {
|
|
|
|
const config = await models.ProductionConfig.findOne();
|
|
|
|
await config.updateAttributes({
|
|
|
|
itemOrderReviewHours: 24,
|
|
|
|
});
|
|
|
|
|
|
|
|
const result = await models.ItemShelving.getItemsByReviewOrder(shelving, parking, itemFk, myOptions);
|
|
|
|
|
|
|
|
expect(result.length).toEqual(1);
|
|
|
|
await tx.rollback();
|
|
|
|
} catch (e) {
|
|
|
|
await tx.rollback();
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2024-12-05 11:42:17 +00:00
|
|
|
it('should return an item because you are trying parking a shelving and there is an newer item', async() => {
|
2024-12-05 11:39:20 +00:00
|
|
|
const shelving = 'NBB';
|
|
|
|
const parking = 'K-26-2';
|
|
|
|
const itemFk = 1000000;
|
|
|
|
|
|
|
|
const tx = await models.Sector.beginTransaction({});
|
|
|
|
const myOptions = {transaction: tx};
|
|
|
|
|
|
|
|
try {
|
|
|
|
const config = await models.ProductionConfig.findOne();
|
|
|
|
await config.updateAttributes({
|
|
|
|
itemOrderReviewHours: 24,
|
|
|
|
});
|
|
|
|
|
|
|
|
const result = await models.ItemShelving.getItemsByReviewOrder(shelving, parking, itemFk, myOptions);
|
|
|
|
|
|
|
|
expect(result.length).toEqual(1);
|
|
|
|
await tx.rollback();
|
|
|
|
} catch (e) {
|
|
|
|
await tx.rollback();
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2024-12-05 11:42:17 +00:00
|
|
|
it('should return a item list because you are trying parking a shelving and there is an newer item', async() => {
|
2024-12-05 11:39:20 +00:00
|
|
|
const shelving = 'NCC';
|
|
|
|
const parking = 'K-26-2';
|
|
|
|
const itemFk = 1000000;
|
|
|
|
|
|
|
|
const tx = await models.Sector.beginTransaction({});
|
|
|
|
const myOptions = {transaction: tx};
|
|
|
|
|
|
|
|
try {
|
|
|
|
const config = await models.ProductionConfig.findOne();
|
|
|
|
await config.updateAttributes({
|
|
|
|
itemOrderReviewHours: 24,
|
|
|
|
});
|
|
|
|
|
|
|
|
const result = await models.ItemShelving.getItemsByReviewOrder(shelving, parking, itemFk, myOptions);
|
|
|
|
|
|
|
|
expect(result.length).toEqual(2);
|
|
|
|
await tx.rollback();
|
|
|
|
} catch (e) {
|
|
|
|
await tx.rollback();
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2024-12-05 11:42:17 +00:00
|
|
|
it('should return empty list because all order is correct', async() => {
|
2024-12-05 11:39:20 +00:00
|
|
|
const shelving = 'NCC';
|
|
|
|
const parking = 'A-01-1';
|
|
|
|
const itemFk = 1000000;
|
|
|
|
|
|
|
|
const tx = await models.Sector.beginTransaction({});
|
|
|
|
const myOptions = {transaction: tx};
|
|
|
|
|
|
|
|
try {
|
|
|
|
const config = await models.ProductionConfig.findOne();
|
|
|
|
await config.updateAttributes({
|
|
|
|
itemOrderReviewHours: 24,
|
|
|
|
});
|
|
|
|
|
|
|
|
const result = await models.ItemShelving.getItemsByReviewOrder(shelving, parking, itemFk, myOptions);
|
|
|
|
|
|
|
|
expect(result.length).toEqual(0);
|
|
|
|
await tx.rollback();
|
|
|
|
} catch (e) {
|
|
|
|
await tx.rollback();
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|