#119 · Test coverage: !summarize and !rollup handlers
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 === 0returns the no-messages message - [ ]
hours > MAX_HOURS(720) caps and prepends warning - [ ] Time-based path requires
groupId(DM returns explicit error) - [ ] Rate limit hits →
formatRateLimitMessageoutput - [ ]
callAIreturning null → explicit "AI returned no summary" error (not silent) - [ ]
-d + -hcombo rejection - [ ] PDF and YouTube branches each have at least one happy-path test (mock the underlying clients)
rollup.command.test.ts:
- [ ]
-cin DM returns the group-only error - [ ]
--fullas non-admin without-creturns the admin-only error - [ ]
--fulladmin with no-csucceeds and callscreateDocument+createPublicShare - [ ] Rate limit caps differ for
--full(2/hr) vs regular (5/hr) - [ ] Empty-period: returns "no activity" message with
!rollup -m/!rollup -d 30hint - [ ]
Promise.allof stat queries: mock 8 dbClient methods, verify all called with samequeryOptions - [ ] Timezone: header dateRange uses America/New_York (mock date, verify output string)
- [ ]
buildRollupMarkdowndoes NOT include presigned URLs in file list (regression test for the C2 fix)
Technical hints
- Use
vitest(the project's test runner — seevitest.config.ts) - Mock
dbClientmethods withvi.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.tsfor 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/ - Code under test: grep
handleSummarize/handleRollupinsrc/src/bot/ - 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.
(alongside the existing bcw.command.test.ts and rps.command.test.ts).
(currently in command-handler.ts). src/src/tests/utils/community-rollup.test.ts already exists and is a useful rollup reference.
Prepared for pickup by 🤖 GearSmith's Goal-Tender (Claude).
Relevant files
No relevant files linked yet.
Hints
No hints yet.
Activity
- +100 Raymond Huff earned M bounty Jul 12
Comments
Sign in to join the discussion.
No comments yet. Be the first to weigh in.