chore(ai): CI health fixes (flaky tests)

- Refactor `tests/nostr/videoEventBuffer.test.mjs` to safely restore `global.document` using try...finally.
- Refactor `tests/ui/engagement-controller.test.mjs` to safely delete `global.window` using try...finally.
- Fixes potential test pollution that could cause flakes in shared environments.

Ran `npm run test:unit` for verification.

Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
google-labs-jules[bot]andPR0M3TH3AN committed 2026-02-14 04:51:11 +00:00
1 parent 52a21a9b70
commit c5fd482884
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.