fix(time-entries): use server time for running timers

This commit is contained in:
2026-05-21 13:01:51 +03:30
parent 0fea265cfb
commit e234eac26d
4 changed files with 59 additions and 14 deletions

View File

@@ -19,6 +19,28 @@ def make_aware(year, month, day, hour=9, minute=0, second=0):
class TimeEntryViewTests(APITestCase):
def test_create_running_time_entry_without_start_time_uses_server_time(self):
user = User.objects.create_user(mobile="09125555555", password="secret123")
workspace = Workspace.objects.create(name="Core", owner=user)
self.client.force_authenticate(user=user)
before = timezone.now()
response = self.client.post(
"/api/time-entries/",
{
"workspace_id": str(workspace.id),
"description": "Running work",
},
format="json",
)
after = timezone.now()
self.assertEqual(response.status_code, 201)
entry = TimeEntry.objects.get(id=response.data["id"])
self.assertIsNone(entry.end_time)
self.assertGreaterEqual(entry.start_time, before)
self.assertLessEqual(entry.start_time, after)
def test_time_entry_list_returns_grouped_payload_for_ended_entries(self):
user = User.objects.create_user(mobile="09126666666", password="secret123")
workspace = Workspace.objects.create(name="Core", owner=user)