fix: resolve all npm audit security vulnerabilities

Ran npm audit fix to resolve 19 vulnerabilities and upgraded vitest from
v3 to v4.1.8 (breaking change) to fix the critical UI server advisory
(GHSA-5xrq-8626-4rwp).

Vitest v4 no longer allows vi.fn() mocks to be used as constructors, so
converted constructor mocks (IntersectionObserver, ResizeObserver,
AbortController, NPool/NRelay1) to real classes in the test setup and
affected test files.

npm audit now reports 0 vulnerabilities.
This commit is contained in:
Alex Gleason committed 2026-06-05 09:23:29 -05:00
1 parent 98985c29de
commit 18815f0649
5 files changed
+550 -647

No files matched your search

+16 -13
View File
@@ -72,21 +72,24 @@ Object.defineProperty(window, 'scrollTo', {
Element.prototype.scrollIntoView = vi.fn();
// Mock IntersectionObserver
global.IntersectionObserver = vi.fn().mockImplementation((_callback) => ({
observe: vi.fn(),
unobserve: vi.fn(),
disconnect: vi.fn(),
root: null,
rootMargin: '',
thresholds: [],
}));
class MockIntersectionObserver {
root = null;
rootMargin = '';
thresholds: ReadonlyArray<number> = [];
observe = vi.fn();
unobserve = vi.fn();
disconnect = vi.fn();
takeRecords = vi.fn(() => []);
}
global.IntersectionObserver = MockIntersectionObserver as unknown as typeof IntersectionObserver;
// Mock ResizeObserver
global.ResizeObserver = vi.fn().mockImplementation((_callback) => ({
observe: vi.fn(),
unobserve: vi.fn(),
disconnect: vi.fn(),
}));
class MockResizeObserver {
observe = vi.fn();
unobserve = vi.fn();
disconnect = vi.fn();
}
global.ResizeObserver = MockResizeObserver as unknown as typeof ResizeObserver;
// Mock indexedDB for LightningFS
const mockIDBRequest = {