feat(scan): whiten receipt backgrounds and embed OCR in PDFs

This commit is contained in:
2026-09-24 17:41:30 +02:00
parent b9cfdbe29e
commit a65bd72d74
26 changed files with 572 additions and 76 deletions

View File

@@ -4,7 +4,7 @@ const fs = require('node:fs')
const vm = require('node:vm')
const vue = require('vue')
async function setup(getJob, scanData = {}, agents = [{ id: 'agent', active: true, capabilities: { scan: true }, scannerNames: ['fujitsu:ScanSnap iX1600:test'] }]) {
async function setup(getJob, scanData = {}, agents = [{ id: 'agent', active: true, capabilities: { scan: true, ocr: true, backgroundCleanup: true }, scannerNames: ['fujitsu:ScanSnap iX1600:test'] }]) {
const notices = []
const requests = []
let unmount
@@ -38,6 +38,9 @@ test('duplex scanning continues past the former three-minute polling limit', asy
const body = ui.requests.find(request => request.url === '/api/scan-jobs').options.body
assert.equal(body.settings.source, 'ADF Duplex')
assert.equal(body.settings.paperSize, 'A4')
assert.equal(body.settings.ocr, true)
assert.equal(body.settings.ocrLanguage, 'deu+eng')
assert.equal(body.settings.backgroundCleanup, true)
assert.equal(body.target.folder, 'folder-1')
})
@@ -72,7 +75,7 @@ test('iX1600 preset resets image settings and normalizes the output filename to
})
test('setup test scan uses the requested agent even when another agent is first', async () => {
const agents = ['first', 'configured'].map(id => ({ id, active: true, capabilities: { scan: true }, scannerNames: ['scanner-' + id] }))
const agents = ['first', 'configured'].map(id => ({ id, active: true, capabilities: { scan: true, ocr: true, backgroundCleanup: true }, scannerNames: ['scanner-' + id] }))
const ui = await setup(() => ({ job: { status: 'completed' } }), { agentId: 'configured' }, agents)
await ui.run('startScan()')
assert.equal(ui.requests.find(request => request.url === '/api/scan-jobs').options.body.agentId, 'configured')
@@ -83,3 +86,10 @@ test('an unavailable setup agent never silently scans with another device', asyn
await ui.run('startScan()')
assert.equal(ui.requests.filter(request => request.url === '/api/scan-jobs').length, 0)
})
test('an old agent cannot silently produce an image-only PDF when OCR was requested', async () => {
const ui = await setup(() => ({}), {}, [{ id: 'old', active: true, capabilities: { scan: true }, scannerNames: ['scanner'] }])
await ui.run('startScan()')
assert.equal(ui.requests.filter(request => request.url === '/api/scan-jobs').length, 0)
assert.equal(ui.notices[0].title, 'Agent aktualisieren')
})