From 9dcd56177805ad39b05516fc8860a0560e45356e Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Fri, 19 Jun 2026 23:29:45 +0530 Subject: [PATCH] test(projects): fix time-of-day flaky daily-timesheet-summary test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit make_timesheet(simulate=True) logs at now_datetime(); when the suite runs late in the day under the site timezone the 2h log crosses midnight, so its to_time falls outside the report's `to_time <= end-of-day` bound and the submitted timesheet is (correctly) excluded — making test_submitted_timesheet_in_summary fail in an evening window (observed at 22:51 IST in CI). Pin the log to a fixed mid-day window on today so the assertion is time-of-day independent. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../test_daily_timesheet_summary.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/erpnext/projects/report/daily_timesheet_summary/test_daily_timesheet_summary.py b/erpnext/projects/report/daily_timesheet_summary/test_daily_timesheet_summary.py index 6b8c42b6411..57f1ab85853 100644 --- a/erpnext/projects/report/daily_timesheet_summary/test_daily_timesheet_summary.py +++ b/erpnext/projects/report/daily_timesheet_summary/test_daily_timesheet_summary.py @@ -1,8 +1,10 @@ # Copyright (c) 2024, Frappe Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt +from datetime import timedelta + import frappe -from frappe.utils import today +from frappe.utils import get_datetime, today from erpnext.projects.doctype.timesheet.test_timesheet import make_timesheet from erpnext.projects.report.daily_timesheet_summary.daily_timesheet_summary import execute @@ -17,6 +19,18 @@ class TestDailyTimesheetSummary(ERPNextTestSuite): employee = make_employee("test_employee_6@salary.com", company="_Test Company") timesheet = make_timesheet(employee, simulate=True) + # make_timesheet logs at now_datetime(); run late in the day (under the site timezone) + # the 2h log crosses midnight and falls outside the report's `to_time <= end-of-day` + # bound. Pin the log to a fixed mid-day window on today so the assertion is + # time-of-day independent. + start = get_datetime(today()) + timedelta(hours=9) + frappe.db.set_value( + "Timesheet Detail", + timesheet.time_logs[0].name, + {"from_time": start, "to_time": start + timedelta(hours=2)}, + update_modified=False, + ) + _columns, data = execute({"from_date": today(), "to_date": today()}) # Row column order: [Timesheet.name, employee, employee_name, from_time, to_time,