Mirror and zoom the scan preview, strengthen barcode decoding, save failed captures

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Fable 5.2 committed 2026-11-18 10:28:45 -07:00
1 parent b5defb4e4f
commit 308c0e1ed3
10 files changed
+510 -152

No files matched your search

+27
View File
@@ -222,3 +222,30 @@ test('retry forgets the book\'s cached source responses', async () => {
assert.equal(db.cache.get('ol-data:9780201835953'), 'body');
assert.equal(db.cache.get('loc-title:Other|X'), 'body');
});
test('debug capture: saves a PNG, keeps the newest 30, refuses other bodies', async () => {
const { mkdtempSync, readdirSync, rmSync } = await import('node:fs');
const { tmpdir } = await import('node:os');
const { join } = await import('node:path');
const dir = mkdtempSync(join(tmpdir(), 'captures-'));
try {
const db = openDb(':memory:');
const resolver = { resolve: async () => found, search: async () => [] };
const jobs = createJobs({ db, resolver, onChange: () => {}, retryDelaysMs: [0], log: () => {} });
const app = createApp({
db, jobs, resolver, capturesDir: join(dir, 'captures'),
renderCardsPdf: async () => new Uint8Array(), renderCalibrationPdf: async () => new Uint8Array(),
classNames: () => ({ className: '', subclassName: '' }),
});
const png: Uint8Array<ArrayBuffer> = new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 1, 2, 3]);
const post = (b: Uint8Array<ArrayBuffer>) => app.request('/api/debug/capture', { method: 'POST', body: b });
const r = await post(png);
assert.equal(r.status, 200);
const j = await r.json() as { saved: string };
assert.match(j.saved, /^capture-.*\.png$/);
assert.equal((await post(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9]))).status, 400);
assert.equal((await post(new Uint8Array(8 * 1024 * 1024 + 1))).status, 413);
for (let i = 0; i < 35; i++) await post(png);
assert.equal(readdirSync(join(dir, 'captures')).length, 30);
} finally { rmSync(dir, { recursive: true, force: true }); }
});