Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/helpers/overviewReportHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -1141,8 +1141,13 @@ const overviewReportHelper = function () {
};
}

// non-comparison branch
// Apply the selected range even when comparison mode is off.
const taskStats = await Task.aggregate([
{
$match: {
modifiedDatetime: { $gte: startDate, $lte: endDate },
},
},
{
$group: {
_id: '$status',
Expand Down
19 changes: 19 additions & 0 deletions src/helpers/overviewReportHelper.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const UserProfile = require('../models/userProfile');
const Task = require('../models/task');
const overviewReportHelper = require('./overviewReportHelper');

// const makeSut = () => {
Expand All @@ -8,6 +9,24 @@ const overviewReportHelper = require('./overviewReportHelper');
// };

describe('overviewReportHelper tests', () => {
describe('getTasksStats date boundaries', () => {
afterEach(() => jest.restoreAllMocks());

test('filters the non-comparison totals by the selected date range', async () => {
const startDate = new Date('2026-07-19T00:00:00-07:00');
const endDate = new Date('2026-07-25T23:59:00-07:00');
const aggregateSpy = jest.spyOn(Task, 'aggregate').mockResolvedValue([]);

const { getTasksStats } = overviewReportHelper();
await getTasksStats(startDate, endDate);

expect(aggregateSpy).toHaveBeenCalledWith([
{ $match: { modifiedDatetime: { $gte: startDate, $lte: endDate } } },
{ $group: { _id: '$status', count: { $sum: 1 } } },
]);
});
});

describe('getHoursStats date boundaries', () => {
const originalTimezone = process.env.TZ;

Expand Down
Loading