test(projects): fix time-of-day flaky daily-timesheet-summary test

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) <noreply@anthropic.com>
This commit is contained in:
Mihir Kandoi
2026-06-19 23:29:45 +05:30
parent a5f21331a4
commit 9dcd561778

View File

@@ -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,