Files
faunosteo/apps/app/tests/unit/editor-min-point-radius.test.ts
T
bchanot 5ca2b7e3ad feat(domain): per-view minimum point radius in preview state
PreviewState.min_point_radius maps a view id to the smallest point
hitbox radius that passes TooSmall on the smallest preview, so the
sheet editor can mark it on a size slider. Twin constants named in
layer.rs; frame.rs shares one first-view drawing lookup.
2026-11-17 16:33:40 +01:00

37 lines
1.3 KiB
TypeScript

/**
* The core states, per view, the smallest radius a point may have (the sheet editor's size
* slider marks it): the bundled draft's main view, from its frame and the preview size.
*/
import { beforeAll, describe, expect, it } from 'vitest'
import { CataloguePreview } from '@/catalogue/preview'
import { coreRuntime, setCoreRuntime } from '@/core/runtime'
import { bundledSheet } from '../helpers/sheet'
import { testCoreRuntime } from '../helpers/core'
beforeAll(async () => {
setCoreRuntime(await testCoreRuntime())
})
describe('min_point_radius of the preview state', () => {
it('gives the bundled draft its main-view radius, none for an unknown view', async () => {
const bundle = await bundledSheet()
const [assetId] = Object.keys(bundle.assets)
const preview = new CataloguePreview(
coreRuntime(),
{ status: 'draft', document: JSON.stringify(bundle.document) },
[
{
assetId,
sha256: bundle.assetHashes[assetId],
bytes: new TextEncoder().encode(bundle.assets[assetId]),
},
],
)
const state = preview.state()
if (!state.ok) throw new Error(state.kind)
const radii = state.value.min_point_radius
expect(radii['main']).toBeCloseTo(26.5, 1)
expect(radii['nowhere'] ?? null).toBeNull()
})
})