6005-backupLabeler #2276

Merged
pablone merged 50 commits from 6005-backupLabeler into dev 2024-04-12 07:12:54 +00:00
2 changed files with 14 additions and 11 deletions
Showing only changes of commit 1e4f778ef9 - Show all commits

View File

@ -174,16 +174,20 @@ INSERT INTO `vn`.`warehouse`(`id`, `name`, `code`, `isComparative`, `isInventory
(13, 'Inventory', 'inv', 1, 1, 1, 0, 0, 0, 2, 1, 0), (13, 'Inventory', 'inv', 1, 1, 1, 0, 0, 0, 2, 1, 0),
(60, 'Algemesi', NULL, 1, 1, 1, 0, 0, 0, 2, 1, 0); (60, 'Algemesi', NULL, 1, 1, 1, 0, 0, 0, 2, 1, 0);
INSERT INTO `vn`.`sector`(`id`, `description`, `warehouseFk`, `isPreviousPreparedByPacking`, `code`, `backupPrinterFk`)
VALUES
(1, 'First sector', 1, 1, 'FIRST', NULL),
(2, 'Second sector', 2, 0, 'SECOND', NULL);
INSERT INTO `vn`.`printer` (`id`, `name`, `path`, `isLabeler`, `sectorFk`, `ipAddress`) INSERT INTO `vn`.`printer` (`id`, `name`, `path`, `isLabeler`, `sectorFk`, `ipAddress`)
VALUES VALUES
(1, 'printer1', 'path1', 0, 1 , NULL), (1, 'printer1', 'path1', 0, 1 , NULL),
(2, 'printer2', 'path2', 1, 1 , NULL), (2, 'printer2', 'path2', 1, 1 , NULL),
(4, 'printer4', 'path4', 0, NULL, '10.1.10.4'); (4, 'printer4', 'path4', 0, NULL, '10.1.10.4');
INSERT INTO `vn`.`sector`(`id`, `description`, `warehouseFk`, `isPreviousPreparedByPacking`, `code`, `backupPrinterFk`) UPDATE `vn`.`sector`
VALUES SET `backupPrinterFk` = 1
(1, 'First sector', 1, 1, 'FIRST', 1), WHERE `id` = 1;
(2, 'Second sector', 2, 0, 'SECOND', NULL);
INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`,`bossFk`, `phone`) INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`,`bossFk`, `phone`)
VALUES VALUES
@ -2771,7 +2775,7 @@ INSERT INTO `vn`.`packingSiteConfig` (`shinobiUrl`, `shinobiToken`, `shinobiGrou
VALUES VALUES
('', 'SHINNOBI_TOKEN', 'GROUP_TOKEN', 6000); ('', 'SHINNOBI_TOKEN', 'GROUP_TOKEN', 6000);
INSERT INTO `util`.`notificationConfig` INSERT INTO `util`.`notificationConfig`
SET `cleanDays` = 90; SET `cleanDays` = 90;
INSERT INTO `util`.`notification` (`id`, `name`, `description`) INSERT INTO `util`.`notification` (`id`, `name`, `description`)
VALUES VALUES

View File

@ -3,7 +3,6 @@ const models = require('vn-loopback/server/server').models;
describe('Operator', () => { describe('Operator', () => {
const authorFk = 9; const authorFk = 9;
const sectorId = 1; const sectorId = 1;
const mainPrinter = 1;
const notificationName = 'backup-printer-selected'; const notificationName = 'backup-printer-selected';
const operator = { const operator = {
workerFk: 1, workerFk: 1,
@ -23,17 +22,17 @@ describe('Operator', () => {
}, options); }, options);
} }
it('should create notification when configured a not main printer in the sector', async() => { it('should create notification when configured a backup printer in the sector', async() => {
const tx = await models.Operator.beginTransaction({}); const tx = await models.Operator.beginTransaction({});
try { try {
const options = {transaction: tx, accessToken: {userId: authorFk}}; const options = {transaction: tx, accessToken: {userId: authorFk}};
const notificationQueue = await createOperator(2, options); const notificationQueue = await createOperator(1, options);
const params = JSON.parse(notificationQueue.params); const params = JSON.parse(notificationQueue.params);
expect(notificationQueue.notificationFk).toEqual(notificationName); expect(notificationQueue.notificationFk).toEqual(notificationName);
expect(notificationQueue.authorFk).toEqual(authorFk); expect(notificationQueue.authorFk).toEqual(authorFk);
expect(params.labelerId).toEqual(2); expect(params.labelerId).toEqual(1);
expect(params.sectorId).toEqual(1); expect(params.sectorId).toEqual(1);
expect(params.workerId).toEqual(9); expect(params.workerId).toEqual(9);
@ -44,12 +43,12 @@ describe('Operator', () => {
} }
}); });
it('should not create notification when configured the main printer in the sector', async() => { it('should not create notification when configured a non backup printer in the sector', async() => {
const tx = await models.Operator.beginTransaction({}); const tx = await models.Operator.beginTransaction({});
try { try {
const options = {transaction: tx, accessToken: {userId: authorFk}}; const options = {transaction: tx, accessToken: {userId: authorFk}};
const notificationQueue = await createOperator(mainPrinter, options); const notificationQueue = await createOperator(2, options);
expect(notificationQueue).toEqual(null); expect(notificationQueue).toEqual(null);