Allow undated reconstructed events

This commit is contained in:
2026-08-14 19:57:22 +02:00
parent 703b9652c9
commit d99deb3c06
10 changed files with 60 additions and 17 deletions
+15
View File
@@ -140,6 +140,21 @@ suite('level persistence API', () => {
metadata: { witness: 'Integration test', confidence: 'high' },
})
const undatedState = structuredClone(afterMetadataSave)
const undatedEvent = undatedState.evidence.find(exhibit => exhibit.id === eventId)!
delete undatedEvent.eventDate
const undatedSave = await fetch(`${baseUrl}/api/levels/${state.id}?edit=1`, {
method: 'PUT', headers: { 'content-type': 'application/json' }, body: JSON.stringify(undatedState),
})
expect(undatedSave.ok).toBe(true)
const loadedUndated = await (await fetch(`${baseUrl}/api/levels/${state.id}?edit=1`)).json() as CaseState
expect(loadedUndated.evidence.find(exhibit => exhibit.id === eventId)?.eventDate).toBeUndefined()
expect((await appPool.query<{ occurred_at: Date | null }>('SELECT occurred_at FROM osint.event_exhibits WHERE exhibit_id=$1', [eventId])).rows[0].occurred_at).toBeNull()
loadedUndated.evidence.find(exhibit => exhibit.id === eventId)!.eventDate = '2021-04-18T14:30:00Z'
expect((await fetch(`${baseUrl}/api/levels/${state.id}?edit=1`, {
method: 'PUT', headers: { 'content-type': 'application/json' }, body: JSON.stringify(loadedUndated),
})).ok).toBe(true)
const playerState = await (await fetch(`${baseUrl}/api/levels/${state.id}`)).json() as CaseState
expect(playerState.brief.concepts.every(concept => concept.expectedPartyKind === undefined)).toBe(true)
const personPartyId = randomUUID()