Added tasks, reminders, and role-specific dashboards

This commit is contained in:
Oleksandr Prokhorenko
2026-09-24 22:18:41 +03:00
parent 1f8721e742
commit 9ccbac4aca
33 changed files with 2583 additions and 511 deletions
+24
View File
@@ -34,3 +34,27 @@ test('every role receives its exact merchant scope', () => {
assert.deepEqual(merchantScope({ role: 'COMPLIANCE_OFFICER' }), {});
assert.deepEqual(merchantScope({ role: 'unexpected' }), { id: '__no_access__' });
});
test('task day boundaries use the viewer time zone through DST and include exact due instants', async () => {
const { localDayBounds, taskWhere } = await import('../dist/task-policy.js');
for (const [date, hours] of [
['2026-03-08T12:00:00Z', 23],
['2026-11-01T12:00:00Z', 25],
]) {
const { start, end } = localDayBounds(new Date(date), 'America/New_York');
assert.equal((end - start) / 3600000, hours);
}
const now = new Date('2026-09-24T22:00:00Z');
const { start, end } = localDayBounds(now, 'Europe/Kyiv');
assert.equal(start.toISOString(), '2026-09-24T21:00:00.000Z');
assert.equal(end.toISOString(), '2026-09-25T21:00:00.000Z');
const user = { id: 'manager', role: 'ACCOUNT_MANAGER' };
assert.deepEqual(
taskWhere(user, { filter: 'TODAY', timeZone: 'Europe/Kyiv' }, now).AND[1].dueAt,
{ gte: start, lt: end },
);
assert.deepEqual(
taskWhere(user, { filter: 'UPCOMING', timeZone: 'Europe/Kyiv' }, now).AND[1].dueAt,
{ gte: end },
);
});