Skip to content

AI-native design editor. Open-source Figma alternative.

test: share scene variable helper

Danila Poyarkov3a5b6a5c3797
diff --git a/tests/engine/render/jsx/render-tree.test.ts b/tests/engine/render/jsx/render-tree.test.ts
index 234501cad..879cc2ce2 100644
--- a/tests/engine/render/jsx/render-tree.test.ts
+++ b/tests/engine/render/jsx/render-tree.test.ts
@@ -25,34 +25,7 @@ import {
} from '@open-pencil/core'
import { expectDefined, getNodeOrThrow, childIdAt } from '#tests/helpers/assert'
-import { makeSceneGraph } from '#tests/helpers/scene'
-
-function addTestColorVariable(
- graph: ReturnType<typeof makeSceneGraph>,
- id: string,
- name: string,
- value = { r: 1, g: 1, b: 1, a: 1 }
-): void {
- if (!graph.variableCollections.has('colors')) {
- graph.addCollection({
- id: 'colors',
- name: 'Colors',
- modes: [{ modeId: 'light', name: 'Light' }],
- defaultModeId: 'light',
- variableIds: []
- })
- }
-
- graph.addVariable({
- id,
- name,
- type: 'COLOR',
- collectionId: 'colors',
- valuesByMode: { light: value },
- description: '',
- hiddenFromPublishing: false
- })
-}
+import { addTestColorVariable, makeSceneGraph } from '#tests/helpers/scene'
describe('renderTree', () => {
it('renders a simple frame', async () => {
diff --git a/tests/helpers/scene.ts b/tests/helpers/scene.ts
index 59d14798e..b329bd545 100644
--- a/tests/helpers/scene.ts
+++ b/tests/helpers/scene.ts
@@ -1,5 +1,5 @@
import { SceneGraph } from '@open-pencil/core'
-import type { SceneNode } from '@open-pencil/core'
+import type { Color, SceneNode } from '@open-pencil/core'
export function makeSceneGraph(pageName = 'Test'): SceneGraph {
const graph = new SceneGraph()
@@ -11,6 +11,33 @@ export function firstPageId(graph: SceneGraph): string {
return graph.getPages()[0].id
}
+export function addTestColorVariable(
+ graph: SceneGraph,
+ id: string,
+ name: string,
+ value: Color = { r: 1, g: 1, b: 1, a: 1 }
+): void {
+ if (!graph.variableCollections.has('colors')) {
+ graph.addCollection({
+ id: 'colors',
+ name: 'Colors',
+ modes: [{ modeId: 'light', name: 'Light' }],
+ defaultModeId: 'light',
+ variableIds: []
+ })
+ }
+
+ graph.addVariable({
+ id,
+ name,
+ type: 'COLOR',
+ collectionId: 'colors',
+ valuesByMode: { light: value },
+ description: '',
+ hiddenFromPublishing: false
+ })
+}
+
export function createRect(
graph: SceneGraph,
parentId: string,