fix(spec): refs #6005 backupLabeler spec
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Pablo Natek 2023-11-28 08:11:42 +01:00
parent 5714aeedce
commit c929119797
6 changed files with 67 additions and 50 deletions

View File

@ -2,12 +2,11 @@ const models = require('vn-loopback/server/server').models;
describe('NotificationSubscription getList()', () => { describe('NotificationSubscription getList()', () => {
it('should return a list of available and active notifications of a user', async() => { it('should return a list of available and active notifications of a user', async() => {
const userId = 9; const {active, available} = await models.NotificationSubscription.getList(100);
const {active, available} = await models.NotificationSubscription.getList(userId);
const notifications = await models.Notification.find({}); const notifications = await models.Notification.find({});
const totalAvailable = notifications.length - active.length; const totalAvailable = notifications.length - active.length;
expect(active.length).toEqual(2); expect(active.length).toEqual(0);
expect(available.length).toEqual(totalAvailable); expect(available.length).toEqual(totalAvailable);
}); });
}); });

View File

@ -41,8 +41,7 @@ describe('loopback model NotificationSubscription', () => {
try { try {
const options = {transaction: tx, accessToken: {userId: 9}}; const options = {transaction: tx, accessToken: {userId: 9}};
const notificationSubscriptionId = 2; await models.NotificationSubscription.destroyAll({id: 2}, options);
await models.NotificationSubscription.destroyAll({id: notificationSubscriptionId}, options);
await tx.rollback(); await tx.rollback();
} catch (e) { } catch (e) {
@ -76,8 +75,7 @@ describe('loopback model NotificationSubscription', () => {
try { try {
const options = {transaction: tx, accessToken: {userId: 9}}; const options = {transaction: tx, accessToken: {userId: 9}};
const notificationSubscriptionId = 6; await models.NotificationSubscription.destroyAll({id: 6}, options);
await models.NotificationSubscription.destroyAll({id: notificationSubscriptionId}, options);
await tx.rollback(); await tx.rollback();
} catch (e) { } catch (e) {
@ -94,7 +92,7 @@ describe('loopback model NotificationSubscription', () => {
try { try {
const options = {transaction: tx, accessToken: {userId: 9}}; const options = {transaction: tx, accessToken: {userId: 9}};
await models.NotificationSubscription.create({notificationFk: 1, userFk: 5}, options); await models.NotificationSubscription.create({notificationFk: 12, userFk: 5}, options);
await tx.rollback(); await tx.rollback();
} catch (e) { } catch (e) {
@ -111,8 +109,7 @@ describe('loopback model NotificationSubscription', () => {
try { try {
const options = {transaction: tx, accessToken: {userId: 19}}; const options = {transaction: tx, accessToken: {userId: 19}};
const notificationSubscriptionId = 4; await models.NotificationSubscription.destroyAll({id: 4}, options);
await models.NotificationSubscription.destroyAll({id: notificationSubscriptionId}, options);
await tx.rollback(); await tx.rollback();
} catch (e) { } catch (e) {

View File

@ -9,15 +9,22 @@ ALTER TABLE `util`.`notificationAcl` DROP FOREIGN KEY `notificationAcl_ibfk_1`;
ALTER TABLE `util`.`notification` MODIFY COLUMN `id` int(11) auto_increment NOT NULL; ALTER TABLE `util`.`notification` MODIFY COLUMN `id` int(11) auto_increment NOT NULL;
ALTER TABLE `util`.`notificationSubscription` ADD CONSTRAINT `notificationSubscription_Fk` FOREIGN KEY (`notificationFk`) REFERENCES `util`.`notification`(`id`); ALTER TABLE `util`.`notificationSubscription` ADD CONSTRAINT `notificationSubscription_Fk` FOREIGN KEY (`notificationFk`) REFERENCES `util`.`notification`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `util`.`notificationQueue` ADD CONSTRAINT `notificationQueue_Fk` FOREIGN KEY (`notificationFk`) REFERENCES `util`.`notification`(`name`); ALTER TABLE `util`.`notificationQueue` ADD CONSTRAINT `notificationQueue_Fk` FOREIGN KEY (`notificationFk`) REFERENCES `util`.`notification`(`name`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `util`.`notificationAcl` ADD CONSTRAINT `notificationAcl_Fk` FOREIGN KEY (`notificationFk`) REFERENCES `util`.`notification`(`id`); ALTER TABLE `util`.`notificationAcl` ADD CONSTRAINT `notificationAcl_Fk` FOREIGN KEY (`notificationFk`) REFERENCES `util`.`notification`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
DELETE FROM `util`.`notification` DELETE FROM `util`.`notification`
WHERE `name` = 'not-main-printer-configured'; WHERE `name` = 'not-main-printer-configured';
INSERT INTO `util`.`notification` INSERT INTO `util`.`notification`
SET `id` = 15, SET `name` = 'backup-printer-selected',
`name` = 'backup-printer-selected',
`description` = 'The worker has selected the backup printer for their sector', `description` = 'The worker has selected the backup printer for their sector',
`delay` = 600000; `delay` = 600000;
INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`)
SELECT `n`.`id`, `r`.`id`
FROM `util`.`notification` `n`
JOIN `account`.`role` `r`
WHERE `n`.`name` = 'backup-printer-selected'
AND `r`.`name` = 'system'
LIMIT 1;

View File

@ -232,6 +232,32 @@ LOCK TABLES `agencyTermConfig` WRITE;
/*!40000 ALTER TABLE `agencyTermConfig` DISABLE KEYS */; /*!40000 ALTER TABLE `agencyTermConfig` DISABLE KEYS */;
INSERT INTO `agencyTermConfig` VALUES ('6240000000','4721000015',21.0000000000,'Adquisiciones intracomunitarias de servicios'); INSERT INTO `agencyTermConfig` VALUES ('6240000000','4721000015',21.0000000000,'Adquisiciones intracomunitarias de servicios');
/*!40000 ALTER TABLE `agencyTermConfig` ENABLE KEYS */; /*!40000 ALTER TABLE `agencyTermConfig` ENABLE KEYS */;
UNLOCK TABLES;
LOCK TABLES `notification` WRITE;
INSERT INTO `util`.`notification` (id, name, description)
VALUES(1, 'vehicle-event-expired', 'scheduled event of a vehicle'),
(2, 'invoice-electronic', 'A electronic invoice has been generated'),
(3, 'supplier-pay-method-update', 'A supplier pay method has been updated'),
(4, 'book-entries-imported-incorrectly', 'accounting entries exported incorrectly'),
(5, 'greuge-wrong', 'A wrong greuge has been created'),
(6, 'not-main-printer-configured', 'A printer distinct than main has been configured'),
(7, 'entry-update-comission', 'entry change comission'),
(8, 'modified-entry', 'An entry has been modified'),
(9, 'book-entry-deleted', 'accounting entries deleted'),
(10, 'modified-collection-volumetry', 'A collection volumetry has been modified');
UNLOCK TABLES;
LOCK TABLES `notificationAcl` WRITE;
INSERT INTO `util`.`notificationAcl` (notificationFk, roleFk)
VALUES(1, 57),
(3, 73),
(4, 5),
(6, 108),
(7, 30),
(7, 35),
(8, 15),
(9, 5);
UNLOCK TABLES; UNLOCK TABLES;
-- --

View File

@ -2780,49 +2780,35 @@ INSERT INTO `vn`.`packingSite` (`id`, `code`, `hostFk`, `monitorId`)
INSERT INTO `vn`.`packingSiteConfig` (`shinobiUrl`, `shinobiToken`, `shinobiGroupKey`, `avgBoxingTime`) INSERT INTO `vn`.`packingSiteConfig` (`shinobiUrl`, `shinobiToken`, `shinobiGroupKey`, `avgBoxingTime`)
VALUES VALUES
('', 'SHINNOBI_TOKEN', 'GROUP_TOKEN', 6000); ('', 'SHINNOBI_TOKEN', 'GROUP_TOKEN', 6000);
INSERT INTO `util`.`notificationConfig`
SET `cleanDays` = 90;
INSERT IGNORE INTO `util`.`notification` (`id`, `name`, `description`, `delay`)
VALUES
(1, 'print-email', 'notification fixture one', NULL),
(2, 'invoice-electronic', 'A electronic invoice has been generated', NULL),
(3, 'backup-printer-selected', 'A printer distinct than main has been configured', 600000),
(4, 'supplier-pay-method-update', 'A supplier pay method has been updated', NULL),
(5, 'modified-entry', 'An entry has been modified', NULL),
(6, 'book-entry-deleted', 'accounting entries deleted', NULL);
UPDATE `util`.`notification` INSERT INTO `util`.`notificationConfig`
SET `id` = 3 SET `cleanDays` = 90;
WHERE `name` = 'backup-printer-selected';
INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`) INSERT IGNORE INTO `util`.`notification` (`name`, `description`, `delay`)
VALUES VALUES ('print-email', 'notification fixture one', NULL);
(1, 9),
(1, 1),
(2, 1),
(3, 9),
(4, 1),
(5, 9),
(6, 9);
INSERT INTO `util`.`notificationQueue` (`id`, `notificationFk`, `params`, `authorFk`, `status`, `created`) INSERT INTO `util`.`notificationQueue` (`notificationFk`, `params`, `authorFk`, `status`, `created`)
VALUES VALUES ('print-email', '{"id": "1"}', 9, 'pending', util.VN_CURDATE()),
(1, 'print-email', '{"id": "1"}', 9, 'pending', util.VN_CURDATE()), ('print-email', '{"id": "2"}', null, 'pending', util.VN_CURDATE()),
(2, 'print-email', '{"id": "2"}', null, 'pending', util.VN_CURDATE()), ('print-email', null, null, 'pending', util.VN_CURDATE());
(3, 'print-email', null, null, 'pending', util.VN_CURDATE());
INSERT INTO `util`.`notificationSubscription` (`notificationFk`, `userFk`) INSERT INTO `util`.`notificationSubscription` (`notificationFk`, `userFk`)
VALUES VALUES (12, 1109),
(1, 1109), (12, 1110),
(1, 1110),
(2, 1110), (2, 1110),
(4, 1110), (4, 1110),
(2, 1109), (2, 1109),
(1, 9), (12, 9),
(1, 3), (12, 3);
(6, 9);
INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`)
VALUES (12, 9),
(12, 1),
(4, 1),
(2, 1),
(3, 9),
(5, 9),
(10,1);
INSERT INTO `vn`.`routeConfig` (`id`, `defaultWorkCenterFk`) INSERT INTO `vn`.`routeConfig` (`id`, `defaultWorkCenterFk`)
VALUES VALUES

View File

@ -16,6 +16,8 @@ TABLES=(
config config
version version
versionLog versionLog
notification
notificationAcl
) )
dump_tables ${TABLES[@]} dump_tables ${TABLES[@]}