test(stats): prove seconds-only recency on a fresh row (#948)

CodeRabbit on #947: the prior lastPlayPosition POST already stamped
last_played_at, so the assertion passed even if the seconds-only path
left it unchanged — a guard that cannot fail. Assert on a fresh row.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Byron Gamatos 2026-07-13 15:36:05 +02:00 committed by GitHub
parent 3e57ba0345
commit 5921157f35
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -480,8 +480,11 @@ def test_seconds_only_post_accrues_without_touching_position(client):
# overwrite Continue with the end-of-song offset).
assert row["plays"] == 0
assert row["last_position"] == pytest.approx(42.0)
# But the song WAS played — recency ordering must see it.
assert row["last_played_at"]
# Recency must come from the seconds-only POST itself — prove it on a
# FRESH row (the position touch above already stamps last_played_at,
# which would make an assertion here vacuous).
r2 = client.post("/api/stats", json={"filename": "fresh.archive", "seconds": 30})
assert r2.json()["stats"]["last_played_at"]
# Still counts as playing today for the streak.
assert r.json()["progress"]["current_streak"] == 1