Skip to content

Add boundary carry-in tests for /activity/stats and /activity/daily-status#797

Merged
selfcontained merged 1 commit into
mainfrom
agt_47fdc016c0dd/job-test-enforcer-75abf536
Jul 19, 2026
Merged

Add boundary carry-in tests for /activity/stats and /activity/daily-status#797
selfcontained merged 1 commit into
mainfrom
agt_47fdc016c0dd/job-test-enforcer-75abf536

Conversation

@selfcontained

Copy link
Copy Markdown
Owner

Summary

Recurring test-enforcer maintenance run. Local suite was green at start (check ✓, unit 2281+232+51 ✓, E2E 168 pass/13 skip ✓), so this run closes the highest-value coverage gap identified by the prior run's next_focus.

handleStats and handleDailyStatus both route through loadScopedActivityEvents (apps/server/src/server/activity-query.ts), which merges an in-range query with a DISTINCT ON (agent_id) … WHERE created_at < rangeStart ORDER BY created_at DESC boundary query to carry in each agent's latest pre-range event, then clamps its duration to the range start. That carry-in logic had boundary coverage for working-time-by-project (#787) but zero coverage for these two other consumers.

Tests added (4)

  • stats — clamps a pre-range working session to the range start (30 min counted, not the 150 before it)
  • stats — carries in the latest pre-range event, not the earliest (a pre-range done accrues 0)
  • daily-status — same clamp, asserted by summing working duration across buckets
  • daily-status — a completed pre-range session accrues no time

daily-status assertions sum working duration across day buckets rather than asserting bucket keys, because computeDailyStatus buckets by server-local date — the summed clamped total is timezone-independent, avoiding CI flakiness.

Validation

  • pnpm run check
  • pnpm run test ✓ — server 2285 pass (was 2281, +4), web 232, browser-ext 51, all green
  • pnpm run test:e2e ✓ (baseline) — 168 pass / 13 skip; no product code changed so E2E is unaffected
  • One general review agent traced all four assertions through the merge + compute logic: correct, no timezone/ordering/cleanup flakiness, no changes recommended.

Test-only change.

🤖 Generated with Claude Code

…tatus

Both handleStats and handleDailyStatus route through loadScopedActivityEvents
(apps/server/src/server/activity-query.ts), which merges an in-range query with
a `DISTINCT ON (agent_id) ... WHERE created_at < rangeStart ORDER BY created_at
DESC` boundary query to carry in each agent's latest pre-range event. That
carry-in + range-start clamping logic already had coverage for
working-time-by-project (PR #787) but zero coverage for the two other consumers.

Adds 4 tests mirroring the working-time-by-project boundary pattern (same fixed
Jan-2026 UTC range):
- stats: clamps a pre-range working session to the range start (30 min, not 150)
- stats: carries in the latest pre-range event, not the earliest (done -> 0)
- daily-status: same clamp, asserted by summing working across buckets
- daily-status: completed pre-range session accrues no time

daily-status assertions sum working duration across day buckets rather than
asserting bucket keys, because computeDailyStatus buckets by server-local date;
the summed clamped total is timezone-independent, avoiding CI flakiness.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@selfcontained
selfcontained merged commit b1e7557 into main Jul 19, 2026
1 check passed
@selfcontained
selfcontained deleted the agt_47fdc016c0dd/job-test-enforcer-75abf536 branch July 19, 2026 02:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant