Important 1: a touch press fires pointer leave between up and click; only a mouse leave (or a pointer cancel) forgets the refused field, so Annuler no longer undoes an unrelated change. Important 2: the LAN spec reads the revision before the attach, through shownRevision, which throws instead of NaN (spec stays not run). Minor 1: refocusIfHidden refocuses a still shown element the commit blurred (references search on a 1 024 px crossing). Minor 2: discardChanges keeps lastSave (reload path still drops it). Minor 3: the overview filter term lives in UiState / the read-only twin, not the card. Minor 4: categories section drops its inner h3 and the unused editor.general.categories keys. AC8: badge test. Assertions rewritten or added (R-24): - editor-tabs-general « Général no longer holds the categories editor »: queryByText of the deleted heading (now vacuous) -> queryByLabelText of the category name fields. - editor-focus-request « Annotations: selects the annotation »: findAllByText /anno-b|Sélection/ -> the properties panel holds Centre x = 20 (anno-b) and owns the focused heading. - editor-shell-layout panel walk: added after.at(-1) === 'side'. - editor-recovery title « Annuler les modifications » -> « Abandonner ». - new: touch/cancel/mouse press, references search crossing, discard keeps lastSave, filter kept, one categories heading, badge 1/2/0, shownRevision.
79 lines
2.7 KiB
TypeScript
79 lines
2.7 KiB
TypeScript
/** AC8: the Vérification tab carries the blocking-error count as text, and nothing at zero. */
|
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
import { act, cleanup, render, screen } from '@testing-library/react'
|
|
import type { SheetIssue } from '@faunosteo/core-wasm/types'
|
|
import EditorTabs from '@/components/editor/EditorTabs'
|
|
import { useLocaleStore } from '@/state/localeStore'
|
|
import { openReady, resetStore, store } from '../helpers/editorHarness'
|
|
|
|
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' }))
|
|
afterEach(() => {
|
|
cleanup()
|
|
resetStore()
|
|
})
|
|
|
|
const issue = (severity: SheetIssue['severity'], at: number): SheetIssue => ({
|
|
code: 'x.y',
|
|
severity,
|
|
path: `annotations[${at}]`,
|
|
message: 'm',
|
|
})
|
|
|
|
function reportIssues(issues: SheetIssue[]) {
|
|
const previewState = store.getState().previewState
|
|
if (!previewState) throw new Error('the editor is not ready')
|
|
act(() =>
|
|
store.setState({
|
|
previewState: {
|
|
...previewState,
|
|
report: { ...previewState.report, issues },
|
|
},
|
|
}),
|
|
)
|
|
}
|
|
|
|
const verificationTab = () => screen.getByRole('tab', { name: /^Vérification/ })
|
|
|
|
describe('the Vérification tab badge', () => {
|
|
it.each([
|
|
[1, 'Vérification 1 erreur'],
|
|
[2, 'Vérification 2 erreurs'],
|
|
])('says « n erreur(s) » for %i blocking error(s)', async (count, name) => {
|
|
await openReady()
|
|
render(<EditorTabs active="general" tier="wide" onSelect={vi.fn()} />)
|
|
reportIssues(
|
|
Array.from({ length: count }, (_, at) => issue('error', at)),
|
|
)
|
|
expect(verificationTab()).toHaveTextContent(new RegExp(`^${name}$`))
|
|
})
|
|
|
|
it('shows nothing at zero, and warnings do not count', async () => {
|
|
await openReady()
|
|
render(<EditorTabs active="general" tier="wide" onSelect={vi.fn()} />)
|
|
reportIssues([])
|
|
expect(verificationTab()).toHaveTextContent(/^Vérification$/)
|
|
reportIssues([issue('warning', 0), issue('warning', 1)])
|
|
expect(verificationTab()).toHaveTextContent(/^Vérification$/)
|
|
expect(screen.queryByText(/erreur/)).toBeNull()
|
|
})
|
|
|
|
it('the other tabs never carry the count', async () => {
|
|
await openReady()
|
|
render(<EditorTabs active="general" tier="wide" onSelect={vi.fn()} />)
|
|
reportIssues([issue('error', 0)])
|
|
expect(screen.getByRole('tab', { name: 'Général' })).toHaveTextContent(
|
|
/^Général$/,
|
|
)
|
|
})
|
|
})
|