mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-31 18:02:27 +00:00
chore(ai): CI health fixes (test isolation)
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]>
This commit is contained in:
1 parent
a4a1de2c85
commit
7fdcecfc64
3 files changed
+83
No files matched your search
@@ -10,6 +10,7 @@ let PROVIDERS;
|
||||
describe("StorageService", () => {
|
||||
let dom;
|
||||
const mockPubkey = "0000000000000000000000000000000000000000000000000000000000000001";
|
||||
const originalGlobals = {};
|
||||
|
||||
// Mock Signer (NIP-04 style for simplicity)
|
||||
// In a real app, this does ECIES. Here we just reverse string or something reversible for test speed/simplicity
|
||||
@@ -34,6 +35,13 @@ describe("StorageService", () => {
|
||||
};
|
||||
|
||||
before(async () => {
|
||||
originalGlobals.window = global.window;
|
||||
originalGlobals.indexedDB = global.indexedDB;
|
||||
originalGlobals.globalThisIndexedDB = globalThis.indexedDB;
|
||||
originalGlobals.IDBKeyRange = global.IDBKeyRange;
|
||||
originalGlobals.globalThisIDBKeyRange = globalThis.IDBKeyRange;
|
||||
originalGlobals.crypto = global.crypto;
|
||||
|
||||
dom = createUiDom();
|
||||
|
||||
// Polyfill Globals
|
||||
@@ -66,6 +74,27 @@ describe("StorageService", () => {
|
||||
|
||||
after(() => {
|
||||
if (dom) dom.cleanup();
|
||||
|
||||
if ('window' in originalGlobals) global.window = originalGlobals.window; else delete global.window;
|
||||
|
||||
if ('indexedDB' in originalGlobals) global.indexedDB = originalGlobals.indexedDB; else delete global.indexedDB;
|
||||
if ('globalThisIndexedDB' in originalGlobals) globalThis.indexedDB = originalGlobals.globalThisIndexedDB; else delete globalThis.indexedDB;
|
||||
|
||||
if ('IDBKeyRange' in originalGlobals) global.IDBKeyRange = originalGlobals.IDBKeyRange; else delete global.IDBKeyRange;
|
||||
if ('globalThisIDBKeyRange' in originalGlobals) globalThis.IDBKeyRange = originalGlobals.globalThisIDBKeyRange; else delete globalThis.IDBKeyRange;
|
||||
|
||||
if ('crypto' in originalGlobals) {
|
||||
if (global.crypto !== originalGlobals.crypto) {
|
||||
try {
|
||||
global.crypto = originalGlobals.crypto;
|
||||
} catch (e) {
|
||||
// If read-only/getter, use defineProperty
|
||||
Object.defineProperty(global, 'crypto', { value: originalGlobals.crypto, writable: true, configurable: true });
|
||||
}
|
||||
}
|
||||
} else {
|
||||
delete global.crypto;
|
||||
}
|
||||
});
|
||||
|
||||
// Since storageService is a singleton, state might persist.
|
||||
|
||||
Reference in new issue
Block a user