Stream portal video assets with range support
Test, build, and deploy ComfyUI Jobs / test-build (push) Successful in 3m46s
Test, build, and deploy ComfyUI Jobs / deploy (push) Successful in 15s
Test, build, and deploy ComfyUI Jobs / browser-test (push) Successful in 2m7s
Test, build, and deploy ComfyUI Jobs / qa-gate (push) Successful in 4s

This commit is contained in:
2026-11-14 19:53:01 +00:00
parent 0e204ada43
commit 04344f7f64
2 changed files with 55 additions and 4 deletions
+26 -1
View File
@@ -2,7 +2,7 @@ const test = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const { app, jobFromHistory, statusFromHistory } = require('./server');
const { app, jobFromHistory, statusFromHistory, readVideoSize } = require('./server');
const { createJobStore } = require('./job-store');
test('serves frontend assets before authentication redirects', async (t) => {
@@ -50,6 +50,31 @@ test('recognises audio output arrays used by alternate ComfyUI nodes', () => {
assert.match(job.assets[0].url, /filename=result.mp3/);
});
test('reads video size with HEAD without downloading the video', async (t) => {
const originalFetch = global.fetch;
const calls = [];
global.fetch = async (_url, options = {}) => {
calls.push(options);
return new Response(null, { status: 200, headers: { 'content-length': '987654' } });
};
t.after(() => { global.fetch = originalFetch; });
assert.equal(await readVideoSize('http://comfy/view?filename=clip.mp4'), 987654);
assert.deepEqual(calls, [{ method: 'HEAD' }]);
});
test('falls back to a one-byte range probe when video HEAD has no length', async (t) => {
const originalFetch = global.fetch;
const calls = [];
global.fetch = async (_url, options = {}) => {
calls.push(options);
if (options.method === 'HEAD') return new Response(null, { status: 200 });
return new Response(new Uint8Array([0]), { status: 206, headers: { 'content-range': 'bytes 0-0/1234567' } });
};
t.after(() => { global.fetch = originalFetch; });
assert.equal(await readVideoSize('http://comfy/view?filename=clip.mp4'), 1234567);
assert.equal(calls[1].headers.Range, 'bytes=0-0');
});
test('classifies failed history without exposing mutation paths', () => {
assert.equal(statusFromHistory({ status: { messages: [['execution_error', {}]] } }), 'failed');
});