test and fixtures
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
b5a73ec3a2
commit
ac4d4e6db1
|
@ -1640,51 +1640,59 @@ INSERT INTO `hedera`.`orderRowComponent`(`rowFk`, `componentFk`, `price`)
|
|||
|
||||
INSERT INTO `hedera`.`visit`(`id`, `firstAgentFk`)
|
||||
VALUES
|
||||
(1, NULL),
|
||||
(2, NULL),
|
||||
(3, NULL),
|
||||
(4, NULL),
|
||||
(5, NULL),
|
||||
(6, NULL),
|
||||
(7, NULL),
|
||||
(8, NULL),
|
||||
(9, NULL);
|
||||
(1, NULL),
|
||||
(2, NULL),
|
||||
(3, NULL),
|
||||
(4, NULL),
|
||||
(5, NULL),
|
||||
(6, NULL),
|
||||
(7, NULL),
|
||||
(8, NULL),
|
||||
(9, NULL),
|
||||
(10, NULL),
|
||||
(11, NULL);
|
||||
|
||||
INSERT INTO `hedera`.`visitAgent`(`id`, `visitFk`)
|
||||
VALUES
|
||||
(1, 1),
|
||||
(2, 2),
|
||||
(3, 3),
|
||||
(4, 4),
|
||||
(5, 5),
|
||||
(6, 6),
|
||||
(7, 7),
|
||||
(8, 8),
|
||||
(9, 9);
|
||||
(1, 1),
|
||||
(2, 2),
|
||||
(3, 3),
|
||||
(4, 4),
|
||||
(5, 5),
|
||||
(6, 6),
|
||||
(7, 7),
|
||||
(8, 8),
|
||||
(9, 9),
|
||||
(10, 10),
|
||||
(11, 11);
|
||||
|
||||
INSERT INTO `hedera`.`visitAccess`(`id`, `agentFk`, `stamp`)
|
||||
VALUES
|
||||
(1, 1, CURDATE()),
|
||||
(2, 2, CURDATE()),
|
||||
(3, 3, CURDATE()),
|
||||
(4, 4, CURDATE()),
|
||||
(5, 5, CURDATE()),
|
||||
(6, 6, CURDATE()),
|
||||
(7, 7, CURDATE()),
|
||||
(8, 8, CURDATE()),
|
||||
(9, 9, CURDATE());
|
||||
(1, 1, CURDATE()),
|
||||
(2, 2, CURDATE()),
|
||||
(3, 3, CURDATE()),
|
||||
(4, 4, CURDATE()),
|
||||
(5, 5, CURDATE()),
|
||||
(6, 6, CURDATE()),
|
||||
(7, 7, CURDATE()),
|
||||
(8, 8, CURDATE()),
|
||||
(9, 9, CURDATE()),
|
||||
(10, 10, CURDATE()),
|
||||
(11, 11, CURDATE());
|
||||
|
||||
INSERT INTO `hedera`.`visitUser`(`id`, `accessFk`, `userFk`, `stamp`)
|
||||
VALUES
|
||||
(1, 1, 1101, CURDATE()),
|
||||
(2, 2, 1101, CURDATE()),
|
||||
(3, 3, 1101, CURDATE()),
|
||||
(4, 4, 1102, CURDATE()),
|
||||
(5, 5, 1102, CURDATE()),
|
||||
(6, 6, 1102, CURDATE()),
|
||||
(7, 7, 1103, CURDATE()),
|
||||
(8, 8, 1103, CURDATE()),
|
||||
(9, 9, 1103, CURDATE());
|
||||
(1, 1, 1101, CURDATE()),
|
||||
(2, 2, 1101, CURDATE()),
|
||||
(3, 3, 1101, CURDATE()),
|
||||
(4, 4, 1102, CURDATE()),
|
||||
(5, 5, 1102, CURDATE()),
|
||||
(6, 6, 1102, CURDATE()),
|
||||
(7, 7, 1103, CURDATE()),
|
||||
(8, 8, 1103, CURDATE()),
|
||||
(9, 9, 1103, CURDATE()),
|
||||
(10, 10, 1102, DATE_SUB(CURDATE(), INTERVAL 1 DAY)),
|
||||
(11, 11, 1103, DATE_SUB(CURDATE(), INTERVAL 1 DAY));
|
||||
|
||||
INSERT INTO `hedera`.`userSession`(`created`, `lastUpdate`, `ssid`, `data`, `userVisitFk`)
|
||||
VALUES
|
||||
|
|
|
@ -45,6 +45,7 @@ module.exports = Self => {
|
|||
wtc.workerFk
|
||||
FROM hedera.visitUser v
|
||||
JOIN client c ON c.id = v.userFk
|
||||
JOIN account.user u ON c.salesPersonFk = u.id
|
||||
LEFT JOIN sharingCart sc ON sc.workerFk = c.salesPersonFk
|
||||
AND CURDATE() BETWEEN sc.started AND sc.ended
|
||||
LEFT JOIN workerTeamCollegues wtc
|
||||
|
|
|
@ -6,9 +6,18 @@ describe('SalesMonitor clientsFilter()', () => {
|
|||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 18}}, args: {}};
|
||||
const filter = {order: 'dated DESC'};
|
||||
|
||||
const from = new Date();
|
||||
const to = new Date();
|
||||
from.setHours(0, 0, 0, 0);
|
||||
to.setHours(23, 59, 59, 59);
|
||||
|
||||
const filter = {
|
||||
where: {
|
||||
'v.stamp': {between: [from, to]}
|
||||
}
|
||||
};
|
||||
const result = await models.SalesMonitor.clientsFilter(ctx, filter, options);
|
||||
|
||||
expect(result.length).toEqual(3);
|
||||
|
@ -19,4 +28,32 @@ describe('SalesMonitor clientsFilter()', () => {
|
|||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
it('should return the clients web activity filtered', async() => {
|
||||
const tx = await models.SalesMonitor.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
const ctx = {req: {accessToken: {userId: 18}}, args: {}};
|
||||
const yesterday = new Date();
|
||||
yesterday.setDate(yesterday.getDate() - 1);
|
||||
const today = new Date();
|
||||
yesterday.setHours(0, 0, 0, 0);
|
||||
today.setHours(23, 59, 59, 59);
|
||||
|
||||
const filter = {
|
||||
where: {
|
||||
'v.stamp': {between: [yesterday, today]}
|
||||
}
|
||||
};
|
||||
const result = await models.SalesMonitor.clientsFilter(ctx, filter, options);
|
||||
|
||||
expect(result.length).toEqual(5);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue