This commit is contained in:
parent
5714aeedce
commit
c929119797
|
@ -2,12 +2,11 @@ const models = require('vn-loopback/server/server').models;
|
|||
|
||||
describe('NotificationSubscription getList()', () => {
|
||||
it('should return a list of available and active notifications of a user', async() => {
|
||||
const userId = 9;
|
||||
const {active, available} = await models.NotificationSubscription.getList(userId);
|
||||
const {active, available} = await models.NotificationSubscription.getList(100);
|
||||
const notifications = await models.Notification.find({});
|
||||
const totalAvailable = notifications.length - active.length;
|
||||
|
||||
expect(active.length).toEqual(2);
|
||||
expect(active.length).toEqual(0);
|
||||
expect(available.length).toEqual(totalAvailable);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -41,8 +41,7 @@ describe('loopback model NotificationSubscription', () => {
|
|||
|
||||
try {
|
||||
const options = {transaction: tx, accessToken: {userId: 9}};
|
||||
const notificationSubscriptionId = 2;
|
||||
await models.NotificationSubscription.destroyAll({id: notificationSubscriptionId}, options);
|
||||
await models.NotificationSubscription.destroyAll({id: 2}, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
|
@ -76,8 +75,7 @@ describe('loopback model NotificationSubscription', () => {
|
|||
|
||||
try {
|
||||
const options = {transaction: tx, accessToken: {userId: 9}};
|
||||
const notificationSubscriptionId = 6;
|
||||
await models.NotificationSubscription.destroyAll({id: notificationSubscriptionId}, options);
|
||||
await models.NotificationSubscription.destroyAll({id: 6}, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
|
@ -94,7 +92,7 @@ describe('loopback model NotificationSubscription', () => {
|
|||
|
||||
try {
|
||||
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();
|
||||
} catch (e) {
|
||||
|
@ -111,8 +109,7 @@ describe('loopback model NotificationSubscription', () => {
|
|||
|
||||
try {
|
||||
const options = {transaction: tx, accessToken: {userId: 19}};
|
||||
const notificationSubscriptionId = 4;
|
||||
await models.NotificationSubscription.destroyAll({id: notificationSubscriptionId}, options);
|
||||
await models.NotificationSubscription.destroyAll({id: 4}, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
|
|
|
@ -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`.`notificationSubscription` ADD CONSTRAINT `notificationSubscription_Fk` FOREIGN KEY (`notificationFk`) REFERENCES `util`.`notification`(`id`);
|
||||
ALTER TABLE `util`.`notificationQueue` ADD CONSTRAINT `notificationQueue_Fk` FOREIGN KEY (`notificationFk`) REFERENCES `util`.`notification`(`name`);
|
||||
ALTER TABLE `util`.`notificationAcl` ADD CONSTRAINT `notificationAcl_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`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
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`
|
||||
WHERE `name` = 'not-main-printer-configured';
|
||||
|
||||
INSERT INTO `util`.`notification`
|
||||
SET `id` = 15,
|
||||
`name` = 'backup-printer-selected',
|
||||
SET `name` = 'backup-printer-selected',
|
||||
`description` = 'The worker has selected the backup printer for their sector',
|
||||
`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;
|
||||
|
|
|
@ -234,6 +234,32 @@ INSERT INTO `agencyTermConfig` VALUES ('6240000000','4721000015',21.0000000000,'
|
|||
/*!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;
|
||||
|
||||
--
|
||||
-- Dumping data for table `alertLevel`
|
||||
--
|
||||
|
|
|
@ -2780,49 +2780,35 @@ INSERT INTO `vn`.`packingSite` (`id`, `code`, `hostFk`, `monitorId`)
|
|||
INSERT INTO `vn`.`packingSiteConfig` (`shinobiUrl`, `shinobiToken`, `shinobiGroupKey`, `avgBoxingTime`)
|
||||
VALUES
|
||||
('', '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);
|
||||
INSERT IGNORE INTO `util`.`notification` (`name`, `description`, `delay`)
|
||||
VALUES ('print-email', 'notification fixture one', NULL);
|
||||
|
||||
UPDATE `util`.`notification`
|
||||
SET `id` = 3
|
||||
WHERE `name` = 'backup-printer-selected';
|
||||
|
||||
INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`)
|
||||
VALUES
|
||||
(1, 9),
|
||||
(1, 1),
|
||||
(2, 1),
|
||||
(3, 9),
|
||||
(4, 1),
|
||||
(5, 9),
|
||||
(6, 9);
|
||||
|
||||
INSERT INTO `util`.`notificationQueue` (`id`, `notificationFk`, `params`, `authorFk`, `status`, `created`)
|
||||
VALUES
|
||||
(1, 'print-email', '{"id": "1"}', 9, 'pending', util.VN_CURDATE()),
|
||||
(2, 'print-email', '{"id": "2"}', null, 'pending', util.VN_CURDATE()),
|
||||
(3, 'print-email', null, null, 'pending', util.VN_CURDATE());
|
||||
INSERT INTO `util`.`notificationQueue` (`notificationFk`, `params`, `authorFk`, `status`, `created`)
|
||||
VALUES ('print-email', '{"id": "1"}', 9, 'pending', util.VN_CURDATE()),
|
||||
('print-email', '{"id": "2"}', null, 'pending', util.VN_CURDATE()),
|
||||
('print-email', null, null, 'pending', util.VN_CURDATE());
|
||||
|
||||
INSERT INTO `util`.`notificationSubscription` (`notificationFk`, `userFk`)
|
||||
VALUES
|
||||
(1, 1109),
|
||||
(1, 1110),
|
||||
VALUES (12, 1109),
|
||||
(12, 1110),
|
||||
(2, 1110),
|
||||
(4, 1110),
|
||||
(2, 1109),
|
||||
(1, 9),
|
||||
(1, 3),
|
||||
(6, 9);
|
||||
(12, 9),
|
||||
(12, 3);
|
||||
|
||||
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`)
|
||||
VALUES
|
||||
|
|
|
@ -16,6 +16,8 @@ TABLES=(
|
|||
config
|
||||
version
|
||||
versionLog
|
||||
notification
|
||||
notificationAcl
|
||||
)
|
||||
dump_tables ${TABLES[@]}
|
||||
|
||||
|
|
Loading…
Reference in New Issue