Merge pull request #2497 from PR0M3TH3AN/agents/daily/ci-health-agent-2026-02-14-5523154352363649208

chore(ai): CI health fixes (flaky tests)
This commit is contained in:
thePR0M3TH3AN authored and GitHub committed 2026-02-14 09:56:53 -05:00
commit a07f197773
3 files changed
+63 -34

No files matched your search

@@ -0,0 +1,25 @@
# CI Health Agent - Daily Run
**Date:** 2026-02-14
**Agent:** ci-health-agent
**Status:** Completed
## Summary
Identified and fixed test pollution risks in unit tests that mocked global objects (`global.document` and `global.window`) without guaranteed cleanup.
## Changes
1. **Refactored `tests/nostr/videoEventBuffer.test.mjs`**: Wrapped `global.document` mocking in a `try...finally` block to ensure restoration even if assertions fail.
2. **Refactored `tests/ui/engagement-controller.test.mjs`**: Wrapped `global.window` mocking in a `try...finally` block to ensure deletion even if assertions fail.
## Verification
Ran the affected tests locally to ensure they pass:
- `tests/nostr/videoEventBuffer.test.mjs`: Passed
- `tests/ui/engagement-controller.test.mjs`: Passed
## Learnings
- Tests running in the same process (even sequentially) can pollute global state (`window`, `document`) if not cleaned up properly.
- `try...finally` is crucial when mocking globals in tests.