mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
Refactored tests to prevent global pollution. Cleaned up global variables in after hooks. - tests/ui/uploadModal-integration.test.mjs: Save and restore global window, document, fetch, etc. - tests/ui/storageService.test.mjs: Save and restore global indexedDB, crypto, etc. - Added daily agent report. Co-authored-by: PR0M3TH3AN <[email protected]>
1.6 KiB
1.6 KiB
CI Health Agent - Daily Run
Date: 2026-02-16 Agent: ci-health-agent Status: Completed
Summary
Performed a proactive health check on unit tests to identify and resolve global variable pollution risks. Since direct CI logs were inaccessible, the agent focused on local static analysis and runtime verification of test isolation.
Changes
-
Refactored
tests/ui/uploadModal-integration.test.mjs:- Implemented logic to capture original global values (
window,document,fetch, etc.) before tests run. - Added robust restoration logic in the
afterhook to ensure these globals are reset or deleted, preventing side effects on subsequent tests.
- Implemented logic to capture original global values (
-
Refactored
tests/ui/storageService.test.mjs:- Implemented capture and restore logic for globals including
indexedDB,IDBKeyRange, andcrypto. - Added specific handling for
global.cryptoto respect its read-only nature (usingObject.definePropertyif necessary) while ensuring clean state.
- Implemented capture and restore logic for globals including
Verification
Ran the affected tests locally to ensure they pass and verify the fix logic does not introduce regressions:
tests/ui/uploadModal-integration.test.mjs: Passedtests/ui/storageService.test.mjs: Passednpm run lint: Passed
Learnings
global.cryptoin Node.js 19+ is a read-only getter property. Restoration logic must account for this by either avoiding unnecessary writes or usingObject.definePropertyto restore a value if it was successfully mocked.- Proactive isolation of globals in tests using
jsdomor manual polyfills is critical for preventing flaky tests in the shared Node.js process.