feat(editor): kept-mounted tabs, sections and references panel
Each visited tab, Annotations section and the references panel stay
mounted in a KeptPlace (hidden, nested visibility). Composed canvases
detach while hidden. One JSON.parse per document text. Focus requests
reach only their owning place.
Rewritten assertions (R-24):
- editor-route.test.tsx:127: annotations testid toBeNull -> not.toBeVisible
- editor-sections.test.tsx: place('annotations.drawing') toBeNull -> not.toBeVisible
- editor-journey.spec.ts:311: page-wide getByLabel('Nom (FR)') -> scoped to place 'general'
- editor-tabs-lists.test.tsx: ReferencesPanel `open` prop dropped (the wrapper hides it)
- editor-annotations-tab, editor-focus-request, editor-sections tests: props gain `visited`
No assertion removed.
This commit is contained in:
1 parent
ca184da4d9
commit
6689827a8d
18 files changed
+847
-81
No files matched your search
@@ -15,6 +15,7 @@ import {
|
|||||||
INKSCAPE_EXPORT,
|
INKSCAPE_EXPORT,
|
||||||
openDraft,
|
openDraft,
|
||||||
openSection,
|
openSection,
|
||||||
|
place,
|
||||||
saveDraft,
|
saveDraft,
|
||||||
secondSession,
|
secondSession,
|
||||||
selectTab,
|
selectTab,
|
||||||
@@ -308,9 +309,10 @@ test.describe('editor journey (owner trial steps)', () => {
|
|||||||
|
|
||||||
// 4.5: a rename left unsaved survives a reload through the recovery copy.
|
// 4.5: a rename left unsaved survives a reload through the recovery copy.
|
||||||
await selectTab(page, dict, 'general')
|
await selectTab(page, dict, 'general')
|
||||||
const name = page.getByLabel(dict['editor.general.name_fr'], {
|
const name = place(page, 'general').getByLabel(
|
||||||
exact: true,
|
dict['editor.general.name_fr'],
|
||||||
})
|
{ exact: true },
|
||||||
|
)
|
||||||
await commitText(name, `Chien révisé ${tag}`)
|
await commitText(name, `Chien révisé ${tag}`)
|
||||||
await reloadAndRestore(page, sheetId)
|
await reloadAndRestore(page, sheetId)
|
||||||
await saveDraft(page, dict, 2)
|
await saveDraft(page, dict, 2)
|
||||||
|
|||||||
@@ -0,0 +1,141 @@
|
|||||||
|
import { fr } from '@/i18n/fr'
|
||||||
|
import type { Page, TestInfo } from '@playwright/test'
|
||||||
|
import { expect, test } from '../support/browser'
|
||||||
|
import { dropLateReplays, routeToSandbox } from '../support/sandbox'
|
||||||
|
import {
|
||||||
|
backToDrawing,
|
||||||
|
closeReferences,
|
||||||
|
editorActor,
|
||||||
|
openEditor,
|
||||||
|
openReferences,
|
||||||
|
openSection,
|
||||||
|
place,
|
||||||
|
pointOf,
|
||||||
|
seedDraft,
|
||||||
|
selectTab,
|
||||||
|
shapeWith,
|
||||||
|
showDrawing,
|
||||||
|
} from '../support/editor'
|
||||||
|
|
||||||
|
// V1-2.6 U1 B2a: tabs, Annotations sections and the references panel stay mounted. What
|
||||||
|
// was typed, the canvas zoom and the focus survive a change of place; focus lands on a
|
||||||
|
// named element, never on `body`. happy-dom does not refuse focus on hidden elements, so
|
||||||
|
// the focus rules are checked here with `document.activeElement`.
|
||||||
|
|
||||||
|
const dict = fr
|
||||||
|
|
||||||
|
const isPhone = (info: TestInfo) => info.project.name === 'chromium-375'
|
||||||
|
|
||||||
|
async function open(page: Page) {
|
||||||
|
const actor = await editorActor('fr')
|
||||||
|
const free = {
|
||||||
|
...pointOf('anno-free', 'main', { cx: 120, cy: 120, r: 6 }, 'Point libre'),
|
||||||
|
finding_zone_id: null,
|
||||||
|
}
|
||||||
|
const seed = await seedDraft(actor, { shape: shapeWith(free) })
|
||||||
|
await openEditor(page, dict, actor, seed.sheetId)
|
||||||
|
return seed
|
||||||
|
}
|
||||||
|
|
||||||
|
const active = (page: Page) => page.locator(':focus')
|
||||||
|
const layerTransform = (page: Page) =>
|
||||||
|
page
|
||||||
|
.getByTestId('annotation-canvas')
|
||||||
|
.evaluate((box) => (box.firstElementChild as HTMLElement).style.transform)
|
||||||
|
|
||||||
|
test.describe('editor shell, kept places (B2a)', () => {
|
||||||
|
test.use({ locale: 'fr-FR', actionTimeout: 15_000 })
|
||||||
|
test.beforeEach(async ({ context }, info) => {
|
||||||
|
test.skip(isPhone(info), 'editing needs 1 024 px') // floor-guard: allow C16 editing needs >= 1024 px; phone read-only covered in editor-access
|
||||||
|
await routeToSandbox(context)
|
||||||
|
})
|
||||||
|
test.afterEach(async ({ context }) => {
|
||||||
|
await dropLateReplays(context)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('the category form text and the zoom survive tab and section changes', async ({
|
||||||
|
page,
|
||||||
|
}) => {
|
||||||
|
await open(page)
|
||||||
|
await openSection(page, dict, 'categories')
|
||||||
|
await page.locator('#category-new-fr').fill('Brouillon')
|
||||||
|
await selectTab(page, dict, 'general')
|
||||||
|
await expect(place(page, 'annotations.categories')).toHaveCount(0)
|
||||||
|
await selectTab(page, dict, 'annotations')
|
||||||
|
await expect(page.locator('#category-new-fr')).toHaveValue('Brouillon')
|
||||||
|
|
||||||
|
await backToDrawing(page, dict)
|
||||||
|
await page
|
||||||
|
.getByRole('button', { name: dict['catalogue.zoom.in'], exact: true })
|
||||||
|
.click()
|
||||||
|
const zoomed = await layerTransform(page)
|
||||||
|
expect(zoomed).not.toContain('scale(1)')
|
||||||
|
await selectTab(page, dict, 'findings')
|
||||||
|
await showDrawing(page, dict)
|
||||||
|
expect(await layerTransform(page)).toBe(zoomed)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('the references panel keeps its form text and no id repeats', async ({
|
||||||
|
page,
|
||||||
|
}) => {
|
||||||
|
await open(page)
|
||||||
|
await openReferences(page, dict)
|
||||||
|
await page.locator('#reference-new-citation').fill('Smith 1999')
|
||||||
|
await closeReferences(page, dict)
|
||||||
|
await openReferences(page, dict)
|
||||||
|
await expect(page.locator('#reference-new-citation')).toHaveValue(
|
||||||
|
'Smith 1999',
|
||||||
|
)
|
||||||
|
for (const tab of ['general', 'findings', 'verification']) {
|
||||||
|
await selectTab(page, dict, tab)
|
||||||
|
}
|
||||||
|
for (const section of ['views', 'categories', 'regions'] as const) {
|
||||||
|
await openSection(page, dict, section)
|
||||||
|
}
|
||||||
|
const repeated = await page.evaluate(() => {
|
||||||
|
const ids = [...document.querySelectorAll('[id]')].map((e) => e.id)
|
||||||
|
return ids.filter((id, i) => ids.indexOf(id) !== i)
|
||||||
|
})
|
||||||
|
expect(repeated).toEqual([])
|
||||||
|
})
|
||||||
|
|
||||||
|
test('focus lands on a named element after a tab click, « Retour au dessin » and « Aller à »', async ({
|
||||||
|
page,
|
||||||
|
}) => {
|
||||||
|
await open(page)
|
||||||
|
await selectTab(page, dict, 'findings')
|
||||||
|
await expect(active(page)).toHaveAttribute('id', 'editor-tab-findings')
|
||||||
|
|
||||||
|
await openSection(page, dict, 'categories')
|
||||||
|
await backToDrawing(page, dict)
|
||||||
|
await expect(active(page)).toHaveAttribute(
|
||||||
|
'data-section-entry',
|
||||||
|
'categories',
|
||||||
|
)
|
||||||
|
|
||||||
|
await selectTab(page, dict, 'verification')
|
||||||
|
await page
|
||||||
|
.getByRole('button', { name: 'Aller à Point libre' })
|
||||||
|
.first()
|
||||||
|
.click()
|
||||||
|
await expect(place(page, 'annotations.drawing')).toBeVisible()
|
||||||
|
await expect(active(page)).toHaveAttribute(
|
||||||
|
'data-properties-heading',
|
||||||
|
'true',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('arrowing back onto a tab keeps the focus on the tab', async ({
|
||||||
|
page,
|
||||||
|
}) => {
|
||||||
|
await open(page)
|
||||||
|
await selectTab(page, dict, 'annotations')
|
||||||
|
await page
|
||||||
|
.getByRole('tab', { name: dict['editor.tab.annotations'] })
|
||||||
|
.focus()
|
||||||
|
await page.keyboard.press('ArrowRight')
|
||||||
|
await expect(active(page)).toHaveAttribute('id', 'editor-tab-findings')
|
||||||
|
await page.keyboard.press('ArrowLeft')
|
||||||
|
await expect(active(page)).toHaveAttribute('id', 'editor-tab-annotations')
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||||
|
import { usePlaceVisible } from '@/components/editor/KeptPlace'
|
||||||
import Button from '@/components/ui/Button'
|
import Button from '@/components/ui/Button'
|
||||||
import Notice from '@/components/ui/Notice'
|
import Notice from '@/components/ui/Notice'
|
||||||
import { coreRuntime, useCoreStopped } from '@/core/runtime'
|
import { coreRuntime, useCoreStopped } from '@/core/runtime'
|
||||||
@@ -60,6 +61,7 @@ export default function CatalogueCanvas({
|
|||||||
const [attempt, setAttempt] = useState(0)
|
const [attempt, setAttempt] = useState(0)
|
||||||
const [failure, setFailure] = useState<CanvasFailure | null>(null)
|
const [failure, setFailure] = useState<CanvasFailure | null>(null)
|
||||||
const stopped = useCoreStopped()
|
const stopped = useCoreStopped()
|
||||||
|
const visible = usePlaceVisible()
|
||||||
const { framing, zoomIn, zoomOut, reset, swallowClick, handlers } = useFraming(
|
const { framing, zoomIn, zoomOut, reset, swallowClick, handlers } = useFraming(
|
||||||
viewport,
|
viewport,
|
||||||
viewId,
|
viewId,
|
||||||
@@ -74,17 +76,19 @@ export default function CatalogueCanvas({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const element = host.current
|
const element = host.current
|
||||||
if (!element) return
|
if (!element) return
|
||||||
|
// One composed copy of a view in the page (kept places): the ids repeat otherwise.
|
||||||
|
if (!visible) return element.replaceChildren()
|
||||||
const build = buildView(preview, viewId)
|
const build = buildView(preview, viewId)
|
||||||
setFailure(build.ok ? null : build.failure)
|
setFailure(build.ok ? null : build.failure)
|
||||||
element.replaceChildren(...(build.ok ? [build.svg] : []))
|
element.replaceChildren(...(build.ok ? [build.svg] : []))
|
||||||
}, [preview, viewId, attempt])
|
}, [preview, viewId, attempt, visible])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
host.current?.querySelectorAll<Element>(ANNOTATED).forEach((el) => {
|
host.current?.querySelectorAll<Element>(ANNOTATED).forEach((el) => {
|
||||||
if (el.getAttribute('data-anno-id') === selectedId) el.setAttribute('data-state', 'current')
|
if (el.getAttribute('data-anno-id') === selectedId) el.setAttribute('data-state', 'current')
|
||||||
else el.removeAttribute('data-state')
|
else el.removeAttribute('data-state')
|
||||||
})
|
})
|
||||||
}, [selectedId, preview, viewId, attempt])
|
}, [selectedId, preview, viewId, attempt, visible])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const element = host.current
|
const element = host.current
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import type { ComponentType } from 'react'
|
import type { ComponentType } from 'react'
|
||||||
|
import { ownedBy } from '@/editor/focusRequest'
|
||||||
import type { AnnotationSection } from '@/editor/navigation'
|
import type { AnnotationSection } from '@/editor/navigation'
|
||||||
import {
|
import {
|
||||||
panelDomId,
|
panelDomId,
|
||||||
@@ -6,6 +7,7 @@ import {
|
|||||||
type EditorTabId,
|
type EditorTabId,
|
||||||
} from '@/editor/tabs'
|
} from '@/editor/tabs'
|
||||||
import { useT } from '@/i18n/useT'
|
import { useT } from '@/i18n/useT'
|
||||||
|
import KeptPlace from './KeptPlace'
|
||||||
import AnnotationsTab from './tabs/AnnotationsTab'
|
import AnnotationsTab from './tabs/AnnotationsTab'
|
||||||
import FindingsTab from './tabs/FindingsTab'
|
import FindingsTab from './tabs/FindingsTab'
|
||||||
import GeneralTab from './tabs/GeneralTab'
|
import GeneralTab from './tabs/GeneralTab'
|
||||||
@@ -23,31 +25,55 @@ const BODIES: Record<
|
|||||||
/** What only the Annotations tab needs beyond the common place props. */
|
/** What only the Annotations tab needs beyond the common place props. */
|
||||||
export interface AnnotationNav {
|
export interface AnnotationNav {
|
||||||
section: AnnotationSection
|
section: AnnotationSection
|
||||||
|
/** The sections shown at least once: each stays mounted. */
|
||||||
|
visited: readonly AnnotationSection[]
|
||||||
onOpenSection: (section: AnnotationSection, opener: HTMLElement) => void
|
onOpenSection: (section: AnnotationSection, opener: HTMLElement) => void
|
||||||
onBack: () => void
|
onBack: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Props extends EditorPlaceProps {
|
interface Props extends EditorPlaceProps {
|
||||||
tab: EditorTabId
|
tab: EditorTabId
|
||||||
|
/** The tabs shown at least once: each stays mounted, hidden while another is shown. */
|
||||||
|
visited: readonly EditorTabId[]
|
||||||
annotations: AnnotationNav
|
annotations: AnnotationNav
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The panel of the active tab; a place unmounts when left (kept alive in Lot B2). */
|
function TabPanel({
|
||||||
export default function EditorTabBody({ tab, annotations, ...props }: Props) {
|
id,
|
||||||
|
active,
|
||||||
|
annotations,
|
||||||
|
...props
|
||||||
|
}: Omit<Props, 'tab' | 'visited'> & { id: EditorTabId; active: boolean }) {
|
||||||
const t = useT()
|
const t = useT()
|
||||||
const Body = tab === 'annotations' ? null : BODIES[tab]
|
const Body = id === 'annotations' ? null : BODIES[id]
|
||||||
return (
|
return (
|
||||||
<div
|
<KeptPlace
|
||||||
id={panelDomId(tab)}
|
name={Body ? id : undefined}
|
||||||
|
visible={active}
|
||||||
|
id={panelDomId(id)}
|
||||||
role="tabpanel"
|
role="tabpanel"
|
||||||
aria-label={t(`editor.tab.${tab}`)}
|
aria-label={t(`editor.tab.${id}`)}
|
||||||
data-place={Body ? tab : undefined}
|
|
||||||
>
|
>
|
||||||
{Body ? (
|
{Body ? (
|
||||||
<Body {...props} />
|
<Body {...props} focus={ownedBy(props.focus, id)} />
|
||||||
) : (
|
) : (
|
||||||
<AnnotationsTab {...props} {...annotations} />
|
<AnnotationsTab {...props} {...annotations} />
|
||||||
)}
|
)}
|
||||||
</div>
|
</KeptPlace>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The panels of the tabs shown so far: a tab mounts at its first visit and stays mounted,
|
||||||
|
* hidden while another is shown, so nothing typed or selected is lost on a tab change.
|
||||||
|
* A focus request reaches only the place its target names.
|
||||||
|
*/
|
||||||
|
export default function EditorTabBody({ tab, visited, ...props }: Props) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{visited.map((id) => (
|
||||||
|
<TabPanel key={id} id={id} active={id === tab} {...props} />
|
||||||
|
))}
|
||||||
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -4,11 +4,9 @@ import {
|
|||||||
AnnounceContext,
|
AnnounceContext,
|
||||||
FocusConsumedContext,
|
FocusConsumedContext,
|
||||||
ownedBy,
|
ownedBy,
|
||||||
type PlaceName,
|
|
||||||
} from '@/editor/focusRequest'
|
} from '@/editor/focusRequest'
|
||||||
import { saveFailureMessage } from '@/editor/messages'
|
import { saveFailureMessage } from '@/editor/messages'
|
||||||
import type { EditorMode } from '@/editor/mode'
|
import type { EditorMode } from '@/editor/mode'
|
||||||
import type { NavigationState } from '@/editor/navigation'
|
|
||||||
import { useEditorStore } from '@/editor/state/editorStore'
|
import { useEditorStore } from '@/editor/state/editorStore'
|
||||||
import { initialTab } from '@/editor/tabs'
|
import { initialTab } from '@/editor/tabs'
|
||||||
import { useEditorNavigation } from '@/editor/useEditorNavigation'
|
import { useEditorNavigation } from '@/editor/useEditorNavigation'
|
||||||
@@ -19,6 +17,7 @@ import CopyIssueNotice from './CopyIssueNotice'
|
|||||||
import DraftHeader from './DraftHeader'
|
import DraftHeader from './DraftHeader'
|
||||||
import EditorTabBody from './EditorTabBody'
|
import EditorTabBody from './EditorTabBody'
|
||||||
import EditorTabs from './EditorTabs'
|
import EditorTabs from './EditorTabs'
|
||||||
|
import KeptPlace from './KeptPlace'
|
||||||
import ModeNotice from './ModeNotice'
|
import ModeNotice from './ModeNotice'
|
||||||
import RecoveryNotice from './RecoveryNotice'
|
import RecoveryNotice from './RecoveryNotice'
|
||||||
import ReferencesPanel from './references/ReferencesPanel'
|
import ReferencesPanel from './references/ReferencesPanel'
|
||||||
@@ -48,11 +47,6 @@ function SaveFailureNotice() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The `data-place` the shown tab and section name. */
|
|
||||||
function shownPlace({ tab, section }: NavigationState): PlaceName {
|
|
||||||
return tab === 'annotations' ? `annotations.${section}` : tab
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The draft page once the version is ready: header, notices, tab row, the references
|
* The draft page once the version is ready: header, notices, tab row, the references
|
||||||
* panel and the shown place. Owns the navigation state, so the first tab is known at
|
* panel and the shown place. Owns the navigation state, so the first tab is known at
|
||||||
@@ -85,21 +79,24 @@ export default function EditorWorkspace(props: Props) {
|
|||||||
<FocusConsumedContext value={nav.consumed}>
|
<FocusConsumedContext value={nav.consumed}>
|
||||||
<AnnounceContext value={nav.announce}>
|
<AnnounceContext value={nav.announce}>
|
||||||
{state.referencesMounted && (
|
{state.referencesMounted && (
|
||||||
<ReferencesPanel
|
<KeptPlace name="references" visible={state.references.open}>
|
||||||
readOnly={readOnly}
|
<ReferencesPanel
|
||||||
focus={ownedBy(state.focus, 'references')}
|
readOnly={readOnly}
|
||||||
open={state.references.open}
|
focus={ownedBy(state.focus, 'references')}
|
||||||
onClose={nav.closeReferences}
|
onClose={nav.closeReferences}
|
||||||
/>
|
/>
|
||||||
|
</KeptPlace>
|
||||||
)}
|
)}
|
||||||
<EditorTabBody
|
<EditorTabBody
|
||||||
tab={state.tab}
|
tab={state.tab}
|
||||||
|
visited={state.visitedTabs}
|
||||||
readOnly={readOnly}
|
readOnly={readOnly}
|
||||||
navigate={nav.navigate}
|
navigate={nav.navigate}
|
||||||
focus={ownedBy(state.focus, shownPlace(state))}
|
focus={state.focus}
|
||||||
reloadSheet={reloadSheet}
|
reloadSheet={reloadSheet}
|
||||||
annotations={{
|
annotations={{
|
||||||
section: state.section,
|
section: state.section,
|
||||||
|
visited: state.visitedSections,
|
||||||
onOpenSection: nav.openSection,
|
onOpenSection: nav.openSection,
|
||||||
onBack: nav.backToDrawing,
|
onBack: nav.backToDrawing,
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
import {
|
||||||
|
createContext,
|
||||||
|
useContext,
|
||||||
|
type HTMLAttributes,
|
||||||
|
type ReactNode,
|
||||||
|
} from 'react'
|
||||||
|
|
||||||
|
const PlaceVisibleContext = createContext(true)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the place around this component is shown: every enclosing `KeptPlace` is
|
||||||
|
* visible. Outside any `KeptPlace` (the catalogue pages) it is true.
|
||||||
|
*/
|
||||||
|
export function usePlaceVisible(): boolean {
|
||||||
|
return useContext(PlaceVisibleContext)
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Props extends HTMLAttributes<HTMLDivElement> {
|
||||||
|
/** The `data-place` name; omitted for a wrapper that only nests places (tab panel). */
|
||||||
|
name?: string
|
||||||
|
visible: boolean
|
||||||
|
children: ReactNode
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A place that stays mounted while hidden: `hidden` leaves the accessibility tree and keeps
|
||||||
|
* every component state (Tailwind's preflight makes `[hidden]` `display: none`). Nested
|
||||||
|
* places compose: a place is visible only when all the places around it are.
|
||||||
|
*/
|
||||||
|
export default function KeptPlace({ name, visible, children, ...rest }: Props) {
|
||||||
|
const parent = usePlaceVisible()
|
||||||
|
return (
|
||||||
|
<PlaceVisibleContext value={parent && visible}>
|
||||||
|
<div {...rest} data-place={name} hidden={!visible}>
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
</PlaceVisibleContext>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -30,7 +30,6 @@ export default function AnnotationSection({
|
|||||||
const headingId = `annotation-section-${section}-title`
|
const headingId = `annotation-section-${section}-title`
|
||||||
return (
|
return (
|
||||||
<section
|
<section
|
||||||
data-place={`annotations.${section}`}
|
|
||||||
aria-labelledby={headingId}
|
aria-labelledby={headingId}
|
||||||
className="space-y-4"
|
className="space-y-4"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -11,19 +11,17 @@ import type { EditorPlaceProps } from '@/editor/tabs'
|
|||||||
import { useT } from '@/i18n/useT'
|
import { useT } from '@/i18n/useT'
|
||||||
|
|
||||||
interface Props extends Pick<EditorPlaceProps, 'readOnly' | 'focus'> {
|
interface Props extends Pick<EditorPlaceProps, 'readOnly' | 'focus'> {
|
||||||
open: boolean
|
|
||||||
onClose: () => void
|
onClose: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The references side panel, minimal until Lot D: the sheet's bibliography, cited by id
|
* The references side panel, minimal until Lot D: the sheet's bibliography, cited by id
|
||||||
* from the findings, opened by the header button. Not a dialog: it keeps the page usable.
|
* from the findings, opened by the header button. Not a dialog: it keeps the page usable.
|
||||||
* Mounted at the first opening and kept (hidden) afterwards.
|
* The workspace mounts it at the first opening and keeps it (hidden) afterwards.
|
||||||
*/
|
*/
|
||||||
export default function ReferencesPanel({
|
export default function ReferencesPanel({
|
||||||
readOnly,
|
readOnly,
|
||||||
focus,
|
focus,
|
||||||
open,
|
|
||||||
onClose,
|
onClose,
|
||||||
}: Props) {
|
}: Props) {
|
||||||
const t = useT()
|
const t = useT()
|
||||||
@@ -39,10 +37,8 @@ export default function ReferencesPanel({
|
|||||||
return (
|
return (
|
||||||
<section
|
<section
|
||||||
id="editor-references-panel"
|
id="editor-references-panel"
|
||||||
data-place="references"
|
|
||||||
data-testid="editor-references-panel"
|
data-testid="editor-references-panel"
|
||||||
aria-labelledby="editor-references-title"
|
aria-labelledby="editor-references-title"
|
||||||
hidden={!open}
|
|
||||||
onKeyDown={onKeyDown}
|
onKeyDown={onKeyDown}
|
||||||
className="space-y-3 rounded-xl border border-[var(--color-border)] p-4"
|
className="space-y-3 rounded-xl border border-[var(--color-border)] p-4"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ import PropertiesPanel from '@/components/editor/annotations/PropertiesPanel'
|
|||||||
import AnnotationSection from '@/components/editor/annotations/sections/AnnotationSection'
|
import AnnotationSection from '@/components/editor/annotations/sections/AnnotationSection'
|
||||||
import ViewSwitcher from '@/components/editor/annotations/ViewSwitcher'
|
import ViewSwitcher from '@/components/editor/annotations/ViewSwitcher'
|
||||||
import SelectionTag from '@/components/editor/annotations/SelectionTag'
|
import SelectionTag from '@/components/editor/annotations/SelectionTag'
|
||||||
|
import KeptPlace from '@/components/editor/KeptPlace'
|
||||||
|
import { ownedBy } from '@/editor/focusRequest'
|
||||||
import { useAnnotationRequest } from '@/editor/annotations/focusTarget'
|
import { useAnnotationRequest } from '@/editor/annotations/focusTarget'
|
||||||
import { mainViewId, useViewModel } from '@/editor/annotations/useViewModel'
|
import { mainViewId, useViewModel } from '@/editor/annotations/useViewModel'
|
||||||
import type { AnnotationSection as SectionId } from '@/editor/navigation'
|
import type { AnnotationSection as SectionId } from '@/editor/navigation'
|
||||||
@@ -22,21 +24,30 @@ import { useLocaleStore } from '@/state/localeStore'
|
|||||||
export interface AnnotationsTabProps extends EditorPlaceProps {
|
export interface AnnotationsTabProps extends EditorPlaceProps {
|
||||||
/** The section shown: the drawing workspace, or a full-width section. */
|
/** The section shown: the drawing workspace, or a full-width section. */
|
||||||
section: SectionId
|
section: SectionId
|
||||||
|
/** The sections shown at least once: each stays mounted. */
|
||||||
|
visited: readonly SectionId[]
|
||||||
onOpenSection: (section: SectionId, opener: HTMLElement) => void
|
onOpenSection: (section: SectionId, opener: HTMLElement) => void
|
||||||
onBack: () => void
|
onBack: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A full-width section, once the document is loaded. */
|
/** A full-width section, once the document is loaded. */
|
||||||
function SectionPlace(props: AnnotationsTabProps) {
|
function SectionPlace({
|
||||||
|
section,
|
||||||
|
readOnly,
|
||||||
|
focus,
|
||||||
|
onBack,
|
||||||
|
}: Pick<AnnotationsTabProps, 'readOnly' | 'focus' | 'onBack'> & {
|
||||||
|
section: Exclude<SectionId, 'drawing'>
|
||||||
|
}) {
|
||||||
const doc = useSheetDocument()
|
const doc = useSheetDocument()
|
||||||
if (!doc || props.section === 'drawing') return null
|
if (!doc) return null
|
||||||
return (
|
return (
|
||||||
<AnnotationSection
|
<AnnotationSection
|
||||||
section={props.section}
|
section={section}
|
||||||
doc={doc}
|
doc={doc}
|
||||||
readOnly={props.readOnly}
|
readOnly={readOnly}
|
||||||
focus={props.focus}
|
focus={focus}
|
||||||
onBack={props.onBack}
|
onBack={onBack}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -51,7 +62,6 @@ function DrawingPlace(props: AnnotationsTabProps) {
|
|||||||
const ready = doc && preview
|
const ready = doc && preview
|
||||||
return (
|
return (
|
||||||
<section
|
<section
|
||||||
data-place="annotations.drawing"
|
|
||||||
data-testid="editor-tab-annotations"
|
data-testid="editor-tab-annotations"
|
||||||
aria-label={t('editor.tab.annotations')}
|
aria-label={t('editor.tab.annotations')}
|
||||||
className="min-h-24 space-y-3"
|
className="min-h-24 space-y-3"
|
||||||
@@ -62,16 +72,33 @@ function DrawingPlace(props: AnnotationsTabProps) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** One kept section: the drawing workspace or a full-width section. */
|
||||||
|
function SectionBody(props: AnnotationsTabProps & { id: SectionId }) {
|
||||||
|
const { id, ...rest } = props
|
||||||
|
const focus = ownedBy(props.focus, `annotations.${id}`)
|
||||||
|
if (id === 'drawing') return <DrawingPlace {...rest} focus={focus} />
|
||||||
|
return <SectionPlace {...rest} section={id} focus={focus} />
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Annotations: the drawing workspace (canvas with its tools, the overview or the
|
* Annotations: the drawing workspace (canvas with its tools, the overview or the
|
||||||
* properties and creation panels), or one of its full-width sections. Read-only, the
|
* properties and creation panels), or one of its full-width sections. Read-only, the
|
||||||
* same view is browsable (canvas, list, properties as text) with no tool and no action.
|
* same view is browsable (canvas, list, properties as text) with no tool and no action.
|
||||||
|
* Each section shown so far stays mounted, hidden while another is shown.
|
||||||
*/
|
*/
|
||||||
export default function AnnotationsTab(props: AnnotationsTabProps) {
|
export default function AnnotationsTab(props: AnnotationsTabProps) {
|
||||||
return props.section === 'drawing' ? (
|
return (
|
||||||
<DrawingPlace {...props} />
|
<>
|
||||||
) : (
|
{props.visited.map((id) => (
|
||||||
<SectionPlace {...props} />
|
<KeptPlace
|
||||||
|
key={id}
|
||||||
|
name={`annotations.${id}`}
|
||||||
|
visible={id === props.section}
|
||||||
|
>
|
||||||
|
<SectionBody {...props} id={id} />
|
||||||
|
</KeptPlace>
|
||||||
|
))}
|
||||||
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import { useEffect, useRef, useState } from 'react'
|
import { useEffect, useRef, useState, type RefObject } from 'react'
|
||||||
import type { ViewBox } from '@faunosteo/core-wasm/types'
|
import type { ViewBox } from '@faunosteo/core-wasm/types'
|
||||||
import Notice from '@/components/ui/Notice'
|
import Notice from '@/components/ui/Notice'
|
||||||
import { buildView } from '@/components/catalogue/CatalogueCanvas'
|
import { buildView } from '@/components/catalogue/CatalogueCanvas'
|
||||||
|
import { usePlaceVisible } from '@/components/editor/KeptPlace'
|
||||||
import { useEditorStore } from '@/editor/state/editorStore'
|
import { useEditorStore } from '@/editor/state/editorStore'
|
||||||
import { useT } from '@/i18n/useT'
|
import { useT } from '@/i18n/useT'
|
||||||
|
|
||||||
@@ -10,6 +11,35 @@ interface Frame {
|
|||||||
ratio: string
|
ratio: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Builds the parent view into `host` while its place is shown, and reads its frame. */
|
||||||
|
function useParentFrame(
|
||||||
|
parentId: string,
|
||||||
|
host: RefObject<HTMLDivElement | null>,
|
||||||
|
): Frame | 'failed' | null {
|
||||||
|
const preview = useEditorStore((s) => s.preview)
|
||||||
|
const handleVersion = useEditorStore((s) => s.handleVersion)
|
||||||
|
const visible = usePlaceVisible()
|
||||||
|
const [frame, setFrame] = useState<Frame | 'failed' | null>(null)
|
||||||
|
useEffect(() => {
|
||||||
|
const element = host.current
|
||||||
|
if (!element || !preview) return
|
||||||
|
// One composed copy of a view in the page: the ids repeat otherwise.
|
||||||
|
if (!visible) return element.replaceChildren()
|
||||||
|
const built = buildView(preview, parentId)
|
||||||
|
element.replaceChildren(...(built.ok ? [built.svg] : []))
|
||||||
|
setFrame(
|
||||||
|
built.ok
|
||||||
|
? {
|
||||||
|
viewBox: built.svg.getAttribute('viewBox') ?? '0 0 100 100',
|
||||||
|
ratio:
|
||||||
|
built.svg.getAttribute('preserveAspectRatio') ?? 'xMidYMid meet',
|
||||||
|
}
|
||||||
|
: 'failed',
|
||||||
|
)
|
||||||
|
}, [host, preview, parentId, handleVersion, visible])
|
||||||
|
return frame
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The parent view as the core composes it, with the crop rectangle over it. The overlay
|
* The parent view as the core composes it, with the crop rectangle over it. The overlay
|
||||||
* is page-drawn and holds numbers only (one rectangle in the composed root's own
|
* is page-drawn and holds numbers only (one rectangle in the composed root's own
|
||||||
@@ -23,25 +53,8 @@ export default function CropCanvas({
|
|||||||
box: ViewBox | null
|
box: ViewBox | null
|
||||||
}) {
|
}) {
|
||||||
const t = useT()
|
const t = useT()
|
||||||
const preview = useEditorStore((s) => s.preview)
|
|
||||||
const handleVersion = useEditorStore((s) => s.handleVersion)
|
|
||||||
const host = useRef<HTMLDivElement | null>(null)
|
const host = useRef<HTMLDivElement | null>(null)
|
||||||
const [frame, setFrame] = useState<Frame | 'failed' | null>(null)
|
const frame = useParentFrame(parentId, host)
|
||||||
useEffect(() => {
|
|
||||||
const element = host.current
|
|
||||||
if (!element || !preview) return
|
|
||||||
const built = buildView(preview, parentId)
|
|
||||||
element.replaceChildren(...(built.ok ? [built.svg] : []))
|
|
||||||
setFrame(
|
|
||||||
built.ok
|
|
||||||
? {
|
|
||||||
viewBox: built.svg.getAttribute('viewBox') ?? '0 0 100 100',
|
|
||||||
ratio:
|
|
||||||
built.svg.getAttribute('preserveAspectRatio') ?? 'xMidYMid meet',
|
|
||||||
}
|
|
||||||
: 'failed',
|
|
||||||
)
|
|
||||||
}, [preview, parentId, handleVersion])
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||||
import { buildView } from '@/components/catalogue/CatalogueCanvas'
|
import { buildView } from '@/components/catalogue/CatalogueCanvas'
|
||||||
|
import { usePlaceVisible } from '@/components/editor/KeptPlace'
|
||||||
import { coreRuntime } from '@/core/runtime'
|
import { coreRuntime } from '@/core/runtime'
|
||||||
import { useEditorStore } from '../state/editorStore'
|
import { useEditorStore } from '../state/editorStore'
|
||||||
|
|
||||||
@@ -28,11 +29,11 @@ function rootOf(viewId: string, svg: Element): RootAttributes {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** What the canvas rebuilds on: the handle and its version counter. */
|
/** What the canvas rebuilds on: the handle, its version counter and its place shown. */
|
||||||
function useHandle() {
|
function useHandle() {
|
||||||
const preview = useEditorStore((s) => s.preview)
|
const preview = useEditorStore((s) => s.preview)
|
||||||
const version = useEditorStore((s) => s.handleVersion)
|
const version = useEditorStore((s) => s.handleVersion)
|
||||||
return { preview, version }
|
return { preview, version, visible: usePlaceVisible() }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -50,6 +51,8 @@ export function useCanvasBuild(viewId: string) {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const element = host.current
|
const element = host.current
|
||||||
if (!element || !handle.preview) return
|
if (!element || !handle.preview) return
|
||||||
|
// One composed copy of a view in the page: the ids repeat otherwise.
|
||||||
|
if (!handle.visible) return element.replaceChildren()
|
||||||
const result = buildView(handle.preview, viewId)
|
const result = buildView(handle.preview, viewId)
|
||||||
element.replaceChildren(...(result.ok ? [result.svg] : []))
|
element.replaceChildren(...(result.ok ? [result.svg] : []))
|
||||||
setBuilt(
|
setBuilt(
|
||||||
@@ -57,7 +60,7 @@ export function useCanvasBuild(viewId: string) {
|
|||||||
? { root: rootOf(viewId, result.svg), failure: null }
|
? { root: rootOf(viewId, result.svg), failure: null }
|
||||||
: { root: null, failure: result.failure },
|
: { root: null, failure: result.failure },
|
||||||
)
|
)
|
||||||
}, [handle.preview, viewId, handle.version, attempt])
|
}, [handle.preview, viewId, handle.version, attempt, handle.visible])
|
||||||
|
|
||||||
const retry = useCallback(() => {
|
const retry = useCallback(() => {
|
||||||
void coreRuntime()
|
void coreRuntime()
|
||||||
|
|||||||
@@ -8,16 +8,30 @@ import type {
|
|||||||
import type { Locale } from '@/i18n/types'
|
import type { Locale } from '@/i18n/types'
|
||||||
import { useEditorStore } from './state/editorStore'
|
import { useEditorStore } from './state/editorStore'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The last text parsed and its document. Every kept place reads the document, so one parse
|
||||||
|
* serves them all per commit. A single entry: the store holds one document at a time.
|
||||||
|
*/
|
||||||
|
let lastParse: { text: string; doc: AnatomicalSheetDocument | null } | null =
|
||||||
|
null
|
||||||
|
|
||||||
|
function parseDocument(text: string): AnatomicalSheetDocument | null {
|
||||||
|
if (text === '') return null
|
||||||
|
if (lastParse?.text === text) return lastParse.doc
|
||||||
|
let doc: AnatomicalSheetDocument | null = null
|
||||||
|
try {
|
||||||
|
doc = JSON.parse(text) as AnatomicalSheetDocument
|
||||||
|
} catch {
|
||||||
|
doc = null
|
||||||
|
}
|
||||||
|
lastParse = { text, doc }
|
||||||
|
return doc
|
||||||
|
}
|
||||||
|
|
||||||
/** The edited document, read from the store's text; null while nothing is loaded. */
|
/** The edited document, read from the store's text; null while nothing is loaded. */
|
||||||
export function useSheetDocument(): AnatomicalSheetDocument | null {
|
export function useSheetDocument(): AnatomicalSheetDocument | null {
|
||||||
const text = useEditorStore((s) => s.documentText)
|
const text = useEditorStore((s) => s.documentText)
|
||||||
return useMemo(() => {
|
return useMemo(() => parseDocument(text), [text])
|
||||||
try {
|
|
||||||
return text === '' ? null : (JSON.parse(text) as AnatomicalSheetDocument)
|
|
||||||
} catch {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
}, [text])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const isBlank = (value: string): boolean => value.trim() === ''
|
export const isBlank = (value: string): boolean => value.trim() === ''
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ const props = {
|
|||||||
navigate: vi.fn(),
|
navigate: vi.fn(),
|
||||||
reloadSheet: vi.fn(),
|
reloadSheet: vi.fn(),
|
||||||
section: 'drawing' as const,
|
section: 'drawing' as const,
|
||||||
|
visited: ['drawing'] as const,
|
||||||
onOpenSection: vi.fn(),
|
onOpenSection: vi.fn(),
|
||||||
onBack: vi.fn(),
|
onBack: vi.fn(),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ vi.mock('@faunosteo/supabase', async (orig) => ({
|
|||||||
const base = { readOnly: false, navigate: vi.fn(), reloadSheet: vi.fn() }
|
const base = { readOnly: false, navigate: vi.fn(), reloadSheet: vi.fn() }
|
||||||
const section = {
|
const section = {
|
||||||
section: 'drawing' as const,
|
section: 'drawing' as const,
|
||||||
|
visited: ['drawing'] as const,
|
||||||
onOpenSection: vi.fn(),
|
onOpenSection: vi.fn(),
|
||||||
onBack: vi.fn(),
|
onBack: vi.fn(),
|
||||||
}
|
}
|
||||||
@@ -253,11 +254,13 @@ function Probe({ go, tier }: { go: EditorTarget; tier: 'wide' | 'small' }) {
|
|||||||
<button onClick={() => nav.navigate(go)}>go</button>
|
<button onClick={() => nav.navigate(go)}>go</button>
|
||||||
<EditorTabBody
|
<EditorTabBody
|
||||||
tab={state.tab}
|
tab={state.tab}
|
||||||
|
visited={state.visitedTabs}
|
||||||
{...base}
|
{...base}
|
||||||
navigate={nav.navigate}
|
navigate={nav.navigate}
|
||||||
focus={ownedBy(state.focus, state.tab)}
|
focus={state.focus}
|
||||||
annotations={{
|
annotations={{
|
||||||
section: state.section,
|
section: state.section,
|
||||||
|
visited: state.visitedSections,
|
||||||
onOpenSection: nav.openSection,
|
onOpenSection: nav.openSection,
|
||||||
onBack: nav.backToDrawing,
|
onBack: nav.backToDrawing,
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -0,0 +1,500 @@
|
|||||||
|
/** U1 Lot B2a: tabs, Annotations sections and the references panel stay mounted. */
|
||||||
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||||
|
import {
|
||||||
|
act,
|
||||||
|
cleanup,
|
||||||
|
fireEvent,
|
||||||
|
render,
|
||||||
|
screen,
|
||||||
|
waitFor,
|
||||||
|
within,
|
||||||
|
} from '@testing-library/react'
|
||||||
|
import userEvent from '@testing-library/user-event'
|
||||||
|
import type { AnatomicalSheetDocument } from '@faunosteo/core-wasm/types'
|
||||||
|
import EditorTabBody from '@/components/editor/EditorTabBody'
|
||||||
|
import KeptPlace, { usePlaceVisible } from '@/components/editor/KeptPlace'
|
||||||
|
import { FocusConsumedContext } from '@/editor/focusRequest'
|
||||||
|
import { targetOfKey } from '@/editor/navigation'
|
||||||
|
import { useLocaleStore } from '@/state/localeStore'
|
||||||
|
import { cleanSvg } from '@/editor/core/cleaning'
|
||||||
|
import {
|
||||||
|
ASSET,
|
||||||
|
drawnText,
|
||||||
|
edit,
|
||||||
|
insert,
|
||||||
|
point,
|
||||||
|
} from '../helpers/editorFixtures'
|
||||||
|
import {
|
||||||
|
baseText,
|
||||||
|
resetStore,
|
||||||
|
sb,
|
||||||
|
serverHas,
|
||||||
|
store,
|
||||||
|
versionAnswer,
|
||||||
|
} from '../helpers/editorHarness'
|
||||||
|
import { mountDraft, setWidth } from '../helpers/editorRoute'
|
||||||
|
|
||||||
|
vi.mock('@/lib/supabase', () => ({ getSupabaseClient: () => ({}) }))
|
||||||
|
vi.mock('@faunosteo/supabase', async (orig) => ({
|
||||||
|
...(await orig<typeof import('@faunosteo/supabase')>()),
|
||||||
|
getSheetVersion: vi.fn(),
|
||||||
|
downloadSheetDrawing: vi.fn(),
|
||||||
|
saveSheetDraft: vi.fn(),
|
||||||
|
getOfficialSheetAdmin: vi.fn(),
|
||||||
|
submitSheetReview: vi.fn(),
|
||||||
|
}))
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
useLocaleStore.setState({ locale: 'fr' })
|
||||||
|
const identity = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 }
|
||||||
|
Object.defineProperty(window.SVGElement.prototype, 'getScreenCTM', {
|
||||||
|
configurable: true,
|
||||||
|
value: () => ({ ...identity, inverse: () => identity }),
|
||||||
|
})
|
||||||
|
})
|
||||||
|
afterEach(() => {
|
||||||
|
cleanup()
|
||||||
|
resetStore()
|
||||||
|
setWidth(1024)
|
||||||
|
})
|
||||||
|
|
||||||
|
const ready = () =>
|
||||||
|
screen.findByRole('heading', { level: 1, name: 'Brouillon, version 4' })
|
||||||
|
const tab = (name: string | RegExp) => screen.getByRole('tab', { name })
|
||||||
|
const entry = (name: string | RegExp) => screen.getByRole('button', { name })
|
||||||
|
const place = (name: string) =>
|
||||||
|
document.querySelector<HTMLElement>(`[data-place="${name}"]`)!
|
||||||
|
const inPlace = (name: string) => within(place(name))
|
||||||
|
const referencesButton = () =>
|
||||||
|
screen.getByRole('button', { name: 'Références' })
|
||||||
|
const name = (n: string) => ({ fr: n, en: n })
|
||||||
|
|
||||||
|
function findingsText(): string {
|
||||||
|
const text = insert(baseText(), {
|
||||||
|
kind: 'zone',
|
||||||
|
value: { id: 'zone-a', name: name('Zone A'), categories: [] },
|
||||||
|
})
|
||||||
|
return edit(text, {
|
||||||
|
op: 'insert',
|
||||||
|
parent: { kind: 'zone', id: 'zone-a' },
|
||||||
|
element: {
|
||||||
|
kind: 'finding_category',
|
||||||
|
value: {
|
||||||
|
id: 'fcat-a',
|
||||||
|
kind: 'dysfunction',
|
||||||
|
name: name('Cat A'),
|
||||||
|
description: {},
|
||||||
|
reference_ids: [],
|
||||||
|
review_status: 'to_confirm',
|
||||||
|
children: [],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function referenceText(): string {
|
||||||
|
return insert(baseText(), {
|
||||||
|
kind: 'reference',
|
||||||
|
value: {
|
||||||
|
id: 'ref-1',
|
||||||
|
type: 'journal',
|
||||||
|
citation: 'Doe 2020',
|
||||||
|
url: null,
|
||||||
|
doi: null,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async function mount(text = baseText()) {
|
||||||
|
serverHas(text, 3)
|
||||||
|
const user = userEvent.setup()
|
||||||
|
mountDraft()
|
||||||
|
await ready()
|
||||||
|
return user
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('KeptPlace', () => {
|
||||||
|
function Probe() {
|
||||||
|
return <p>{usePlaceVisible() ? 'yes' : 'no'}</p>
|
||||||
|
}
|
||||||
|
|
||||||
|
it('hides its children and composes with the places around it', () => {
|
||||||
|
render(
|
||||||
|
<KeptPlace name="outer" visible>
|
||||||
|
<KeptPlace name="inner" visible={false}>
|
||||||
|
<Probe />
|
||||||
|
</KeptPlace>
|
||||||
|
<KeptPlace name="other" visible>
|
||||||
|
<Probe />
|
||||||
|
</KeptPlace>
|
||||||
|
</KeptPlace>,
|
||||||
|
)
|
||||||
|
expect(place('inner')).not.toBeVisible()
|
||||||
|
expect(place('other')).toBeVisible()
|
||||||
|
expect(screen.getAllByText('yes')).toHaveLength(1)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('an own visible place inside a hidden one is not visible', () => {
|
||||||
|
render(
|
||||||
|
<KeptPlace name="outer" visible={false}>
|
||||||
|
<KeptPlace name="inner" visible>
|
||||||
|
<Probe />
|
||||||
|
</KeptPlace>
|
||||||
|
</KeptPlace>,
|
||||||
|
)
|
||||||
|
expect(screen.getByText('no')).toBeInTheDocument()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('is visible outside any place', () => {
|
||||||
|
render(<Probe />)
|
||||||
|
expect(screen.getByText('yes')).toBeInTheDocument()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('text typed in a place that is left', () => {
|
||||||
|
it('the category add form survives Général ↔ Annotations and a section round trip', async () => {
|
||||||
|
const user = await mount()
|
||||||
|
await user.click(tab('Annotations'))
|
||||||
|
await user.click(entry('Modifier les catégories'))
|
||||||
|
const field = inPlace('annotations.categories').getByLabelText(
|
||||||
|
'Nom de la catégorie (FR)',
|
||||||
|
{ selector: '#category-new-fr' },
|
||||||
|
)
|
||||||
|
await user.type(field, 'Brouillon')
|
||||||
|
await user.click(tab('Général'))
|
||||||
|
expect(place('annotations.categories')).not.toBeVisible()
|
||||||
|
await user.click(tab('Annotations'))
|
||||||
|
expect(place('annotations.categories')).toBeVisible()
|
||||||
|
await user.click(screen.getByRole('button', { name: 'Retour au dessin' }))
|
||||||
|
await user.click(entry('Modifier les catégories'))
|
||||||
|
expect(document.querySelector('#category-new-fr')).toBe(field)
|
||||||
|
expect(field).toHaveValue('Brouillon')
|
||||||
|
expect(store.getState().unsaved).toBe(false)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('the reference add form survives closing and reopening the panel', async () => {
|
||||||
|
const user = await mount()
|
||||||
|
await user.click(referencesButton())
|
||||||
|
const field = inPlace('references').getByLabelText('Citation', {
|
||||||
|
selector: '#reference-new-citation',
|
||||||
|
})
|
||||||
|
await user.type(field, 'Smith 1999')
|
||||||
|
await user.click(referencesButton())
|
||||||
|
expect(place('references')).not.toBeVisible()
|
||||||
|
await user.click(referencesButton())
|
||||||
|
expect(field).toHaveValue('Smith 1999')
|
||||||
|
expect(store.getState().unsaved).toBe(false)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('findings and canvas state across a tab change', () => {
|
||||||
|
it('the findings selection and expansion survive', async () => {
|
||||||
|
const user = await mount(findingsText())
|
||||||
|
await user.click(tab('Constats'))
|
||||||
|
const zone = inPlace('findings').getByRole('treeitem', { name: /Zone A/ })
|
||||||
|
const cat = inPlace('findings').getByRole('treeitem', { name: /Cat A/ })
|
||||||
|
await user.click(cat)
|
||||||
|
expect(zone).toHaveAttribute('aria-expanded', 'true')
|
||||||
|
await user.click(tab('Général'))
|
||||||
|
await user.click(tab('Constats'))
|
||||||
|
expect(inPlace('findings').getByRole('treeitem', { name: /Cat A/ })).toBe(
|
||||||
|
cat,
|
||||||
|
)
|
||||||
|
expect(cat).toHaveAttribute('aria-selected', 'true')
|
||||||
|
expect(zone).toHaveAttribute('aria-expanded', 'true')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('the canvas tool, selection and zoom survive a tab change and a section round trip', async () => {
|
||||||
|
const text = insert(drawnText(), point('anno-a', 50, 50, 5))
|
||||||
|
const user = await mount(text)
|
||||||
|
await waitFor(() =>
|
||||||
|
expect(
|
||||||
|
inPlace('annotations.drawing').getByRole('button', { name: 'Zone' }),
|
||||||
|
).toBeEnabled(),
|
||||||
|
)
|
||||||
|
const drawing = inPlace('annotations.drawing')
|
||||||
|
await user.click(drawing.getByRole('button', { name: 'Zone' }))
|
||||||
|
await user.click(drawing.getByRole('button', { name: 'Zoom avant' }))
|
||||||
|
const layer = () =>
|
||||||
|
drawing.getByTestId('annotation-canvas').firstElementChild as HTMLElement
|
||||||
|
const zoomed = layer().style.transform
|
||||||
|
expect(zoomed).not.toContain('scale(1)')
|
||||||
|
await user.click(tab('Général'))
|
||||||
|
await user.click(tab('Annotations'))
|
||||||
|
await user.click(entry('Gérer les vues'))
|
||||||
|
await user.click(screen.getByRole('button', { name: 'Retour au dessin' }))
|
||||||
|
expect(drawing.getByRole('button', { name: 'Zone' })).toHaveAttribute(
|
||||||
|
'aria-pressed',
|
||||||
|
'true',
|
||||||
|
)
|
||||||
|
expect(layer().style.transform).toBe(zoomed)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('a field still focused while a place is left', () => {
|
||||||
|
async function generalNameField(user: ReturnType<typeof userEvent.setup>) {
|
||||||
|
await user.click(tab('Général'))
|
||||||
|
const field = inPlace('general').getByLabelText('Nom (FR)', {
|
||||||
|
exact: true,
|
||||||
|
selector: '#general-name-fr',
|
||||||
|
})
|
||||||
|
await user.click(field)
|
||||||
|
fireEvent.change(field, { target: { value: 'Nom saisi' } })
|
||||||
|
return field
|
||||||
|
}
|
||||||
|
|
||||||
|
it('a click that moves no focus (Safari) still commits it, as one undo entry', async () => {
|
||||||
|
const user = await mount()
|
||||||
|
const before = store.getState().documentText
|
||||||
|
const field = await generalNameField(user)
|
||||||
|
expect(document.activeElement).toBe(field)
|
||||||
|
fireEvent.click(tab('Annotations'))
|
||||||
|
expect(JSON.parse(store.getState().documentText).name.fr).toBe('Nom saisi')
|
||||||
|
expect(store.getState().unsaved).toBe(true)
|
||||||
|
act(() => void store.getState().undoStep())
|
||||||
|
expect(store.getState().documentText).toBe(before)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Escape in a reference field commits the text before the panel hides', async () => {
|
||||||
|
const user = await mount(referenceText())
|
||||||
|
await user.click(referencesButton())
|
||||||
|
const field = inPlace('references').getByLabelText('Citation', {
|
||||||
|
selector: '#reference-ref-1-citation',
|
||||||
|
})
|
||||||
|
await user.click(field)
|
||||||
|
fireEvent.change(field, { target: { value: 'Doe 2021' } })
|
||||||
|
await user.keyboard('{Escape}')
|
||||||
|
expect(place('references')).not.toBeVisible()
|
||||||
|
const doc: AnatomicalSheetDocument = JSON.parse(
|
||||||
|
store.getState().documentText,
|
||||||
|
)
|
||||||
|
expect(doc.references[0].citation).toBe('Doe 2021')
|
||||||
|
expect(store.getState().unsaved).toBe(true)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('the header toggle (no focus move) closes the panel after committing', async () => {
|
||||||
|
const user = await mount(referenceText())
|
||||||
|
await user.click(referencesButton())
|
||||||
|
const field = inPlace('references').getByLabelText('Citation', {
|
||||||
|
selector: '#reference-ref-1-citation',
|
||||||
|
})
|
||||||
|
await user.click(field)
|
||||||
|
fireEvent.change(field, { target: { value: 'Doe 2022' } })
|
||||||
|
fireEvent.click(referencesButton())
|
||||||
|
expect(place('references')).not.toBeVisible()
|
||||||
|
expect(
|
||||||
|
JSON.parse(store.getState().documentText).references[0].citation,
|
||||||
|
).toBe('Doe 2022')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('ids and parses', () => {
|
||||||
|
const detail = {
|
||||||
|
kind: 'view',
|
||||||
|
value: {
|
||||||
|
kind: 'detail',
|
||||||
|
id: 'view-det',
|
||||||
|
name: { fr: 'Tête', en: 'Head' },
|
||||||
|
svg_asset_id: null,
|
||||||
|
view_box: { min_x: 10, min_y: 20, width: 40, height: 60 },
|
||||||
|
parent_view_id: 'view-main',
|
||||||
|
},
|
||||||
|
} as const
|
||||||
|
|
||||||
|
/** A drawing whose own elements carry ids, so a second composed copy would repeat them. */
|
||||||
|
function serveDrawingWithIds(text: string): void {
|
||||||
|
const svg =
|
||||||
|
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">' +
|
||||||
|
'<defs><linearGradient id="fade"><stop offset="0"/></linearGradient></defs>' +
|
||||||
|
'<rect id="body" width="4" height="4" fill="url(#fade)"/></svg>'
|
||||||
|
const cleaned = cleanSvg(new TextEncoder().encode(svg))
|
||||||
|
if (!cleaned.ok || !cleaned.value.stored) throw new Error('uncleanable')
|
||||||
|
const bytes = new TextEncoder().encode(cleaned.value.stored)
|
||||||
|
const answer = versionAnswer(text, 3)
|
||||||
|
answer.drawings = [{ asset_id: ASSET, sha256: cleaned.value.sha256! }]
|
||||||
|
sb.getSheetVersion.mockResolvedValue(answer as never)
|
||||||
|
sb.downloadSheetDrawing.mockResolvedValue(bytes)
|
||||||
|
}
|
||||||
|
|
||||||
|
const composedHosts = () =>
|
||||||
|
[
|
||||||
|
...document.querySelectorAll(
|
||||||
|
'[data-testid="annotation-canvas-drawing"], [data-testid="crop-canvas-drawing"]',
|
||||||
|
),
|
||||||
|
].filter((host) => host.querySelector('svg'))
|
||||||
|
|
||||||
|
it('every place visited, a crop group open: one composed copy, no id repeats', async () => {
|
||||||
|
serveDrawingWithIds(insert(drawnText(), detail))
|
||||||
|
const user = userEvent.setup()
|
||||||
|
mountDraft()
|
||||||
|
await ready()
|
||||||
|
await waitFor(() => expect(composedHosts()).toHaveLength(1))
|
||||||
|
await user.click(entry('Gérer les vues'))
|
||||||
|
await user.click(
|
||||||
|
inPlace('annotations.views').getByRole('button', {
|
||||||
|
name: 'Modifier le recadrage',
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
await waitFor(() => expect(composedHosts()).toHaveLength(1))
|
||||||
|
expect(composedHosts()[0]).toHaveAttribute(
|
||||||
|
'data-testid',
|
||||||
|
'crop-canvas-drawing',
|
||||||
|
)
|
||||||
|
await user.click(screen.getByRole('button', { name: 'Retour au dessin' }))
|
||||||
|
await user.click(entry('Modifier les catégories'))
|
||||||
|
await user.click(screen.getByRole('button', { name: 'Retour au dessin' }))
|
||||||
|
await user.click(entry(/^Régions vertébrales/))
|
||||||
|
for (const name of ['Général', 'Constats', /Vérification/]) {
|
||||||
|
await user.click(tab(name))
|
||||||
|
}
|
||||||
|
await user.click(referencesButton())
|
||||||
|
expect(composedHosts()).toHaveLength(0)
|
||||||
|
await user.click(tab('Annotations'))
|
||||||
|
await user.click(screen.getByRole('button', { name: 'Retour au dessin' }))
|
||||||
|
await waitFor(() => expect(composedHosts()).toHaveLength(1))
|
||||||
|
const ids = [...document.querySelectorAll('[id]')].map((e) => e.id)
|
||||||
|
expect(ids.filter((id, i) => ids.indexOf(id) !== i)).toEqual([])
|
||||||
|
expect(ids.some((id) => id.includes('body'))).toBe(true)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('one JSON.parse per document text across the places', async () => {
|
||||||
|
const user = await mount()
|
||||||
|
for (const name of ['Général', 'Constats', /Vérification/]) {
|
||||||
|
await user.click(tab(name))
|
||||||
|
}
|
||||||
|
await user.click(tab('Annotations'))
|
||||||
|
const original = JSON.parse
|
||||||
|
const fromPlaces: string[] = []
|
||||||
|
const parse = vi.spyOn(JSON, 'parse').mockImplementation((...args) => {
|
||||||
|
if (new Error().stack?.includes('parseDocument')) {
|
||||||
|
fromPlaces.push(String(args[0]))
|
||||||
|
}
|
||||||
|
return original(...args)
|
||||||
|
})
|
||||||
|
act(() => {
|
||||||
|
store.getState().commit({
|
||||||
|
op: 'insert',
|
||||||
|
element: {
|
||||||
|
kind: 'category',
|
||||||
|
value: { id: 'cat-z', name: name('Z'), color: null },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
parse.mockRestore()
|
||||||
|
expect(fromPlaces).toEqual([store.getState().documentText])
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('a request reaches only its owner', () => {
|
||||||
|
it('a finding request focuses the findings place while others are mounted', async () => {
|
||||||
|
await mount(findingsText())
|
||||||
|
await userEvent.setup().click(tab('Constats'))
|
||||||
|
await userEvent.setup().click(tab('Général'))
|
||||||
|
const consumed = vi.fn()
|
||||||
|
const { unmount } = render(
|
||||||
|
<FocusConsumedContext value={consumed}>
|
||||||
|
<EditorTabBody
|
||||||
|
tab="findings"
|
||||||
|
visited={['general', 'annotations', 'findings']}
|
||||||
|
readOnly={false}
|
||||||
|
navigate={vi.fn()}
|
||||||
|
reloadSheet={vi.fn()}
|
||||||
|
focus={{
|
||||||
|
target: targetOfKey({
|
||||||
|
kind: 'finding',
|
||||||
|
zone_id: 'zone-a',
|
||||||
|
path: ['fcat-a'],
|
||||||
|
}),
|
||||||
|
serial: 9,
|
||||||
|
}}
|
||||||
|
annotations={{
|
||||||
|
section: 'drawing',
|
||||||
|
visited: ['drawing'],
|
||||||
|
onOpenSection: vi.fn(),
|
||||||
|
onBack: vi.fn(),
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</FocusConsumedContext>,
|
||||||
|
)
|
||||||
|
await waitFor(() => expect(consumed).toHaveBeenCalledTimes(1))
|
||||||
|
expect(consumed).toHaveBeenCalledWith(9, 'found')
|
||||||
|
unmount()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('after « Aller à » a finding, arrowing back onto Constats keeps the focus on the tab', async () => {
|
||||||
|
const text = insert(findingsText(), {
|
||||||
|
...point('anno-bare', 10, 10, 2),
|
||||||
|
})
|
||||||
|
const user = await mount(text)
|
||||||
|
await user.click(tab('Constats'))
|
||||||
|
await user.click(
|
||||||
|
inPlace('findings').getByRole('treeitem', { name: /Cat A/ }),
|
||||||
|
)
|
||||||
|
await user.click(tab('Annotations'))
|
||||||
|
tab('Annotations').focus()
|
||||||
|
await user.keyboard('{ArrowRight}')
|
||||||
|
expect(tab('Constats')).toHaveAttribute('aria-selected', 'true')
|
||||||
|
expect(document.activeElement).toBe(tab('Constats'))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('« Aller à » while a creation or a tracing is in progress', () => {
|
||||||
|
function bareAnnotationText(): string {
|
||||||
|
const bare = point('anno-bare', 10, 10, 2)
|
||||||
|
const value = { ...bare.value, geometry: null, name: name('Sans tracé') }
|
||||||
|
return insert(drawnText(), { kind: 'annotation', value } as typeof bare)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function gotoBare(
|
||||||
|
user: ReturnType<typeof userEvent.setup>,
|
||||||
|
start: () => Promise<void>,
|
||||||
|
) {
|
||||||
|
await waitFor(() =>
|
||||||
|
expect(
|
||||||
|
inPlace('annotations.drawing').getByRole('button', { name: 'Zone' }),
|
||||||
|
).toBeEnabled(),
|
||||||
|
)
|
||||||
|
await start()
|
||||||
|
await user.click(tab(/Vérification/))
|
||||||
|
await user.click(
|
||||||
|
inPlace('verification').getAllByRole('button', {
|
||||||
|
name: 'Aller à Sans tracé',
|
||||||
|
})[0],
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
it('a tracing from the Zone tool is kept and focused', async () => {
|
||||||
|
const user = await mount(bareAnnotationText())
|
||||||
|
await gotoBare(user, async () => {
|
||||||
|
await user.click(
|
||||||
|
inPlace('annotations.drawing').getByRole('button', { name: 'Zone' }),
|
||||||
|
)
|
||||||
|
fireEvent.click(screen.getByTestId('annotation-canvas'), {
|
||||||
|
clientX: 20,
|
||||||
|
clientY: 20,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
expect(tab('Annotations')).toHaveAttribute('aria-selected', 'true')
|
||||||
|
const bar = within(place('annotations.drawing')).getByTestId('tracing-bar')
|
||||||
|
expect(bar).toBeVisible()
|
||||||
|
await waitFor(() => expect(document.activeElement).toBe(bar))
|
||||||
|
})
|
||||||
|
|
||||||
|
it('a pending creation is kept and focused', async () => {
|
||||||
|
const user = await mount(bareAnnotationText())
|
||||||
|
await gotoBare(user, async () => {
|
||||||
|
await user.click(
|
||||||
|
inPlace('annotations.drawing').getByRole('button', {
|
||||||
|
name: 'Ajouter un point',
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
const panel = within(place('annotations.drawing')).getByTestId(
|
||||||
|
'annotation-creation',
|
||||||
|
)
|
||||||
|
expect(panel).toBeVisible()
|
||||||
|
await waitFor(() =>
|
||||||
|
expect(document.activeElement).toHaveAttribute('data-creation-heading'),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -124,7 +124,7 @@ describe('tabs', () => {
|
|||||||
'true',
|
'true',
|
||||||
)
|
)
|
||||||
expect(screen.getByTestId('editor-tab-findings')).toBeInTheDocument()
|
expect(screen.getByTestId('editor-tab-findings')).toBeInTheDocument()
|
||||||
expect(screen.queryByTestId('editor-tab-annotations')).toBeNull()
|
expect(screen.getByTestId('editor-tab-annotations')).not.toBeVisible()
|
||||||
expect(screen.getByRole('tabpanel')).toHaveAccessibleName('Constats')
|
expect(screen.getByRole('tabpanel')).toHaveAccessibleName('Constats')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ describe('the overview entries', () => {
|
|||||||
'aria-selected',
|
'aria-selected',
|
||||||
'true',
|
'true',
|
||||||
)
|
)
|
||||||
expect(place('annotations.drawing')).toBeNull()
|
expect(place('annotations.drawing')).not.toBeVisible()
|
||||||
await user.click(screen.getByRole('button', { name: 'Retour au dessin' }))
|
await user.click(screen.getByRole('button', { name: 'Retour au dessin' }))
|
||||||
expect(place('annotations.drawing')).toBeVisible()
|
expect(place('annotations.drawing')).toBeVisible()
|
||||||
expect(document.activeElement).toHaveAttribute(
|
expect(document.activeElement).toHaveAttribute(
|
||||||
@@ -135,6 +135,7 @@ const props = {
|
|||||||
navigate: vi.fn(),
|
navigate: vi.fn(),
|
||||||
reloadSheet: vi.fn(),
|
reloadSheet: vi.fn(),
|
||||||
section: 'drawing' as const,
|
section: 'drawing' as const,
|
||||||
|
visited: ['drawing'] as const,
|
||||||
onOpenSection: vi.fn(),
|
onOpenSection: vi.fn(),
|
||||||
onBack: vi.fn(),
|
onBack: vi.fn(),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ describe('Références', () => {
|
|||||||
it('adds a reference only with a type and a citation', async () => {
|
it('adds a reference only with a type and a citation', async () => {
|
||||||
await openReady()
|
await openReady()
|
||||||
const user = userEvent.setup()
|
const user = userEvent.setup()
|
||||||
render(<ReferencesPanel {...props} open onClose={vi.fn()} />)
|
render(<ReferencesPanel {...props} onClose={vi.fn()} />)
|
||||||
await user.click(
|
await user.click(
|
||||||
screen.getByRole('button', { name: 'Ajouter la référence' }),
|
screen.getByRole('button', { name: 'Ajouter la référence' }),
|
||||||
)
|
)
|
||||||
@@ -72,7 +72,7 @@ describe('Références', () => {
|
|||||||
)
|
)
|
||||||
await openReady({ text })
|
await openReady({ text })
|
||||||
const user = userEvent.setup()
|
const user = userEvent.setup()
|
||||||
render(<ReferencesPanel {...props} open onClose={vi.fn()} />)
|
render(<ReferencesPanel {...props} onClose={vi.fn()} />)
|
||||||
const url = screen.getByLabelText('Adresse web (URL)', {
|
const url = screen.getByLabelText('Adresse web (URL)', {
|
||||||
selector: '#reference-ref-a-url',
|
selector: '#reference-ref-a-url',
|
||||||
})
|
})
|
||||||
@@ -111,7 +111,7 @@ describe('Références', () => {
|
|||||||
})
|
})
|
||||||
await openReady({ text })
|
await openReady({ text })
|
||||||
const user = userEvent.setup()
|
const user = userEvent.setup()
|
||||||
render(<ReferencesPanel {...props} open onClose={vi.fn()} />)
|
render(<ReferencesPanel {...props} onClose={vi.fn()} />)
|
||||||
await user.click(screen.getAllByRole('button', { name: 'Supprimer' })[0])
|
await user.click(screen.getAllByRole('button', { name: 'Supprimer' })[0])
|
||||||
const refused = await screen.findByRole('dialog')
|
const refused = await screen.findByRole('dialog')
|
||||||
expect(within(refused).getByText(/cite cette référence/)).toBeTruthy()
|
expect(within(refused).getByText(/cite cette référence/)).toBeTruthy()
|
||||||
@@ -127,7 +127,7 @@ describe('Références', () => {
|
|||||||
|
|
||||||
it('read-only shows the citations as text', async () => {
|
it('read-only shows the citations as text', async () => {
|
||||||
await openReady({ text: insert(baseText(), reference('ref-a', 'Alpha')) })
|
await openReady({ text: insert(baseText(), reference('ref-a', 'Alpha')) })
|
||||||
render(<ReferencesPanel {...props} open onClose={vi.fn()} readOnly />)
|
render(<ReferencesPanel {...props} onClose={vi.fn()} readOnly />)
|
||||||
expect(screen.getByText('Alpha')).toBeTruthy()
|
expect(screen.getByText('Alpha')).toBeTruthy()
|
||||||
expect(screen.queryByRole('textbox')).toBeNull()
|
expect(screen.queryByRole('textbox')).toBeNull()
|
||||||
expect(
|
expect(
|
||||||
|
|||||||
Reference in new issue
Block a user