Files
bindery/tests/js/revisions.test.mjs
tim 2f4271314b 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.
2026-09-27 23:38:28 +02:00

25 lines
1.2 KiB
JavaScript

import assert from 'node:assert/strict';
import { test } from 'node:test';
import { Element, find, install, nodes, server, settle } from './flow-helpers.mjs';
install();
const { chapterPage } = await import('../../bindery/static/js/chapter.js');
test('the revision in the book and the newest revision have no Delete button', async (t) => {
const backend = server(t);
backend.on('GET', 'jobs', []);
backend.on('GET', 'chapters/2/diff?', {
chapter: { id: 2, title: 'One', url: 'https://example.com/c/1', current_rev: 1 }, story_title: 'Story',
a: 1, b: 3, identical: false, html: '', changed: 1, added: 0, removed: 0,
revisions: [{ rev: 1, size: 100 }, { rev: 2, size: 100 }, { rev: 3, size: 100 }],
});
const main = new Element('main');
const cleanup = chapterPage(main, { storyId: '1', chapterId: '2' });
await settle();
cleanup?.();
const rows = nodes(main).filter((el) => el.tagName === 'tr').slice(1);
const badges = rows.map((row) => nodes(row.children[0]).filter((el) => el.tagName === 'span').map((el) => el.textContent));
assert.deepEqual(badges, [['in book'], [], ['newest']]);
assert.deepEqual(rows.map((row) => Boolean(find(row, 'button', 'Delete'))), [false, true, false]);
});