feat(editor): a clear final state once the engine spent its three recoveries (canvas and action alerts)

This commit is contained in:
bchanot committed 2026-10-15 17:58:11 +02:00
1 parent f0580922b5
commit 0279953e9e
19 files changed
+101 -16

No files matched your search

@@ -2,6 +2,9 @@ import { beforeAll, describe, expect, it, vi, afterEach } from 'vitest'
import { cleanup, render, screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import AnatomyCanvas from '@/components/canvas/AnatomyCanvas'
import type { CoreRuntime } from '@faunosteo/core-wasm'
import { coreRuntime, setCoreRuntime } from '@/core/runtime'
import { coreFailureMessage } from '@/core/failure'
import { buildViewSvg } from '@/anatomy/drawing'
import type { SheetIndex } from '@/services/sheetIndex'
import { useLocaleStore } from '@/state/localeStore'
@@ -143,6 +146,23 @@ describe('AnatomyCanvas', () => {
expect(screen.queryByText(fr['sheet.core_unavailable']!)).toBeNull()
})
it('after the recoveries are spent, shows the final state with no retry; alerts say the same', async () => {
useLocaleStore.setState({ locale: 'fr' })
const live = coreRuntime()
setCoreRuntime({ stopped: true } as unknown as CoreRuntime)
try {
const down = Object.create(sheet) as SheetIndex
down.canvasSvg = () => ({ ok: false, kind: 'internal' })
render(<AnatomyCanvas index={down} viewId="main" states={new Map()} onZoneClick={() => undefined} />)
await screen.findByText(fr['core.stopped']!)
expect(screen.queryByRole('button', { name: fr['sheet.core_retry'] })).toBeNull()
expect(coreFailureMessage((k: string) => fr[k]!)).toBe(fr['core.stopped'])
} finally {
setCoreRuntime(live)
}
expect(coreFailureMessage((k: string) => fr[k]!)).toBe(fr['core.action_failed'])
})
it('words both failures in English too', async () => {
useLocaleStore.setState({ locale: 'en' })
const hostile = await sheetDrawing('<svg xmlns="http://www.w3.org/2000/svg"><script/></svg>')