Testing · mastra-ai/mastra
Test notification-to-signal mapping and summary edge cases
Adds a Vitest suite for five pure helpers in Mastra's notification pipeline. The tests cover signal attributes, metadata conversion, summary formatting, and pending-notification aggregation without changing production behavior.
The problem
The notification-to-signal helpers lacked unit coverage. Their contracts include subtle rules such as core fields overriding custom attributes, conditional inclusion of coalesced counts and timestamps, and summaries counting only pending notifications.
The approach
Introduces a dedicated signals.test.ts file with reusable notification and summary fixtures. Tests exercise field mapping and precedence, ISO timestamp serialization, alphabetical source ordering, and highest-priority selection. Aggregation cases cover pending-only counts and IDs, source and priority grouping, first-notification context, and empty or all-seen inputs.
What changed
Adds executable checks for the five helpers' mapping and aggregation contracts. The change is additive test coverage, with no production behavior changes or new dependencies.
- typescript
- vitest
- unit-testing
- notifications
- signals