mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-03 07:57:22 +00:00
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:
5 files changed
+550
-647
No files matched your search
Generated
+522
-626
File diff suppressed because it is too large.
Load diff
+1
-1
@@ -151,6 +151,6 @@
|
||||
"typescript-eslint": "^8.0.1",
|
||||
"vite": "^6.3.5",
|
||||
"vite-plugin-pwa": "^1.1.0",
|
||||
"vitest": "^3.1.4"
|
||||
"vitest": "^4.1.8"
|
||||
}
|
||||
}
|
||||
@@ -388,11 +388,15 @@ describe('CurlCommand', () => {
|
||||
it('should handle timeout', async () => {
|
||||
vi.useFakeTimers();
|
||||
|
||||
const abortFn = vi.fn();
|
||||
const mockController = {
|
||||
abort: vi.fn(),
|
||||
abort: abortFn,
|
||||
signal: { aborted: false }
|
||||
};
|
||||
global.AbortController = vi.fn(() => mockController) as unknown as typeof AbortController;
|
||||
global.AbortController = class {
|
||||
abort = abortFn;
|
||||
signal = mockController.signal;
|
||||
} as unknown as typeof AbortController;
|
||||
|
||||
// Mock fetch to reject with AbortError after timeout
|
||||
mockFetch.mockImplementation(() => {
|
||||
|
||||
@@ -24,11 +24,11 @@ vi.mock('nostr-tools', () => ({
|
||||
|
||||
// Mock NPool to avoid actual network calls
|
||||
vi.mock('@nostrify/nostrify', () => ({
|
||||
NPool: vi.fn().mockImplementation(() => ({
|
||||
event: vi.fn().mockResolvedValue(undefined),
|
||||
close: vi.fn().mockResolvedValue(undefined),
|
||||
})),
|
||||
NRelay1: vi.fn(),
|
||||
NPool: class {
|
||||
event = vi.fn().mockResolvedValue(undefined);
|
||||
close = vi.fn().mockResolvedValue(undefined);
|
||||
},
|
||||
NRelay1: class {},
|
||||
}));
|
||||
|
||||
describe('NostrPublishEventsTool', () => {
|
||||
|
||||
+16
-13
@@ -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 = {
|
||||
|
||||
Reference in new issue
Block a user