Files
faunosteo/apps/app/tests/helpers/findingsHost.tsx
T
bchanot abc781df52 feat(editor): references dialog over the finding, view mode
A modal Dialog replaces the citations side sheet; families open it too
(isCitable). The finding dialog shows only « Références citées » and
« X références », also at zero; its edit form no longer carries
reference_ids. A dirty form refusing « Aller à » or « Tout afficher »
closes the clean references dialog first.
2026-11-15 16:13:57 +01:00

56 lines
1.7 KiB
TypeScript

import { vi } from 'vitest'
import type { FindingLayer } from '@/editor/tabs'
import CitationsDialog from '@/components/editor/references/CitationsDialog'
import FindingsTab from '@/components/editor/tabs/FindingsTab'
import { findingLayerOf } from '@/editor/findingLayer'
import { citationsOfView } from '@/editor/navigation'
import { useEditorNavigation } from '@/editor/useEditorNavigation'
import { ReadOnlyContext } from '@/editor/editingContext'
/**
* Constats with the navigation that drives its dialog and the references dialog over it (what the
* workspace gives it), without the rest of the editor.
*/
export default function FindingsHost({
readOnly = false,
}: {
readOnly?: boolean
}) {
const nav = useEditorNavigation('findings')
return (
<ReadOnlyContext value={readOnly}>
<FindingsTab
readOnly={readOnly}
navigate={vi.fn()}
reloadSheet={vi.fn()}
layer={findingLayerOf(nav)}
/>
<CitationsDialog
citedBy={citationsOfView(nav.state)}
onClose={nav.closeCitations}
onShowAll={() => undefined}
navigate={nav.navigate}
returnFocus={nav.citationsTrigger}
/>
</ReadOnlyContext>
)
}
/** A layer that never opens: for a test that mounts Constats only to read its focus. */
export const testLayer: FindingLayer = {
view: null,
guards: {
register: () => undefined,
ask: () => ({ allowed: true }),
askAll: () => ({ allowed: true }),
holdLeave: () => undefined,
takeLeave: () => null,
},
open: () => undefined,
start: () => undefined,
close: () => true,
replace: () => undefined,
openCitations: () => undefined,
announce: () => undefined,
}