refactor(fig): export the symbol readers and move the library tests home (#929)
The Kiwi codec types only symbolID, so every test reading symbolOverrides or uniformScaleFactor repeated the same cast against a type the package exported without the readers that go with it. symbolDataOf and symbolOverridesOf are now exported and five call sites use them. tests/engine/library exercises @/app/libraries, so it belongs under tests/app by the placement rules; the shard list and the engine baseline follow it.
This commit is contained in:
parent
9dce9fdcbc
commit
f7a013191b
|
|
@ -1,4 +1,4 @@
|
|||
import type { SymbolData } from '@open-pencil/fig/instance-overrides'
|
||||
import { symbolOverridesOf } from '@open-pencil/fig/instance-overrides'
|
||||
import type { NodeChange } from '@open-pencil/kiwi/fig/codec'
|
||||
|
||||
import { expectDefined } from '../assert'
|
||||
|
|
@ -13,7 +13,7 @@ export function inheritedNestedBindingRecords(): NodeChange[] {
|
|||
changes.find((node) => node.guid?.sessionID === 293733 && node.guid.localID === 8),
|
||||
'captured owner'
|
||||
)
|
||||
for (const override of (owner.symbolData as SymbolData).symbolOverrides ?? []) {
|
||||
for (const override of symbolOverridesOf(owner)) {
|
||||
Reflect.deleteProperty(override, 'parameterConsumptionMap')
|
||||
}
|
||||
return changes
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { exportFigFile } from '@open-pencil/core/io'
|
|||
import { initCodec } from '@open-pencil/core/kiwi'
|
||||
import { computeAllLayouts } from '@open-pencil/core/layout'
|
||||
import { materializeDocument, parseFigBuffer } from '@open-pencil/fig'
|
||||
import type { SymbolData } from '@open-pencil/fig/instance-overrides'
|
||||
import { symbolOverridesOf } from '@open-pencil/fig/instance-overrides'
|
||||
import type { NodeChange } from '@open-pencil/kiwi/fig/codec'
|
||||
import { hasInstanceOverride } from '@open-pencil/scene-graph'
|
||||
import { NestedLayoutScaleFixture, readFixture } from '#core-tests/helpers/fig/fixtures'
|
||||
|
|
@ -63,7 +63,7 @@ test('scaled padding edits undo and export in the declaring owner space', async
|
|||
(node) => node.type === 'INSTANCE' && node.name === 'Scaled outer'
|
||||
)
|
||||
expect(saved).toBeDefined()
|
||||
const overrides = (saved?.symbolData as SymbolData | undefined)?.symbolOverrides ?? []
|
||||
const overrides = saved ? symbolOverridesOf(saved) : []
|
||||
expect(overrides.some((override) => override.stackHorizontalPadding === 14)).toBe(true)
|
||||
const { graph: reopened } = materializeDocument(parsed.nodeChanges, parsed.blobs, {
|
||||
derivedBounds: true
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { FigmaAPI } from '@open-pencil/core/figma-api'
|
|||
import { exportFigFile } from '@open-pencil/core/io'
|
||||
import { initCodec } from '@open-pencil/core/kiwi'
|
||||
import { materializeDocument, parseFigBuffer } from '@open-pencil/fig'
|
||||
import type { SymbolData } from '@open-pencil/fig/instance-overrides'
|
||||
import { symbolDataOf } from '@open-pencil/fig/instance-overrides'
|
||||
import { setInstanceOverride } from '@open-pencil/scene-graph'
|
||||
|
||||
import { expectDefined } from '#core-tests/helpers/assert'
|
||||
|
|
@ -53,7 +53,7 @@ for (const scale of [0.5, 2]) {
|
|||
const exported = expectDefined(
|
||||
parsed.nodeChanges.find((node) => node.name === 'Rescaled owner')
|
||||
)
|
||||
const symbol = exported.symbolData as SymbolData
|
||||
const symbol = expectDefined(symbolDataOf(exported), 'exported symbol data')
|
||||
const symbolID = expectDefined(symbol.symbolID)
|
||||
expect(
|
||||
symbol.symbolOverrides?.filter((entry) => entry.size).map((entry) => entry.guidPath?.guids)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { expect, test } from 'bun:test'
|
|||
import { exportFigFile } from '@open-pencil/core/io'
|
||||
import { initCodec } from '@open-pencil/core/kiwi'
|
||||
import { parseFigBuffer } from '@open-pencil/fig'
|
||||
import type { SymbolData } from '@open-pencil/fig/instance-overrides'
|
||||
import { symbolDataOf } from '@open-pencil/fig/instance-overrides'
|
||||
import { SceneGraph, setInstanceOverride, rescaleNodeTree } from '@open-pencil/scene-graph'
|
||||
|
||||
import { expectDefined } from '#core-tests/helpers/assert'
|
||||
|
|
@ -25,7 +25,7 @@ test('serializes self size claims against the instance main component', async ()
|
|||
const bytes = await exportFigFile(graph)
|
||||
const { nodeChanges } = parseFigBuffer(bytes.buffer as ArrayBuffer)
|
||||
const exported = nodeChanges.find((node) => node.type === 'INSTANCE')
|
||||
const symbol = exported?.symbolData as SymbolData | undefined
|
||||
const symbol = exported ? symbolDataOf(exported) : undefined
|
||||
if (!symbol) throw new Error('Missing exported symbol')
|
||||
expect(exported?.size).toEqual({ x: 16, y: 16 })
|
||||
expect(symbol.uniformScaleFactor).toBe(0.5)
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@ export { materializeComponentClosure } from './component-closure'
|
|||
export { linkInstanceSourceChildren, mapInstanceSourceChildren } from './source-children'
|
||||
export type { MaterializedInstance } from './materialize-instance'
|
||||
|
||||
/** The Kiwi codec types only `symbolID`, so the remaining symbol fields are read through these. */
|
||||
export { symbolDataOf, symbolOverridesOf } from './types'
|
||||
|
||||
export type {
|
||||
ComponentPropAssignment,
|
||||
ComponentPropDef,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import type { SymbolData } from '@open-pencil/fig/instance-overrides'
|
||||
import { symbolOverridesOf } from '@open-pencil/fig/instance-overrides'
|
||||
import type { NodeChange } from '@open-pencil/kiwi/fig/codec'
|
||||
|
||||
import fixture from '#tests/fixtures/nested-binding-ownership-records.json' with { type: 'json' }
|
||||
|
|
@ -11,7 +11,7 @@ export function inheritedNestedBindingRecords(): NodeChange[] {
|
|||
changes.find((node) => node.guid?.sessionID === 293733 && node.guid.localID === 8),
|
||||
'captured owner'
|
||||
)
|
||||
for (const override of (owner.symbolData as SymbolData).symbolOverrides ?? []) {
|
||||
for (const override of symbolOverridesOf(owner)) {
|
||||
Reflect.deleteProperty(override, 'parameterConsumptionMap')
|
||||
}
|
||||
return changes
|
||||
|
|
|
|||
|
|
@ -311,19 +311,6 @@ tests/engine/layout/auto-layout/text/measurement.test.ts
|
|||
tests/engine/layout/auto-layout/vertical/basic.test.ts
|
||||
tests/engine/layout/auto-layout/wrap/layout.test.ts
|
||||
tests/engine/layout/grid-layout.test.ts
|
||||
tests/engine/library/discovery.test.ts
|
||||
tests/engine/library/hash-normalization.test.ts
|
||||
tests/engine/library/instance-updates.test.ts
|
||||
tests/engine/library/materialize.test.ts
|
||||
tests/engine/library/metadata.test.ts
|
||||
tests/engine/library/preview.test.ts
|
||||
tests/engine/library/routed-catalog.test.ts
|
||||
tests/engine/library/selective.test.ts
|
||||
tests/engine/library/snapshot.test.ts
|
||||
tests/engine/library/source-publication.test.ts
|
||||
tests/engine/library/storage-catalog.test.ts
|
||||
tests/engine/library/update-groups.test.ts
|
||||
tests/engine/library/update.test.ts
|
||||
tests/engine/lint/basic.test.ts
|
||||
tests/engine/lint/variable-binding-validation.test.ts
|
||||
tests/engine/mcp/auth.test.ts
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ export const UNIT_TEST_GROUPS = {
|
|||
'tests/engine/editor',
|
||||
'tests/engine/icons',
|
||||
'tests/engine/layout',
|
||||
'tests/engine/library',
|
||||
'tests/engine/lint',
|
||||
'tests/engine/profiler',
|
||||
'tests/engine/text',
|
||||
|
|
|
|||
Loading…
Reference in a new issue