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

@@ -55,3 +55,30 @@ test("unknown agents cannot receive setup credentials", async (t) => {
assert.equal(response.statusCode, 404)
assert.equal(f.updates.length, 0)
})
test("OCR and background cleanup require an agent that supports the requested processing", async t => {
const app = Fastify()
t.after(() => app.close())
const jobs: any[] = []
let capabilities: Record<string, boolean> = { scan: true }
app.addHook("onRequest", async request => { request.user = { is_admin: true, tenant_id: 1 } as any })
app.decorate("db", {
select: () => ({ from: () => ({ where: () => ({ limit: async () => [{ id, active: true, scanDefaults: {}, capabilities }] }) }) }),
insert: () => ({ values: (data: any) => ({ returning: async () => { jobs.push(data); return [{ id: "job", ...data }] } }) }),
})
await app.register(routes)
for (const settings of [{ ocr: true }, { ocr: "true" }, { backgroundCleanup: true }]) {
const response = await app.inject({ method: "POST", url: "/scan-jobs", payload: { agentId: id, settings } })
assert.equal(response.statusCode, 409)
assert.equal(jobs.length, 0)
}
capabilities = { scan: true, ocr: true, backgroundCleanup: true }
const response = await app.inject({
method: "POST", url: "/scan-jobs",
payload: { agentId: id, settings: { ocr: true, ocrLanguage: "deu+eng", backgroundCleanup: true }, target: { folder: null, type: null } },
})
assert.equal(response.statusCode, 200)
assert.equal(jobs.length, 1)
assert.equal(jobs[0].settings.ocr, true)
assert.equal(jobs[0].target.type, null)
})