Submit a merge request that closes this issue to earn points on merge — bounties stack on the standard +40 merge_pr award. New to the repo? See the Contributing guide, and Local Development & SSO to run the app locally (cp .dev.vars.example .dev.vars && pnpm dev, after rebasing on main) and fully test your change before opening the MR.

Description

Context

handleSummarize (567 lines, ~5 distinct content pipelines: PDF, YouTube, social video, HTML, plain text) and handleRollup (~300 lines, 8 stat queries + Outline doc) have zero test coverage in apps/signal-bot/src/tests/. The only handler test is bcw.command.test.ts. Recent fixes to these handlers (rate limits, admin gating, Promise.all parallelization, timezone) shipped without regression tests.

Acceptance criteria

Add apps/signal-bot/src/tests/bot/summarize.command.test.ts and apps/signal-bot/src/tests/bot/rollup.command.test.ts covering at minimum:

summarize.command.test.ts:

  • [ ] messages.length === 0 returns the no-messages message
  • [ ] hours > MAX_HOURS (720) caps and prepends warning
  • [ ] Time-based path requires groupId (DM returns explicit error)
  • [ ] Rate limit hits → formatRateLimitMessage output
  • [ ] callAI returning null → explicit "AI returned no summary" error (not silent)
  • [ ] -d + -h combo rejection
  • [ ] PDF and YouTube branches each have at least one happy-path test (mock the underlying clients)

rollup.command.test.ts:

  • [ ] -c in DM returns the group-only error
  • [ ] --full as non-admin without -c returns the admin-only error
  • [ ] --full admin with no -c succeeds and calls createDocument + createPublicShare
  • [ ] Rate limit caps differ for --full (2/hr) vs regular (5/hr)
  • [ ] Empty-period: returns "no activity" message with !rollup -m / !rollup -d 30 hint
  • [ ] Promise.all of stat queries: mock 8 dbClient methods, verify all called with same queryOptions
  • [ ] Timezone: header dateRange uses America/New_York (mock date, verify output string)
  • [ ] buildRollupMarkdown does NOT include presigned URLs in file list (regression test for the C2 fix)

Technical hints

  • Use vitest (the project's test runner — see vitest.config.ts)
  • Mock dbClient methods with vi.fn().mockResolvedValue(...) and the OpenAI client similarly
  • For the timezone test, use vi.useFakeTimers() + vi.setSystemTime(new Date('2026-05-15T05:00:00Z')) to pin the date
  • Reference: apps/signal-bot/src/tests/bot/bcw.command.test.ts for handler-test setup patterns

--- *M-tier (100 pts + 40 = 140). Substantial work but unblocks confident future refactors of these two giant functions.*

Getting Started (added for pickup-readiness)

Path note: this code moved out of apps/signal-bot/ into
selfhost/messaging-apps/signal-messenger/. Translate the paths above:
apps/signal-bot/src/tests/selfhost/messaging-apps/signal-messenger/src/src/tests/.
  • New specs go in: selfhost/messaging-apps/signal-messenger/src/src/tests/bot/
  • (alongside the existing bcw.command.test.ts and rps.command.test.ts).

  • Code under test: grep handleSummarize / handleRollup in src/src/bot/
  • (currently in command-handler.ts). src/src/tests/utils/community-rollup.test.ts already exists and is a useful rollup reference.

  • Pattern to copy: src/src/tests/bot/bcw.command.test.ts (handler-test setup + mock wiring).
  • Verify: cd selfhost/messaging-apps/signal-messenger/src && npx vitest run src/tests/bot/summarize.command.test.ts src/tests/bot/rollup.command.test.ts
  • Done when: both spec files exist, every acceptance box is exercised, and the suite is green.

Prepared for pickup by 🤖 GearSmith's Goal-Tender (Claude).

Relevant files

No relevant files linked yet.

Hints

No hints yet.

Activity

No points have been awarded for this bounty yet.

Comments

No comments yet. Be the first to weigh in.

↑ Top