← Back to PRs

#19095: test(discord): add unit tests for presence cache module

by Clawborn open 2026-02-17 11:09 View on GitHub →
channel: discord size: S trusted-contributor
The presence cache module (`src/discord/monitor/presence-cache.ts`) had zero test coverage. Adds 9 unit tests covering: - Store and retrieve presence data - Undefined accountId fallback behavior - Overwrites for same user+account - Per-account clearing - Global clearing - Cross-account size tracking - Max-size eviction (5000 cap) <!-- greptile_comment --> <h3>Greptile Summary</h3> Adds a comprehensive unit test suite for the Discord presence cache module (`src/discord/monitor/presence-cache.ts`), which previously had zero test coverage. The 9 tests cover the full public API surface: `setPresence`, `getPresence`, `clearPresences`, and `presenceCacheSize`, including edge cases like the `undefined` accountId fallback to `"default"` key and the 5000-entry per-account eviction cap. - Tests follow project conventions: colocated `*.test.ts`, vitest framework, proper `afterEach` cleanup of module-level state - Eviction test correctly verifies FIFO eviction behavior at the 5000-entry boundary - No issues found — clean, focused test addition with no production code changes <h3>Confidence Score: 5/5</h3> - This PR is safe to merge — it only adds a new test file with no changes to production code. - Score of 5 reflects that this is a pure test addition with no production code changes. The tests are correctly written, properly isolated, and follow project conventions. No logical errors or issues found. - No files require special attention. <sub>Last reviewed commit: 7a61b28</sub> <!-- greptile_other_comments_section --> **Context used:** - Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8)) <!-- /greptile_comment -->

Most Similar PRs