openpencil/tests/app/libraries/update-groups.test.ts
Danila Poyarkov f7a013191b
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.
2026-10-06 10:44:22 +00:00

32 lines
1.1 KiB
TypeScript

import { describe, expect, test } from 'bun:test'
import { SceneGraph } from '@open-pencil/scene-graph'
import { createEditorStore } from '@/app/editor/session'
import { scopeLibraryUpdateGroups } from '@/app/libraries/update-groups'
describe('library update page scopes', () => {
test('filters grouped updates to the current page', () => {
const graph = new SceneGraph()
const firstPage = graph.getPages()[0]
const secondPage = graph.addPage('Second')
const first = graph.createNode('INSTANCE', firstPage.id)
const second = graph.createNode('INSTANCE', secondPage.id)
const editor = createEditorStore(graph)
editor.state.currentPageId = firstPage.id
const groups = [
{
libraryId: 'library',
assetKey: 'button',
name: 'Button',
instanceIds: [first.id, second.id],
currentPageCount: 2,
allPagesCount: 2
}
]
expect(scopeLibraryUpdateGroups(editor, groups, false)[0]?.instanceIds).toEqual([first.id])
expect(scopeLibraryUpdateGroups(editor, groups, true)[0]?.instanceIds).toHaveLength(2)
})
})