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
@@ -46,6 +46,7 @@ const props = {
|
||||
navigate: vi.fn(),
|
||||
reloadSheet: vi.fn(),
|
||||
section: 'drawing' as const,
|
||||
visited: ['drawing'] as const,
|
||||
onOpenSection: 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 section = {
|
||||
section: 'drawing' as const,
|
||||
visited: ['drawing'] as const,
|
||||
onOpenSection: 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>
|
||||
<EditorTabBody
|
||||
tab={state.tab}
|
||||
visited={state.visitedTabs}
|
||||
{...base}
|
||||
navigate={nav.navigate}
|
||||
focus={ownedBy(state.focus, state.tab)}
|
||||
focus={state.focus}
|
||||
annotations={{
|
||||
section: state.section,
|
||||
visited: state.visitedSections,
|
||||
onOpenSection: nav.openSection,
|
||||
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',
|
||||
)
|
||||
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')
|
||||
})
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ describe('the overview entries', () => {
|
||||
'aria-selected',
|
||||
'true',
|
||||
)
|
||||
expect(place('annotations.drawing')).toBeNull()
|
||||
expect(place('annotations.drawing')).not.toBeVisible()
|
||||
await user.click(screen.getByRole('button', { name: 'Retour au dessin' }))
|
||||
expect(place('annotations.drawing')).toBeVisible()
|
||||
expect(document.activeElement).toHaveAttribute(
|
||||
@@ -135,6 +135,7 @@ const props = {
|
||||
navigate: vi.fn(),
|
||||
reloadSheet: vi.fn(),
|
||||
section: 'drawing' as const,
|
||||
visited: ['drawing'] as const,
|
||||
onOpenSection: 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 () => {
|
||||
await openReady()
|
||||
const user = userEvent.setup()
|
||||
render(<ReferencesPanel {...props} open onClose={vi.fn()} />)
|
||||
render(<ReferencesPanel {...props} onClose={vi.fn()} />)
|
||||
await user.click(
|
||||
screen.getByRole('button', { name: 'Ajouter la référence' }),
|
||||
)
|
||||
@@ -72,7 +72,7 @@ describe('Références', () => {
|
||||
)
|
||||
await openReady({ text })
|
||||
const user = userEvent.setup()
|
||||
render(<ReferencesPanel {...props} open onClose={vi.fn()} />)
|
||||
render(<ReferencesPanel {...props} onClose={vi.fn()} />)
|
||||
const url = screen.getByLabelText('Adresse web (URL)', {
|
||||
selector: '#reference-ref-a-url',
|
||||
})
|
||||
@@ -111,7 +111,7 @@ describe('Références', () => {
|
||||
})
|
||||
await openReady({ text })
|
||||
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])
|
||||
const refused = await screen.findByRole('dialog')
|
||||
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 () => {
|
||||
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.queryByRole('textbox')).toBeNull()
|
||||
expect(
|
||||
|
||||
Reference in new issue
Block a user