Add the web interface
Plain HTML, CSS and JavaScript modules, with no build step. Hash routes and relative URLs make it work under any path. The job list is polled: every 2 seconds while a job runs, and less often otherwise.
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { test } from 'node:test';
|
||||
import { find, install, server, settle } from './flow-helpers.mjs';
|
||||
|
||||
const ui = install();
|
||||
const { api, setUnauthorizedHandler } = await import('../../bindery/static/js/lib.js');
|
||||
const { stopPolling } = await import('../../bindery/static/js/jobs.js');
|
||||
|
||||
// The proxy login page has no form to retry from, and a fetch keeps the proxy's own session
|
||||
// cookie, so only a full page load lets the proxy step in again.
|
||||
test('a 401 while logged in through the proxy reloads the page', async (t) => {
|
||||
t.after(() => {
|
||||
stopPolling();
|
||||
setUnauthorizedHandler(() => {});
|
||||
});
|
||||
const backend = server(t);
|
||||
backend.on('GET', 'auth/check', { authenticated: true, mode: 'proxy', user: 'alice' });
|
||||
backend.on('GET', 'config', { metadata_fields: {}, mode_labels: {}, library_available: false });
|
||||
backend.on('GET', 'jobs', []);
|
||||
backend.on('GET', 'stories', []);
|
||||
backend.on('GET', 'expired', { error: 'Session ended' }, 401);
|
||||
await import('../../bindery/static/js/main.js');
|
||||
await settle();
|
||||
assert.match(ui.app.textContent, /alice/);
|
||||
let reloaded = 0;
|
||||
window.location.reload = () => reloaded++;
|
||||
await assert.rejects(api('expired'), /Session ended/);
|
||||
await settle();
|
||||
assert.equal(reloaded, 1);
|
||||
assert.equal(backend.sent('GET', 'auth/check').length, 1);
|
||||
});
|
||||
Reference in New Issue
Block a user