fix(f6.9): load PDF and image converters in production runtime
Android CI / RC / Android · lint, tests, debug APK, release compile (push) Successful in 3m16s
DH V2 CI / API · typecheck, tests, build (push) Successful in 31s
DH V2 CI / WEB · typecheck, build (push) Successful in 18s
Production dependency audit / API · production dependencies (push) Successful in 8s
Production dependency audit / WEB · production dependencies (push) Successful in 8s
DH V2 CI / Docker / scripts contract (push) Successful in 50s
Android CI / RC / Android · lint, tests, debug APK, release compile (push) Successful in 3m16s
DH V2 CI / API · typecheck, tests, build (push) Successful in 31s
DH V2 CI / WEB · typecheck, build (push) Successful in 18s
Production dependency audit / API · production dependencies (push) Successful in 8s
Production dependency audit / WEB · production dependencies (push) Successful in 8s
DH V2 CI / Docker / scripts contract (push) Successful in 50s
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { createHash } from 'node:crypto';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { existsSync, readFileSync } from 'node:fs';
|
||||
import { createRequire } from 'node:module';
|
||||
import { resolve } from 'node:path';
|
||||
import test from 'node:test';
|
||||
import { buildInspectionActPdf } from '../../src/inspection-reports/inspection-act-pdf-builder';
|
||||
@@ -70,3 +71,16 @@ test('F6.9 renders WebP field photographs in both documents without changing the
|
||||
assert.ok(word.buffer.includes(display));
|
||||
assert.ok(word.buffer.includes(Buffer.from(originalSha)));
|
||||
});
|
||||
|
||||
test('F6.9 built CommonJS runtime renders signed PDF and WebP evidence', async () => {
|
||||
const builtPdf = resolve(process.cwd(), 'dist/inspection-reports/inspection-act-pdf-builder.js');
|
||||
const builtImage = resolve(process.cwd(), 'dist/inspection-reports/inspection-document-images.js');
|
||||
if (!existsSync(builtPdf) || !existsSync(builtImage)) return;
|
||||
const requireCjs = createRequire(resolve(process.cwd(), 'package.json'));
|
||||
const runtimePdf = requireCjs(builtPdf) as { buildInspectionActPdf: typeof buildInspectionActPdf };
|
||||
const runtimeImage = requireCjs(builtImage) as { renderableInspectionImage: typeof renderableInspectionImage };
|
||||
const webp = await sharp(photo).webp().toBuffer();
|
||||
const rendered = await runtimeImage.renderableInspectionImage(webp);
|
||||
const pdf = await runtimePdf.buildInspectionActPdf(sealed, [{ ...evidence, buffer: rendered, sha256: digest(webp) }]);
|
||||
assert.ok(pdf.buffer.subarray(0, 8).equals(Buffer.from('%PDF-1.4')));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user