openpencil/tests/helpers
Danila Poyarkov 510cdbc36f
feat(scene-graph)!: let a SceneGraph take its ID generator (#887)
* feat(scene-graph): let a SceneGraph take its ID generator

The constructor accepts an ID generator, used for the root node and for
nodes, variables, and collections created later; generated IDs skip any
node, variable, collection, or mode ID already in the graph.

Refs #770

Signed-off-by: Marc Went <marc@went.io>

* perf(scene-graph): check mode IDs without allocating per created entity

Generating an ID spread every collection into a new array and scanned it
for each candidate, which runs on every createNode. Check the node,
variable, and collection maps first and walk the modes with an early exit.
An index of mode IDs is not kept because history snapshots, transfer, and
undo replace collection maps and edit modes in place, which would leave it
stale.

* test(scene-graph): cover injected ID generators and collision skipping

* docs: note the SceneGraph ID generator in the changelog

* test(core): keep reopened .fig GUIDs when a sibling is inserted before them

Refs #770

* test(collab): cover concurrent additions, same-property writes, and delete versus edit

Move the synced-store harness to tests/helpers/collab so the new cases
live in tests/app/collab, and let it bind graph events as a collab session
does. The cases edit both peers while disconnected and check the
converged graphs.

Refs #770

* fix(scene-graph): keep a collection's IDs apart and stop on an exhausted generator

createCollection asks for the collection and default mode IDs before
registering either, so a generator repeating a candidate gave both the
same ID. A generator that only returned taken IDs looped forever, even in
the constructor; it now throws after a bounded number of attempts.

* test: require the inserted GUID and a real disconnect in new tests

The GUID test passed even if export dropped the inserted layer, and the
concurrent-edit helper would have tested sequential sync had its peers
not been disconnectable.

* feat(scene-graph): create variable modes through the graph's ID generator

The editor minted added and duplicated modes as mode:<random hex>, so an
injected generator governed every graph entity except modes added after
a collection's first. SceneGraph.createMode mints the ID and adds the
mode; undo and redo replay it with addMode.

* test(core): type the reopened .fig buffer in the GUID test

* refactor(scene-graph)!: share random helpers and one component property ID

randomHex, randomInt, and randomIndex move from @open-pencil/core/random
to @open-pencil/scene-graph/random, so format packages can use them:
design-jsx and the MCP test server dropped private copies. Component
property IDs, written as prop:<random hex> in six places across Core and
design-jsx, come from createComponentPropertyId.

* docs: point the randomness rule at the shared ID and random helpers

---------

Signed-off-by: Marc Went <marc@went.io>
Co-authored-by: Marc Went <marc@went.io>
2026-10-05 08:21:22 +00:00
..
canvas refactor(design-jsx): extract design JSX into its own package (#793) 2026-09-30 20:55:27 +04:00
chat feat(ai): choose a thinking level per message (#809) 2026-10-03 13:30:05 +04:00
collab feat(scene-graph)!: let a SceneGraph take its ID generator (#887) 2026-10-05 08:21:22 +00:00
fig fix: validate parsed JSON at untrusted boundaries with Valibot (#855) 2026-10-04 17:01:50 +00:00
fonts perf(canvas): reuse labels with shared font fallback 2026-09-15 23:08:53 +03:00
mcp feat(scene-graph)!: let a SceneGraph take its ID generator (#887) 2026-10-05 08:21:22 +00:00
pages feat(app): jump between pages from the command palette (#801) 2026-10-01 20:26:35 +04:00
performance refactor: scope browser test instrumentation and global types (#667) 2026-09-10 14:26:36 +03:00
tauri fix(desktop): allow reading recent .fig files for thumbnails (#872) 2026-10-04 13:03:20 +00:00
vue fix(editor): close preview and history lifecycle gaps 2026-09-16 03:36:44 +03:00
assert.ts
canvas.ts fix(text): finalize font readiness and label shaping (#593) 2026-08-30 14:33:32 +03:00
cli.ts ci: shard unit tests by owner and cut the quick suite from 100 s to 13 s (#715) 2026-09-17 10:18:16 +03:00
code-panel.ts feat(code): add live JSX and HTML/CSS editing (#525) 2026-08-15 09:48:42 +03:00
demo.ts fix: convert document colour profiles, keep text edits live, and fix .fig exports (#716) 2026-09-18 00:43:10 +03:00
dom-css-browser.ts feat: write variables as a CSS token stylesheet (#856) 2026-10-04 18:15:52 +00:00
dom-css.ts refactor!: move shared primitives below dom-css and core (#771) 2026-09-26 11:39:11 +04:00
figma.ts
geometry.ts feat(editor): checkpoint live interaction improvements 2026-09-15 11:36:17 +03:00
large-document.ts perf(scene-graph): accelerate axis-aligned hit tests (#534) 2026-08-16 15:43:25 +03:00
layout.ts
paths.ts Add heuristic overlap detection tool and CLI 2026-06-19 09:54:27 +10:00
properties.ts feat(app): migrate paint effect and export panels 2026-07-14 17:06:28 +03:00
scene.ts test: share scene variable helper 2026-06-30 10:55:05 +03:00
store.ts feat(text): create text boxes by dragging 2026-07-20 21:22:30 +03:00
test-ids.ts
test-utils.ts test: extend timeout for slow gold-preview fixture tests 2026-06-19 11:05:25 +10:00
tools.ts
vector-network.ts
yjs-test-helper.d.ts perf(collab): skip unchanged Yjs node fields (#529) 2026-08-15 11:40:27 +03:00
yjs.ts fix(collab): replicate document content to joiners 2026-06-30 11:56:58 +03:00