Files
ComfyUiPortalNext/server.test.js
T
chris.dumas 8de0f8d7f0
Test, build, and deploy ComfyUI Jobs / deploy (push) Successful in 15s
Test, build, and deploy ComfyUI Jobs / test-build (push) Successful in 4m43s
Test, build, and deploy ComfyUI Jobs / browser-test (push) Successful in 1m35s
Test, build, and deploy ComfyUI Jobs / qa-gate (push) Successful in 4s
Make static asset regression test build independent
2026-10-26 14:45:00 +00:00

30 lines
2.0 KiB
JavaScript

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');
test('serves frontend assets before authentication redirects', async (t) => {
const server = app.listen(0);
const browserDir = path.join(__dirname, 'frontend', 'dist', 'browser');
const asset = '__qa-static-asset.js';
fs.mkdirSync(browserDir, { recursive: true });
fs.writeFileSync(path.join(browserDir, asset), 'window.__qaStaticAsset = true;\n');
t.after(() => server.close());
t.after(() => fs.rmSync(path.join(browserDir, asset), { force: true }));
await new Promise((resolve) => server.once('listening', resolve));
const port = server.address().port;
const response = await fetch(`http://127.0.0.1:${port}/${asset}`);
assert.equal(response.status, 200);
assert.match(response.headers.get('content-type') || '', /javascript/);
});
test('maps completed ComfyUI history into a read-only job summary', () => {
const job = jobFromHistory('abc123', { prompt: [1, 'abc123', { '7': { class_type: 'CheckpointLoaderSimple', inputs: { ckpt_name: 'portrait.safetensors' } } }, { title: 'Portrait' }], status: { completed: true, messages: [['execution_start', { timestamp: 1000 }], ['execution_success', { timestamp: 3250 }]] }, outputs: { '7': { images: [{ filename: 'result.png', subfolder: '', type: 'output' }] } } });
assert.deepEqual(job, { promptId: 'abc123', title: 'Portrait', status: 'completed', queuedAt: 1000, completedAt: 3250, durationMs: 2250, outputCount: 1, assets: [{ filename: 'result.png', subfolder: '', type: 'image', url: '/api/assets?filename=result.png&subfolder=&type=output' }], models: [{ nodeId: '7', type: 'CheckpointLoaderSimple', name: 'portrait.safetensors' }], progress: null });
});
test('classifies failed history without exposing mutation paths', () => {
assert.equal(statusFromHistory({ status: { messages: [['execution_error', {}]] } }), 'failed');
});