Skip to content
Merged
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
3 changes: 2 additions & 1 deletion driving_log/templates/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,21 @@ <h1>Student progress</h1>
<div>
<p><strong>{{ format_minutes(totals.total_minutes) }}</strong><small> / 60h</small></p>
<span>Total driving</span>
<span>Remaining: {{ format_minutes([0, 3600 - totals.total_minutes] | max) }}</span>
</div>
</article>
<article>
<span class="progress-icon progress-icon-night" aria-hidden="true">☾</span>
<div>
<p><strong>{{ format_minutes(totals.night_minutes) }}</strong><small> / 10h</small></p>
<span>Night driving</span>
<span>Remaining: {{ format_minutes([0, 600 - totals.night_minutes] | max) }}</span>
</div>
</article>
</div>
</div>
</section>
<section class="stats">
<article><span>Remaining</span><strong>{{ format_minutes([0, 3600 - totals.total_minutes] | max) }}</strong></article>
<article><span>Recorded drives</span><strong>{{ totals.drive_count }}</strong></article>
</section>
{% if overages %}
Expand Down
33 changes: 31 additions & 2 deletions tests/test_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -1178,6 +1178,22 @@ async def add_drive(day: int, duration_minutes: int) -> None:
)
self.assertEqual(response.status_code, 303)

async def add_night_drive(day: int) -> None:
start = datetime(2026, 7, day, 22, tzinfo=ZoneInfo(DEFAULT_TIMEZONE))
response = await client.post(
"/drives",
data={
"request_id": str(uuid.uuid4()),
"driver_name": "Daniel Ahern",
"started_at_local": start.strftime("%Y-%m-%dT%H:%M"),
"ended_at_local": (start + timedelta(hours=8)).strftime(
"%Y-%m-%dT%H:%M"
),
"road_type": "local",
},
)
self.assertEqual(response.status_code, 303)

await add_drive(1, 18)
dashboard = await client.get("/")
self.assertIn(
Expand Down Expand Up @@ -1210,11 +1226,24 @@ async def add_drive(day: int, duration_minutes: int) -> None:
self.assertIn(">100%</text>", dashboard.text)

await add_drive(16, 288)
await add_night_drive(20)
await add_night_drive(22)
await add_night_drive(24)
dashboard = await client.get("/")
self.assertIn(
'aria-label="108 percent of required driving completed"', dashboard.text
'aria-label="148 percent of required driving completed"', dashboard.text
)
self.assertIn(">148%</text>", dashboard.text)
self.assertIn(
"<span>Total driving</span>\n <span>Remaining: 0h 00m</span>",
dashboard.text,
)
self.assertIn(
"<span>Night driving</span>\n <span>Remaining: 0h 00m</span>",
dashboard.text,
)
self.assertIn(">108%</text>", dashboard.text)
self.assertNotIn("Total remaining", dashboard.text)
self.assertNotIn("Nighttime remaining", dashboard.text)

self.run_async(scenario)

Expand Down
Loading