fix(supabase): confirmed uploads gate asset reads (hash claim), seeds-listed test, Dockerfile workspace manifests; importer declares every authored label, real in=out control

This commit is contained in:
bchanot committed 2026-10-09 00:50:36 +02:00
1 parent bbfb8d6203
commit dee4ce43d9
28 files changed
+511 -87

No files matched your search

+20 -1
View File
@@ -1,3 +1,4 @@
import type { FindingNodeInput } from '@faunosteo/domain'
import { EQUINE_SOURCE_PATHS, type ImportResult } from '../src'
import { legacyAnnoIds, runImport } from './helpers'
@@ -51,9 +52,27 @@ describe('equine import volumes', () => {
expect(bilateral).toHaveLength(9)
})
it('keeps 26 zones, 792 nodes, 612 leaves, 41 vet referrals', () => {
it('writes 792 nodes, 612 leaves, 41 vet referrals in the document', () => {
const counts = { nodes: 0, leaves: 0, vet: 0 }
const walk = (nodes: readonly FindingNodeInput[]): void => {
for (const node of nodes) {
counts.nodes += 1
if (!node.children?.length) counts.leaves += 1
if (node.requires_vet_referral === true) counts.vet += 1
walk(node.children ?? [])
}
}
for (const zone of result.document.finding_zones) {
counts.nodes += zone.categories.length
for (const category of zone.categories) walk(category.children)
}
expect(counts).toEqual({ nodes: 792, leaves: 612, vet: 41 })
})
it('reports the input side from the sources: 27 ids, 26 zones, 792/612/41', () => {
expect(result.document.finding_zones).toHaveLength(26)
expect(result.stats).toMatchObject({
legacyAnnotations: 27,
findingZones: 26,
nodes: 792,
leaves: 612,
@@ -0,0 +1,46 @@
import { renderSeedSql, DOCUMENT_DOLLAR_TAG } from '../src'
import { mapAnnotation } from '../src/legacy/annotations'
import { assertNothingDropped } from '../src/legacy/catalog'
import { parseAnnotatedSvg } from '../src/legacy/svg'
import { runImport } from './helpers'
/** Guards that never fire on today's data, proven on synthetic inputs. */
const SVG_WITHOUT_EN = `<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10">
<circle cx="1" cy="2" r="3" data-anno-id="point-x"
data-anno-name-fr="Garrot" data-anno-category="os"/>
</svg>`
describe('importer guards', () => {
it('throws when a zone loses a vet referral', () => {
const before = { nodes: 10, leaves: 7, vetReferrals: 2 }
const after = { nodes: 10, leaves: 7, vetReferrals: 1 }
expect(() => assertNothingDropped('hip', before, after)).toThrow(
'zone hip: vetReferrals 2 in, 1 out',
)
expect(() => assertNothingDropped('hip', before, before)).not.toThrow()
})
it('copies FR into EN when data-anno-name-en is absent, and says so', () => {
const [legacy] = parseAnnotatedSvg(SVG_WITHOUT_EN, 'x.svg').annotations
const mapped = mapAnnotation(legacy!, {
viewId: 'main',
fileName: 'x.svg',
zoneByNames: new Map(),
})
expect(mapped.annotation.name).toEqual({ fr: 'Garrot', en: 'Garrot' })
expect(mapped.anomalies.map((a) => [a.code, a.level])).toContainEqual([
'annotation.name_en.missing',
'a_valider',
])
})
it('refuses a document that contains the dollar-quote tag', async () => {
const result = await runImport()
const documentJson = JSON.stringify({ note: DOCUMENT_DOLLAR_TAG })
expect(() => renderSeedSql({ result, documentJson })).toThrow(
DOCUMENT_DOLLAR_TAG,
)
})
})
@@ -107,3 +107,22 @@ describe('equine import special cases', () => {
expect(Object.keys(leaf).sort()).toEqual(['id', 'name'])
})
})
describe('importer-authored labels', () => {
it('declares every label written without a source', () => {
const subjects = result.anomalies
.filter((a) => a.code === 'label.authored' && a.level === 'a_valider')
.map((a) => a.subject)
expect(subjects).toEqual([
'name',
'description',
'views.main',
'views.head',
'vertebral_config.C',
'vertebral_config.T',
'vertebral_config.L',
'vertebral_config.S',
'vertebral_config.Cd',
])
})
})