Skip to content

Add boundary-merge tests for working-time-by-project#787

Merged
selfcontained merged 1 commit into
mainfrom
agt_8f52ea2ee777/job-test-enforcer-1b021f03
Jul 17, 2026
Merged

Add boundary-merge tests for working-time-by-project#787
selfcontained merged 1 commit into
mainfrom
agt_8f52ea2ee777/job-test-enforcer-1b021f03

Conversation

@selfcontained

@selfcontained selfcontained commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Summary

Adds 4 integration tests for the GET /api/v1/activity/working-time-by-project boundary-merge path (handleWorkingTimeByProject, apps/server/src/routes/activity.ts), which was previously only smoke-tested:

  • clamps a pre-range working session to the range start
  • carries in the latest pre-range event (guards the DISTINCT ON ... ORDER BY created_at DESC boundary query)
  • merges boundary + in-range events per agent independently with interleaved timestamps
  • prefers event project_dir over agent cwd for boundary events (COALESCE)

Tests use fixed Jan-2026 timestamps and explicit start/end params so agent-creation events at "now" can't contaminate the strict assertions. Also extends the seedEvent helper with an optional projectDir param.

Note: this PR originally also fixed the prepare-release install gap, but #786 landed the same fix first, so that hunk was dropped after rebasing.

Validation

  • pnpm run check
  • pnpm run test ✅ (server 2268 passed, web 224, browser-extension 51)
  • pnpm run test:e2e ✅ (168 passed, 13 skipped on full re-run)
  • Reviewed by a general review agent — no blocking findings

🤖 Generated with Claude Code

Four integration tests for the previously smoke-tested boundary-merge
path in handleWorkingTimeByProject: range-start clamping, DISTINCT ON
picking the latest pre-range event, per-agent merge of interleaved
events, and project_dir precedence over agent cwd.

Co-Authored-By: Claude Fable 5 <[email protected]>
@selfcontained
selfcontained force-pushed the agt_8f52ea2ee777/job-test-enforcer-1b021f03 branch from bd0ccc6 to 497e437 Compare July 17, 2026 02:37
@selfcontained selfcontained changed the title Fix release workflow install gap and add working-time boundary tests Add boundary-merge tests for working-time-by-project Jul 17, 2026
@selfcontained
selfcontained merged commit f7a7eb5 into main Jul 17, 2026
1 check passed
@selfcontained
selfcontained deleted the agt_8f52ea2ee777/job-test-enforcer-1b021f03 branch July 17, 2026 02:43
selfcontained added a commit that referenced this pull request Jul 19, 2026
…tatus (#797)

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]>
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