Files
ComfyUiPortalNext/server.test.js
T
chris.dumas a3ce474996
Test, build, and deploy ComfyUI Jobs / test-build (push) Failing after 25s
Test, build, and deploy ComfyUI Jobs / deploy (push) Skipped
Test, build, and deploy ComfyUI Jobs / browser-test (push) Skipped
Test, build, and deploy ComfyUI Jobs / qa-gate (push) Successful in 4s
Fix portal assets and QA action authentication
2026-10-26 14:43:42 +00:00

28 lines
1.9 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);
t.after(() => server.close());
await new Promise((resolve) => server.once('listening', resolve));
const port = server.address().port;
const index = fs.readFileSync(path.join(__dirname, 'frontend', 'dist', 'browser', 'index.html'), 'utf8');
const asset = index.match(/src="([^"]+\.js)"/)?.[1];
assert.ok(asset, 'the built frontend should reference a JavaScript asset');
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');
});