Repository navigation
refactor(discord): deduplicate presence listener tests - #118155
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed August 2, 2026, 3:54 PM ET / 19:54 UTC. ClawSweeper reviewWhat this changesThe branch replaces repeated Discord presence-listener test construction with a shared fixture, per-case overrides, and resettable test clock/client state while preserving the existing scenarios. Merge readinessKeep this PR open for normal maintainer landing. It is a focused test-only cleanup with no production, configuration, dependency, or security surface change; source inspection found no blocking correctness regression in the shared fixture. Priority: P3 Review scores
Verification
How this fits togetherDiscord gateway presence events are processed by the Discord presence listener, which applies snapshot, cooldown, visibility, and burst rules before queueing a system event and requesting a heartbeat. This PR changes only the regression harness that supplies those event inputs and verifies those outputs. flowchart TD
A[Presence event fixtures] --> B[Shared test fixture]
B --> C[Discord presence listener]
C --> D[Snapshot, cooldown, visibility, and burst decisions]
D --> E[Queued system event]
D --> F[Heartbeat assertion]
Before merge
Agent review detailsSecurityNone. PR surfaceTests -203. Total -203 across 1 file. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Retain one canonical fixture for the 29 existing regression scenarios and land it after the ordinary current-head checks complete, without changing Discord presence runtime behavior. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR refactors regression-test setup rather than reporting or changing a user-visible runtime failure. The preserved test-title and assertion counts provide a high-confidence check that the existing behavioral contract remains covered. Is this the best way to solve the issue? Yes. A constructor-derived fixture is the narrowest maintainable solution because it centralizes only the repeated listener defaults while each scenario retains explicit overrides for the behavior it exercises. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 254ab826f1e3. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
What Problem This Solves
The Discord presence-listener regression suite repeated the same full listener, clock, cooldown-store, guild, and client setup across 29 cases. That duplication made the suite substantially longer and made scenario-specific differences harder to review.
Why This Change Was Made
Use one constructor-derived listener fixture with explicit per-case overrides, plus a deterministic clock and human client reset before every test. Production code, Discord configuration, event ordering, privacy checks, and assertions are unchanged.
User Impact
No user-visible behavior changes. This reduces the presence-listener test file by 203 net lines while preserving its complete regression contract.
Evidence
node scripts/run-vitest.mjs extensions/discord/src/monitor/listeners.presence.test.ts(29/29 passed).tbx_01kz1zdrj67q00t7ssfwz4p2hv: focused presence suite 29/29; full Discord suite 2,489/2,489; changed gate passed formatting, extension test typecheck, lint, dependency, duplicate, boundary, and dead-code checks.discord-api-types0.38.52 contracts.