Release God's Eye View as open source

This commit is contained in:
Bilawal Sidhu committed 2026-08-24 17:02:16 -05:00
1 parent a5aaea7e16
commit 880a672b5e
433 files changed
+219893 -23

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
import { test } from 'node:test';
import assert from 'node:assert/strict';
import {
CCTV_FRAME_FETCH_TIMEOUT_MS,
fetchCctvImageFromUpstream,
} from '../../vite.config.js';
test('CCTV upstream frame fetch supplies a bounded abort signal', async () => {
let observedSignal = null;
const startedAt = Date.now();
const result = await fetchCctvImageFromUpstream('https://example.com/frame.jpg', {
timeoutMs: 20,
fetchImpl: (_url, options) => new Promise((_resolve, reject) => {
observedSignal = options.signal;
options.signal.addEventListener('abort', () => reject(options.signal.reason), { once: true });
}),
});
assert.equal(result, null);
assert.ok(observedSignal instanceof AbortSignal);
assert.equal(observedSignal.aborted, true);
assert.ok(Date.now() - startedAt < 500, 'test timeout should settle promptly');
assert.ok(CCTV_FRAME_FETCH_TIMEOUT_MS < 10_000, 'production timeout must beat the active refresh cadence');
});
test('CCTV upstream frame fetch returns a valid image response', async () => {
const result = await fetchCctvImageFromUpstream('https://example.com/frame.jpg', {
timeoutMs: 100,
fetchImpl: async () => new Response(Uint8Array.from([1, 2, 3]), {
status: 200,
headers: { 'Content-Type': 'image/jpeg' },
}),
});
assert.equal(result?.ok, true);
assert.equal(result?.contentType, 'image/jpeg');
assert.deepEqual(result?.body, Buffer.from([1, 2, 3]));
});