Fix portal assets and QA action authentication
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
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
This commit is contained in:
@@ -180,7 +180,7 @@ jobs:
|
|||||||
- name: Track browser failures in Gitea
|
- name: Track browser failures in Gitea
|
||||||
if: always()
|
if: always()
|
||||||
env:
|
env:
|
||||||
GITEA_API_TOKEN: ${{ secrets.COMFYUI_PORTAL_ISSUE_TOKEN }}
|
GITEA_API_TOKEN: ${{ github.token }}
|
||||||
GITEA_REPOSITORY: ${{ gitea.repository }}
|
GITEA_REPOSITORY: ${{ gitea.repository }}
|
||||||
GITEA_RUN_ID: ${{ gitea.run_id }}
|
GITEA_RUN_ID: ${{ gitea.run_id }}
|
||||||
GITEA_SHA: ${{ gitea.sha }}
|
GITEA_SHA: ${{ gitea.sha }}
|
||||||
@@ -203,6 +203,6 @@ jobs:
|
|||||||
github-server-url: https://git.dumas.ddns.net
|
github-server-url: https://git.dumas.ddns.net
|
||||||
- name: Check automated QA blockers
|
- name: Check automated QA blockers
|
||||||
env:
|
env:
|
||||||
GITEA_API_TOKEN: ${{ secrets.COMFYUI_PORTAL_ISSUE_TOKEN }}
|
GITEA_API_TOKEN: ${{ github.token }}
|
||||||
GITEA_REPOSITORY: ${{ gitea.repository }}
|
GITEA_REPOSITORY: ${{ gitea.repository }}
|
||||||
run: npm run qa:gate
|
run: npm run qa:gate
|
||||||
|
|||||||
@@ -119,8 +119,8 @@ app.post('/api/comfy/switch-version', async (req, res) => { const user = require
|
|||||||
app.get('/api/jobs/:promptId', async (req, res) => { if (!requireUser(req, res)) return; try { const history = await comfyJson(`/history/${encodeURIComponent(req.params.promptId)}`); const entry = history?.[req.params.promptId] || history; if (!entry) return res.status(404).json({ error: 'Job not found' }); res.json({ job: jobFromHistory(req.params.promptId, entry) }); } catch (error) { res.status(502).json({ error: error.message || 'Unable to read ComfyUI job' }); } });
|
app.get('/api/jobs/:promptId', async (req, res) => { if (!requireUser(req, res)) return; try { const history = await comfyJson(`/history/${encodeURIComponent(req.params.promptId)}`); const entry = history?.[req.params.promptId] || history; if (!entry) return res.status(404).json({ error: 'Job not found' }); res.json({ job: jobFromHistory(req.params.promptId, entry) }); } catch (error) { res.status(502).json({ error: error.message || 'Unable to read ComfyUI job' }); } });
|
||||||
app.get('/api/assets/meta', async (req, res) => { if (!requireUser(req, res)) return; const filename = String(req.query.filename || ''); const subfolder = String(req.query.subfolder || ''); const type = String(req.query.type || 'output'); if (!filename || !['output', 'input', 'temp'].includes(type) || filename.includes('..') || subfolder.includes('..')) return res.status(400).json({ error: 'Invalid asset reference' }); try { const response = await fetch(comfyUrl(`/view?filename=${encodeURIComponent(filename)}&subfolder=${encodeURIComponent(subfolder)}&type=${encodeURIComponent(type)}`)); if (!response.ok) return res.status(response.status).json({ error: 'Asset unavailable' }); const buffer = Buffer.from(await response.arrayBuffer()); let width = null; let height = null; try { const image = await sharp(buffer).metadata(); width = image.width || null; height = image.height || null; } catch { /* Video metadata is not available from sharp. */ } res.json({ width, height, sizeBytes: buffer.length }); } catch (error) { res.status(502).json({ error: error.message || 'Unable to read asset metadata' }); } });
|
app.get('/api/assets/meta', async (req, res) => { if (!requireUser(req, res)) return; const filename = String(req.query.filename || ''); const subfolder = String(req.query.subfolder || ''); const type = String(req.query.type || 'output'); if (!filename || !['output', 'input', 'temp'].includes(type) || filename.includes('..') || subfolder.includes('..')) return res.status(400).json({ error: 'Invalid asset reference' }); try { const response = await fetch(comfyUrl(`/view?filename=${encodeURIComponent(filename)}&subfolder=${encodeURIComponent(subfolder)}&type=${encodeURIComponent(type)}`)); if (!response.ok) return res.status(response.status).json({ error: 'Asset unavailable' }); const buffer = Buffer.from(await response.arrayBuffer()); let width = null; let height = null; try { const image = await sharp(buffer).metadata(); width = image.width || null; height = image.height || null; } catch { /* Video metadata is not available from sharp. */ } res.json({ width, height, sizeBytes: buffer.length }); } catch (error) { res.status(502).json({ error: error.message || 'Unable to read asset metadata' }); } });
|
||||||
app.get('/api/assets', async (req, res) => { if (!requireUser(req, res)) return; const filename = String(req.query.filename || ''); const subfolder = String(req.query.subfolder || ''); const type = String(req.query.type || 'output'); if (!filename || !['output', 'input', 'temp'].includes(type) || filename.includes('..') || subfolder.includes('..')) return res.status(400).json({ error: 'Invalid asset reference' }); try { const response = await fetch(comfyUrl(`/view?filename=${encodeURIComponent(filename)}&subfolder=${encodeURIComponent(subfolder)}&type=${encodeURIComponent(type)}`)); if (!response.ok) return res.status(response.status).send('Asset unavailable'); res.setHeader('Content-Type', response.headers.get('content-type') || 'application/octet-stream'); res.setHeader('Content-Disposition', 'inline'); res.setHeader('Cache-Control', 'private, max-age=300'); res.send(Buffer.from(await response.arrayBuffer())); } catch (error) { res.status(502).json({ error: error.message || 'Unable to read ComfyUI asset' }); } });
|
app.get('/api/assets', async (req, res) => { if (!requireUser(req, res)) return; const filename = String(req.query.filename || ''); const subfolder = String(req.query.subfolder || ''); const type = String(req.query.type || 'output'); if (!filename || !['output', 'input', 'temp'].includes(type) || filename.includes('..') || subfolder.includes('..')) return res.status(400).json({ error: 'Invalid asset reference' }); try { const response = await fetch(comfyUrl(`/view?filename=${encodeURIComponent(filename)}&subfolder=${encodeURIComponent(subfolder)}&type=${encodeURIComponent(type)}`)); if (!response.ok) return res.status(response.status).send('Asset unavailable'); res.setHeader('Content-Type', response.headers.get('content-type') || 'application/octet-stream'); res.setHeader('Content-Disposition', 'inline'); res.setHeader('Cache-Control', 'private, max-age=300'); res.send(Buffer.from(await response.arrayBuffer())); } catch (error) { res.status(502).json({ error: error.message || 'Unable to read ComfyUI asset' }); } });
|
||||||
app.use((req, res, next) => { if (req.path.startsWith('/login') || req.path.startsWith('/api/')) return next(); if (!currentUser(req)) return res.redirect('/login'); next(); });
|
|
||||||
app.use(express.static(browserDir, { index: false }));
|
app.use(express.static(browserDir, { index: false }));
|
||||||
|
app.use((req, res, next) => { if (req.path.startsWith('/login') || req.path.startsWith('/api/')) return next(); if (!currentUser(req)) return res.redirect('/login'); next(); });
|
||||||
app.use((_req, res) => { if (!fs.existsSync(indexHtml)) return res.status(500).send('Build output missing.'); res.type('html').send(fs.readFileSync(indexHtml, 'utf8')); });
|
app.use((_req, res) => { if (!fs.existsSync(indexHtml)) return res.status(500).send('Build output missing.'); res.type('html').send(fs.readFileSync(indexHtml, 'utf8')); });
|
||||||
if (require.main === module) { startComfyProgressSocket(); app.listen(port, () => console.log(`ComfyUiPortal Next listening on ${port}`)); }
|
if (require.main === module) { startComfyProgressSocket(); app.listen(port, () => console.log(`ComfyUiPortal Next listening on ${port}`)); }
|
||||||
module.exports = { app, jobFromHistory, statusFromHistory };
|
module.exports = { app, jobFromHistory, statusFromHistory };
|
||||||
|
|||||||
+16
-1
@@ -1,6 +1,21 @@
|
|||||||
const test = require('node:test');
|
const test = require('node:test');
|
||||||
const assert = require('node:assert/strict');
|
const assert = require('node:assert/strict');
|
||||||
const { jobFromHistory, statusFromHistory } = require('./server');
|
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', () => {
|
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' }] } } });
|
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' }] } } });
|
||||||
|
|||||||
Reference in New Issue
Block a user