feat(app): export and import through @faunosteo/pdf — snapshot, archived branding and labels, browser rasterizer, imported archive kept in session, explicit rebase with messages; legacy PDF modules removed
This commit is contained in:
1 parent
20dafc0b00
commit
9bd5173a9c
43 files changed
+1492
-1989
No files matched your search
@@ -1,14 +1,19 @@
|
||||
/**
|
||||
* The archive check tool (scripts/compare-reports.ts) on the frozen v2 PDF,
|
||||
* on a synthetic v2 report with removed and unknown items, and on a v3 report.
|
||||
* on a synthetic v2 report with removed and unknown items, on a v3 report
|
||||
* and on a Step 6 envelope (archive header line).
|
||||
*/
|
||||
import { describe, it, expect, beforeAll } from 'vitest'
|
||||
import { PDFDocument } from 'pdf-lib'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { dirname, resolve } from 'node:path'
|
||||
import { readReportDocument, type ReportV2 } from '@faunosteo/domain'
|
||||
import { readAttachedDocument } from '@/pdf/attachment'
|
||||
import {
|
||||
readArchiveDocument,
|
||||
readReportDocument,
|
||||
type ReportV2,
|
||||
} from '@faunosteo/domain'
|
||||
import { readAttachedDocument } from '@faunosteo/pdf'
|
||||
import type { SheetIndex } from '@/services/sheetIndex'
|
||||
import {
|
||||
compareReport,
|
||||
@@ -18,7 +23,7 @@ import {
|
||||
renderSummary,
|
||||
UNRESOLVED,
|
||||
} from '../../scripts/compare/report'
|
||||
import { loadTestSheet, minimalReport } from '../helpers/sheet'
|
||||
import { archiveEnvelope, loadTestSheet, minimalReport } from '../helpers/sheet'
|
||||
|
||||
const HERE = dirname(fileURLToPath(import.meta.url))
|
||||
const OPTS = { locale: 'fr' as const, full: false }
|
||||
@@ -32,9 +37,8 @@ function minimalV2(): ReportV2 {
|
||||
}
|
||||
|
||||
function compareRaw(raw: unknown, full = false) {
|
||||
const outcome = readReportDocument(raw, sheet.sheet.migrationMap)
|
||||
const migrated = (raw as { version: number }).version !== 3
|
||||
return compareReport(raw, outcome, migrated, sheet, { ...OPTS, full })
|
||||
const outcome = readArchiveDocument(raw, sheet.sheet.migrationMap)
|
||||
return compareReport(raw, outcome, sheet, { ...OPTS, full })
|
||||
}
|
||||
|
||||
beforeAll(async () => {
|
||||
@@ -165,6 +169,35 @@ describe('compareReport on unresolved items', () => {
|
||||
expect(c.counts.unresolvedFindings).toBe(1)
|
||||
})
|
||||
|
||||
it('prints the archive line of an envelope: snapshot kept, or rejected with its reason', () => {
|
||||
const envelope = archiveEnvelope(
|
||||
sheet,
|
||||
minimalReport(sheet, {
|
||||
observations: [
|
||||
{
|
||||
id: 'o-env',
|
||||
zones: [{ annotationId: 'hip', viewId: 'main', side: 'left' }],
|
||||
findings: [],
|
||||
freeTextFindings: [],
|
||||
comment: '',
|
||||
},
|
||||
],
|
||||
}),
|
||||
)
|
||||
const kept = compareRaw(envelope)
|
||||
expect(kept.source).toBe('v3')
|
||||
expect(kept.header).toContain('archive v1 (snapshot kept)')
|
||||
const text = renderComparison('env.pdf', kept).join('\n')
|
||||
expect(text).toContain('hip@main left "Hanche (coxo-fémorale)"')
|
||||
const rejected = compareRaw({ ...envelope, envelopeVersion: 2 })
|
||||
expect(rejected.header).toContain(
|
||||
'archive v1 (snapshot rejected: unsupported_envelope)',
|
||||
)
|
||||
expect(compareRaw(envelope.report).header).not.toContain(
|
||||
'archive v1 (snapshot kept)',
|
||||
)
|
||||
})
|
||||
|
||||
it('warns when a v3 report was written on another sheet document', () => {
|
||||
const report = minimalReport(sheet, {
|
||||
sheet: { ...sheet.sheet.ref, documentSha256: 'b'.repeat(64) },
|
||||
|
||||
Reference in new issue
Block a user