Add drag-to-trash exhibit disposal
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
||||
MIN_BOARD_ZOOM,
|
||||
clampBoardZoom,
|
||||
containedIds,
|
||||
discardExhibit,
|
||||
folderIsOpen,
|
||||
moveBoardPoint,
|
||||
nextOpenBoardPosition,
|
||||
@@ -185,3 +186,27 @@ describe('folder domain behavior', () => {
|
||||
expect(normalized.relations).toHaveLength(1)
|
||||
})
|
||||
})
|
||||
|
||||
describe('exhibit disposal', () => {
|
||||
it('removes an exhibit and every graph reference while retaining source documents', () => {
|
||||
const note = { ...folder, id: 'note-1', type: 'note' as const, title: 'Working note' }
|
||||
const event = { ...folder, id: 'event-1', type: 'event' as const, supportingEvidenceIds: [note.id, 'doc-1'] }
|
||||
const party = { ...folder, id: 'party-1', type: 'party' as const, relatedEvidenceIds: [note.id] }
|
||||
const discarded = discardExhibit({
|
||||
...state,
|
||||
documents: [{ id: 'doc-1', title: 'Source', kind: 'TEXT', date: '', body: [], regions: [], fileType: 'text', metadata: {} }],
|
||||
evidence: [folder, note, event, party],
|
||||
relations: [{ id: 'nested', fromWidgetId: folder.id, toWidgetId: note.id, type: 'contains' }],
|
||||
connections: [{ id: 'thread', fromEvidenceId: note.id, toEvidenceId: party.id }],
|
||||
brief: { body: '', concepts: [{ id: 'concept-1', label: 'Unknown', context: '', resolvedPartyExhibitId: note.id }] },
|
||||
}, note.id)
|
||||
|
||||
expect(discarded.documents).toHaveLength(1)
|
||||
expect(discarded.evidence.map(exhibit => exhibit.id)).not.toContain(note.id)
|
||||
expect(discarded.relations).toEqual([])
|
||||
expect(discarded.connections).toEqual([])
|
||||
expect(discarded.evidence.find(exhibit => exhibit.id === event.id)?.supportingEvidenceIds).toEqual(['doc-1'])
|
||||
expect(discarded.evidence.find(exhibit => exhibit.id === party.id)?.relatedEvidenceIds).toEqual([])
|
||||
expect(discarded.brief.concepts[0].resolvedPartyExhibitId).toBeUndefined()
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user