chore(lint): fix unused test code
- Remove stale imports and unused locals from split engine and e2e tests - Drop the targeted no-unused-vars test allowances - Keep check and affected test suites warning-free
This commit is contained in:
parent
f2df82285a
commit
9e4d7bee5d
42
oxlint.json
42
oxlint.json
|
|
@ -196,48 +196,6 @@
|
|||
"open-pencil/no-raw-console-format": "error"
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": [
|
||||
"tests/e2e/autosave.spec.ts",
|
||||
"tests/e2e/color-picker/basic.spec.ts",
|
||||
"tests/e2e/context-menu/basic.spec.ts",
|
||||
"tests/e2e/layers/panel.spec.ts",
|
||||
"tests/e2e/pages/multi-page.spec.ts",
|
||||
"tests/e2e/properties/panel.spec.ts",
|
||||
"tests/engine/cli/eval.test.ts",
|
||||
"tests/engine/color/okhcl/ui-logic.test.ts",
|
||||
"tests/engine/color/solid-commit.test.ts",
|
||||
"tests/engine/editor/selection/alignment.test.ts",
|
||||
"tests/engine/editor/selection/properties.test.ts",
|
||||
"tests/engine/fig/export/text.test.ts",
|
||||
"tests/engine/fig/heavy/fixtures.test.ts",
|
||||
"tests/engine/fig/import/basic.test.ts",
|
||||
"tests/engine/fig/import/edge-cases.test.ts",
|
||||
"tests/engine/fig/import/instance-regressions.test.ts",
|
||||
"tests/engine/fig/import/property-integrity.test.ts",
|
||||
"tests/engine/fig/roundtrip/basic.test.ts",
|
||||
"tests/engine/fig/roundtrip/variables.test.ts",
|
||||
"tests/engine/hit-test/basic.test.ts",
|
||||
"tests/engine/hit-test/scope.test.ts",
|
||||
"tests/engine/kiwi/serialize-fixes.test.ts",
|
||||
"tests/engine/layout/auto-layout.test.ts",
|
||||
"tests/engine/mcp.test.ts",
|
||||
"tests/engine/mcp/stdio.test.ts",
|
||||
"tests/engine/render/canvas/silhouette-autopsy.test.ts",
|
||||
"tests/engine/scene-graph/basic.test.ts",
|
||||
"tests/engine/scene-graph/world-transform.test.ts",
|
||||
"tests/engine/svg/export.test.ts",
|
||||
"tests/engine/text/style-runs.test.ts",
|
||||
"tests/engine/tools/ai-adapter.test.ts",
|
||||
"tests/engine/tools/cli.test.ts",
|
||||
"tests/engine/tools/modify.test.ts",
|
||||
"tests/engine/tools/registry.test.ts",
|
||||
"tests/engine/visual-inner-shadow-counter.ts"
|
||||
],
|
||||
"rules": {
|
||||
"no-unused-vars": "off"
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": [
|
||||
"tests/e2e/perf/basic.spec.ts",
|
||||
|
|
|
|||
|
|
@ -42,7 +42,6 @@ test('autosave triggers after scene changes with a file handle', async () => {
|
|||
// Inject the file handle into the store's internal state
|
||||
// We do this by calling a save first to establish the handle
|
||||
await page.evaluate(() => {
|
||||
const store = window.__OPEN_PENCIL_STORE__!
|
||||
// Directly set the fileHandle via a test hook
|
||||
// Since fileHandle is a closure variable, we need to trigger the save path
|
||||
// The cleanest way: mock showSaveFilePicker to return our handle
|
||||
|
|
|
|||
|
|
@ -18,13 +18,6 @@ test.afterAll(async () => {
|
|||
await page.close()
|
||||
})
|
||||
|
||||
async function getSelectedId() {
|
||||
return page.evaluate(() => {
|
||||
const store = window.__OPEN_PENCIL_STORE__!
|
||||
return [...store.state.selectedIds][0] ?? null
|
||||
})
|
||||
}
|
||||
|
||||
async function getSelectedFill() {
|
||||
return page.evaluate(() => {
|
||||
const store = window.__OPEN_PENCIL_STORE__!
|
||||
|
|
|
|||
|
|
@ -116,10 +116,10 @@ test('toggle visibility via context menu', async () => {
|
|||
expect(hidden!.visible).toBe(false)
|
||||
|
||||
// Toggle back: select via store since invisible nodes can't be hit-tested
|
||||
await page.evaluate((id) => {
|
||||
await page.evaluate(() => {
|
||||
const store = window.__OPEN_PENCIL_STORE__!
|
||||
store.toggleVisibility()
|
||||
}, nodeId)
|
||||
})
|
||||
await canvas.waitForRender()
|
||||
|
||||
const restored = await page.evaluate((id) => {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { test, expect, type Page } from '@playwright/test'
|
||||
import { expect, test, type Page } from '@playwright/test'
|
||||
|
||||
import { CanvasHelper } from '#tests/helpers/canvas'
|
||||
|
||||
|
|
@ -140,7 +140,6 @@ test('grouping updates layers', async () => {
|
|||
await canvas.drawRect(800, 600, 60, 60)
|
||||
await canvas.selectAll()
|
||||
|
||||
const beforeCount = await getSelectedCount()
|
||||
await page.keyboard.press('Meta+g')
|
||||
await canvas.waitForRender()
|
||||
|
||||
|
|
|
|||
|
|
@ -134,7 +134,6 @@ test('delete current page switches to adjacent', async () => {
|
|||
})
|
||||
|
||||
test('rename page via store', async () => {
|
||||
const pages = await getPages()
|
||||
const currentId = await getCurrentPageId()
|
||||
|
||||
await page.evaluate(
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { test, expect, type Page } from '@playwright/test'
|
||||
import { expect, test, type Page } from '@playwright/test'
|
||||
|
||||
import { CanvasHelper } from '#tests/helpers/canvas'
|
||||
import { getSelectedNode, getPageChildren } from '#tests/helpers/store'
|
||||
import { getPageChildren, getSelectedNode } from '#tests/helpers/store'
|
||||
|
||||
let page: Page
|
||||
let canvas: CanvasHelper
|
||||
|
|
@ -114,7 +114,7 @@ test('fill color can bind an existing variable', async () => {
|
|||
await canvas.clearCanvas()
|
||||
await canvas.drawRect(200, 200, 80, 80)
|
||||
|
||||
const variableId = await page.evaluate(() => {
|
||||
await page.evaluate(() => {
|
||||
const store = window.__OPEN_PENCIL_STORE__!
|
||||
const col = store.graph.createCollection('Colors')
|
||||
const variable = store.graph.createVariable('test-brand-red', 'COLOR', col.id, {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { describe, expect, test, setDefaultTimeout } from 'bun:test'
|
||||
import { expect, setDefaultTimeout, test } from 'bun:test'
|
||||
import { randomUUID } from 'crypto'
|
||||
import { tmpdir } from 'os'
|
||||
import { join } from 'path'
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import {
|
|||
setNodeStrokeOkHCL
|
||||
} from '@open-pencil/core'
|
||||
|
||||
import { expectDefined, getNodeOrThrow } from '#tests/helpers/assert'
|
||||
import { getNodeOrThrow } from '#tests/helpers/assert'
|
||||
|
||||
describe('OkHCL metadata toggling', () => {
|
||||
test('can disable fill OkHCL metadata', () => {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { describe, expect, test } from 'bun:test'
|
||||
|
||||
import type { Fill, Stroke } from '@open-pencil/core'
|
||||
import type { Fill } from '@open-pencil/core'
|
||||
import { applySolidFillColor, applySolidStrokeColor } from '@open-pencil/vue'
|
||||
|
||||
describe('solid color commit helpers', () => {
|
||||
|
|
@ -18,14 +18,6 @@ describe('solid color commit helpers', () => {
|
|||
})
|
||||
|
||||
test('syncs stroke opacity with color alpha', () => {
|
||||
const stroke: Stroke = {
|
||||
color: { r: 0, g: 0, b: 1, a: 1 },
|
||||
weight: 1,
|
||||
opacity: 1,
|
||||
visible: true,
|
||||
align: 'CENTER'
|
||||
}
|
||||
|
||||
const updated = applySolidStrokeColor({ r: 1, g: 1, b: 0, a: 0.2 })
|
||||
expect(updated.color?.a).toBeCloseTo(0.2, 5)
|
||||
expect(updated.opacity).toBeCloseTo(0.2, 5)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { describe, expect, test } from 'bun:test'
|
|||
|
||||
import { SceneGraph } from '@open-pencil/core'
|
||||
|
||||
import { expectDefined, getNodeOrThrow } from '#tests/helpers/assert'
|
||||
import { getNodeOrThrow } from '#tests/helpers/assert'
|
||||
import { createRect, firstPageId } from '#tests/helpers/scene'
|
||||
|
||||
describe('single-node alignment to parent', () => {
|
||||
|
|
@ -26,7 +26,7 @@ describe('single-node alignment to parent', () => {
|
|||
}
|
||||
|
||||
test('align left within parent', () => {
|
||||
const { graph, frame, child } = setup()
|
||||
const { graph, child } = setup()
|
||||
graph.updateNode(child.id, { x: 0 })
|
||||
expect(getNodeOrThrow(graph, child.id).x).toBe(0)
|
||||
})
|
||||
|
|
@ -80,7 +80,7 @@ describe('multi-node alignment', () => {
|
|||
const { graph, a, b, c } = setup()
|
||||
const nodes = [a, b, c].map((n) => getNodeOrThrow(graph, n.id))
|
||||
const abs = nodes.map((n) => graph.getAbsolutePosition(n.id))
|
||||
const minX = Math.min(...abs.map((p, i) => p.x))
|
||||
const minX = Math.min(...abs.map((p) => p.x))
|
||||
|
||||
for (const n of nodes) {
|
||||
const nodeAbs = graph.getAbsolutePosition(n.id)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { describe, expect, test } from 'bun:test'
|
|||
|
||||
import { SceneGraph } from '@open-pencil/core'
|
||||
|
||||
import { expectDefined, getNodeOrThrow } from '#tests/helpers/assert'
|
||||
import { getNodeOrThrow } from '#tests/helpers/assert'
|
||||
import { createRect, firstPageId } from '#tests/helpers/scene'
|
||||
|
||||
describe('multi-node property merging', () => {
|
||||
|
|
|
|||
|
|
@ -1,34 +1,9 @@
|
|||
import { beforeAll, describe, expect, setDefaultTimeout, test } from 'bun:test'
|
||||
import { describe, expect, setDefaultTimeout, test } from 'bun:test'
|
||||
|
||||
import {
|
||||
parseFigFile,
|
||||
computeAllLayouts,
|
||||
exportFigFile,
|
||||
importNodeChanges,
|
||||
initCodec,
|
||||
SceneGraph,
|
||||
FigmaAPI,
|
||||
type SceneNode,
|
||||
type Fill
|
||||
} from '@open-pencil/core'
|
||||
|
||||
import { computeContentBounds } from '#core/io/formats/raster/render'
|
||||
import { exportFigFile, initCodec, parseFigFile, SceneGraph } from '@open-pencil/core'
|
||||
|
||||
import { expectDefined } from '#tests/helpers/assert'
|
||||
import {
|
||||
FIXTURES,
|
||||
parseFixture,
|
||||
parseGoldPreviewFixture,
|
||||
VALID_NODE_TYPES
|
||||
} from '#tests/helpers/fig-fixtures'
|
||||
import {
|
||||
childMatching,
|
||||
childNamed,
|
||||
collectAllNodes,
|
||||
countByType,
|
||||
previewChild
|
||||
} from '#tests/helpers/fig-traversal'
|
||||
import { heavy } from '#tests/helpers/test-utils'
|
||||
import { parseFixture } from '#tests/helpers/fig-fixtures'
|
||||
|
||||
setDefaultTimeout(60_000)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,32 +1,9 @@
|
|||
import { beforeAll, describe, expect, setDefaultTimeout, test } from 'bun:test'
|
||||
import { beforeAll, expect, setDefaultTimeout, test } from 'bun:test'
|
||||
|
||||
import {
|
||||
parseFigFile,
|
||||
computeAllLayouts,
|
||||
exportFigFile,
|
||||
importNodeChanges,
|
||||
initCodec,
|
||||
SceneGraph,
|
||||
FigmaAPI,
|
||||
type SceneNode,
|
||||
type Fill
|
||||
} from '@open-pencil/core'
|
||||
import { SceneGraph, type SceneNode } from '@open-pencil/core'
|
||||
|
||||
import { computeContentBounds } from '#core/io/formats/raster/render'
|
||||
|
||||
import { expectDefined } from '#tests/helpers/assert'
|
||||
import {
|
||||
parseFixture,
|
||||
parseGoldPreviewFixture,
|
||||
VALID_NODE_TYPES
|
||||
} from '#tests/helpers/fig-fixtures'
|
||||
import {
|
||||
childMatching,
|
||||
childNamed,
|
||||
collectAllNodes,
|
||||
countByType,
|
||||
previewChild
|
||||
} from '#tests/helpers/fig-traversal'
|
||||
import { parseFixture, VALID_NODE_TYPES } from '#tests/helpers/fig-fixtures'
|
||||
import { collectAllNodes } from '#tests/helpers/fig-traversal'
|
||||
import { heavy } from '#tests/helpers/test-utils'
|
||||
|
||||
setDefaultTimeout(60_000)
|
||||
|
|
|
|||
|
|
@ -1,34 +1,8 @@
|
|||
import { beforeAll, describe, expect, setDefaultTimeout, test } from 'bun:test'
|
||||
|
||||
import {
|
||||
parseFigFile,
|
||||
computeAllLayouts,
|
||||
exportFigFile,
|
||||
importNodeChanges,
|
||||
initCodec,
|
||||
SceneGraph,
|
||||
FigmaAPI,
|
||||
type SceneNode,
|
||||
type Fill
|
||||
} from '@open-pencil/core'
|
||||
import { SceneGraph, type SceneNode } from '@open-pencil/core'
|
||||
|
||||
import { computeContentBounds } from '#core/io/formats/raster/render'
|
||||
|
||||
import { expectDefined } from '#tests/helpers/assert'
|
||||
import {
|
||||
FIXTURES,
|
||||
parseFixture,
|
||||
parseGoldPreviewFixture,
|
||||
VALID_NODE_TYPES
|
||||
} from '#tests/helpers/fig-fixtures'
|
||||
import {
|
||||
childMatching,
|
||||
childNamed,
|
||||
collectAllNodes,
|
||||
countByType,
|
||||
previewChild
|
||||
} from '#tests/helpers/fig-traversal'
|
||||
import { heavy } from '#tests/helpers/test-utils'
|
||||
import { parseGoldPreviewFixture, VALID_NODE_TYPES } from '#tests/helpers/fig-fixtures'
|
||||
|
||||
setDefaultTimeout(60_000)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,34 +1,9 @@
|
|||
import { beforeAll, describe, expect, setDefaultTimeout, test } from 'bun:test'
|
||||
import { describe, expect, setDefaultTimeout, test } from 'bun:test'
|
||||
|
||||
import {
|
||||
parseFigFile,
|
||||
computeAllLayouts,
|
||||
exportFigFile,
|
||||
importNodeChanges,
|
||||
initCodec,
|
||||
SceneGraph,
|
||||
FigmaAPI,
|
||||
type SceneNode,
|
||||
type Fill
|
||||
} from '@open-pencil/core'
|
||||
|
||||
import { computeContentBounds } from '#core/io/formats/raster/render'
|
||||
import { importNodeChanges, parseFigFile } from '@open-pencil/core'
|
||||
|
||||
import { expectDefined } from '#tests/helpers/assert'
|
||||
import {
|
||||
FIXTURES,
|
||||
parseFixture,
|
||||
parseGoldPreviewFixture,
|
||||
VALID_NODE_TYPES
|
||||
} from '#tests/helpers/fig-fixtures'
|
||||
import {
|
||||
childMatching,
|
||||
childNamed,
|
||||
collectAllNodes,
|
||||
countByType,
|
||||
previewChild
|
||||
} from '#tests/helpers/fig-traversal'
|
||||
import { heavy } from '#tests/helpers/test-utils'
|
||||
import { parseFixture } from '#tests/helpers/fig-fixtures'
|
||||
|
||||
setDefaultTimeout(60_000)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,46 +1,19 @@
|
|||
import { beforeAll, describe, expect, setDefaultTimeout, test } from 'bun:test'
|
||||
|
||||
import {
|
||||
parseFigFile,
|
||||
computeAllLayouts,
|
||||
exportFigFile,
|
||||
importNodeChanges,
|
||||
initCodec,
|
||||
FigmaAPI,
|
||||
type SceneGraph,
|
||||
type SceneNode,
|
||||
type Fill
|
||||
} from '@open-pencil/core'
|
||||
import { computeAllLayouts, type SceneGraph, type SceneNode } from '@open-pencil/core'
|
||||
|
||||
import { computeContentBounds } from '#core/io/formats/raster/render'
|
||||
|
||||
import { expectDefined } from '#tests/helpers/assert'
|
||||
import {
|
||||
FIXTURES,
|
||||
parseFixture,
|
||||
parseGoldPreviewFixture,
|
||||
VALID_NODE_TYPES
|
||||
} from '#tests/helpers/fig-fixtures'
|
||||
import { parseFixture } from '#tests/helpers/fig-fixtures'
|
||||
import {
|
||||
childMatching,
|
||||
childNamed,
|
||||
collectAllNodes,
|
||||
countByType,
|
||||
previewChild
|
||||
} from '#tests/helpers/fig-traversal'
|
||||
import { heavy } from '#tests/helpers/test-utils'
|
||||
|
||||
setDefaultTimeout(60_000)
|
||||
|
||||
let parsed: SceneGraph
|
||||
let allNodes: SceneNode[]
|
||||
|
||||
beforeAll(async () => {
|
||||
const fixture = await parseGoldPreviewFixture()
|
||||
parsed = fixture.graph
|
||||
allNodes = fixture.allNodes
|
||||
})
|
||||
|
||||
describe('derived instance layout regressions', () => {
|
||||
let layoutGraph: SceneGraph
|
||||
let layoutNodes: SceneNode[]
|
||||
|
|
|
|||
|
|
@ -1,42 +1,15 @@
|
|||
import { beforeAll, describe, expect, setDefaultTimeout, test } from 'bun:test'
|
||||
|
||||
import {
|
||||
parseFigFile,
|
||||
computeAllLayouts,
|
||||
exportFigFile,
|
||||
importNodeChanges,
|
||||
initCodec,
|
||||
FigmaAPI,
|
||||
type SceneGraph,
|
||||
type SceneNode,
|
||||
type Fill
|
||||
} from '@open-pencil/core'
|
||||
import { type Fill, type SceneNode } from '@open-pencil/core'
|
||||
|
||||
import { computeContentBounds } from '#core/io/formats/raster/render'
|
||||
|
||||
import { expectDefined } from '#tests/helpers/assert'
|
||||
import {
|
||||
parseFixture,
|
||||
parseGoldPreviewFixture,
|
||||
VALID_NODE_TYPES
|
||||
} from '#tests/helpers/fig-fixtures'
|
||||
import {
|
||||
childMatching,
|
||||
childNamed,
|
||||
collectAllNodes,
|
||||
countByType,
|
||||
previewChild
|
||||
} from '#tests/helpers/fig-traversal'
|
||||
import { heavy } from '#tests/helpers/test-utils'
|
||||
import { parseGoldPreviewFixture } from '#tests/helpers/fig-fixtures'
|
||||
|
||||
setDefaultTimeout(60_000)
|
||||
|
||||
let parsed: SceneGraph
|
||||
let allNodes: SceneNode[]
|
||||
|
||||
beforeAll(async () => {
|
||||
const fixture = await parseGoldPreviewFixture()
|
||||
parsed = fixture.graph
|
||||
allNodes = fixture.allNodes
|
||||
})
|
||||
|
||||
|
|
@ -82,7 +55,7 @@ describe('property integrity', () => {
|
|||
})
|
||||
|
||||
test('fills have valid colors', () => {
|
||||
function checkFill(fill: Fill, nodeName: string) {
|
||||
function checkFill(fill: Fill) {
|
||||
if (fill.type === 'SOLID') {
|
||||
const { r, g, b, a } = fill.color
|
||||
expect(r).toBeGreaterThanOrEqual(0)
|
||||
|
|
@ -97,7 +70,7 @@ describe('property integrity', () => {
|
|||
}
|
||||
for (const n of allNodes) {
|
||||
for (const fill of n.fills) {
|
||||
checkFill(fill, n.name)
|
||||
checkFill(fill)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,34 +1,15 @@
|
|||
import { beforeAll, describe, expect, setDefaultTimeout, test } from 'bun:test'
|
||||
|
||||
import {
|
||||
parseFigFile,
|
||||
computeAllLayouts,
|
||||
exportFigFile,
|
||||
importNodeChanges,
|
||||
initCodec,
|
||||
parseFigFile,
|
||||
SceneGraph,
|
||||
FigmaAPI,
|
||||
type SceneNode,
|
||||
type Fill
|
||||
type SceneNode
|
||||
} from '@open-pencil/core'
|
||||
|
||||
import { computeContentBounds } from '#core/io/formats/raster/render'
|
||||
|
||||
import { expectDefined } from '#tests/helpers/assert'
|
||||
import {
|
||||
FIXTURES,
|
||||
parseFixture,
|
||||
parseGoldPreviewFixture,
|
||||
VALID_NODE_TYPES
|
||||
} from '#tests/helpers/fig-fixtures'
|
||||
import {
|
||||
childMatching,
|
||||
childNamed,
|
||||
collectAllNodes,
|
||||
countByType,
|
||||
previewChild
|
||||
} from '#tests/helpers/fig-traversal'
|
||||
import { heavy } from '#tests/helpers/test-utils'
|
||||
import { collectAllNodes, countByType } from '#tests/helpers/fig-traversal'
|
||||
|
||||
setDefaultTimeout(60_000)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,35 +1,16 @@
|
|||
import { beforeAll, describe, expect, setDefaultTimeout, test } from 'bun:test'
|
||||
import { describe, expect, setDefaultTimeout, test } from 'bun:test'
|
||||
|
||||
import {
|
||||
parseFigFile,
|
||||
computeAllLayouts,
|
||||
exportFigFile,
|
||||
importNodeChanges,
|
||||
initCodec,
|
||||
SceneGraph,
|
||||
FigmaAPI,
|
||||
type SceneNode,
|
||||
type Fill,
|
||||
initCodec,
|
||||
parseFigFile,
|
||||
SceneGraph,
|
||||
type Color
|
||||
} from '@open-pencil/core'
|
||||
|
||||
import { computeContentBounds } from '#core/io/formats/raster/render'
|
||||
|
||||
import { expectDefined } from '#tests/helpers/assert'
|
||||
import {
|
||||
FIXTURES,
|
||||
parseFixture,
|
||||
parseGoldPreviewFixture,
|
||||
VALID_NODE_TYPES
|
||||
} from '#tests/helpers/fig-fixtures'
|
||||
import {
|
||||
childMatching,
|
||||
childNamed,
|
||||
collectAllNodes,
|
||||
countByType,
|
||||
previewChild
|
||||
} from '#tests/helpers/fig-traversal'
|
||||
import { heavy } from '#tests/helpers/test-utils'
|
||||
import { parseFixture } from '#tests/helpers/fig-fixtures'
|
||||
|
||||
setDefaultTimeout(60_000)
|
||||
|
||||
|
|
|
|||
|
|
@ -139,7 +139,6 @@ describe('hitTest — opacity', () => {
|
|||
describe('hitTest — point outside all nodes', () => {
|
||||
test('returns null for empty area', () => {
|
||||
const graph = new SceneGraph()
|
||||
const page = pageId(graph)
|
||||
|
||||
const hit = graph.hitTest(500, 500)
|
||||
expect(hit).toBeNull()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { describe, test, expect } from 'bun:test'
|
||||
import { describe, expect, test } from 'bun:test'
|
||||
|
||||
import { SceneGraph } from '@open-pencil/core'
|
||||
|
||||
|
|
@ -28,7 +28,7 @@ describe('hitTest — group behavior', () => {
|
|||
}
|
||||
|
||||
test('single click on child returns GROUP (not child)', () => {
|
||||
const { graph, page, child } = setup()
|
||||
const { graph, page } = setup()
|
||||
const hit = graph.hitTest(110, 110, page)
|
||||
expect(hit).not.toBeNull()
|
||||
expect(hit!.type).toBe('GROUP')
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import { describe, test, expect, beforeAll } from 'bun:test'
|
||||
import { beforeAll, describe, expect, test } from 'bun:test'
|
||||
|
||||
import {
|
||||
SceneGraph,
|
||||
sceneNodeToKiwi,
|
||||
exportFigFile,
|
||||
initCodec,
|
||||
parseFigFile,
|
||||
initCodec
|
||||
SceneGraph,
|
||||
sceneNodeToKiwi
|
||||
} from '@open-pencil/core'
|
||||
|
||||
beforeAll(async () => {
|
||||
|
|
@ -44,7 +44,7 @@ describe('Fix 1: auto-layout child transforms', () => {
|
|||
paddingRight: 16
|
||||
})
|
||||
|
||||
const child = graph.createNode('FRAME', parent.id, {
|
||||
graph.createNode('FRAME', parent.id, {
|
||||
name: 'Child',
|
||||
x: 50,
|
||||
y: 100,
|
||||
|
|
@ -82,7 +82,7 @@ describe('Fix 1: auto-layout child transforms', () => {
|
|||
itemSpacing: 8
|
||||
})
|
||||
|
||||
const absChild = graph.createNode('FRAME', parent.id, {
|
||||
graph.createNode('FRAME', parent.id, {
|
||||
name: 'AbsChild',
|
||||
x: 75,
|
||||
y: 120,
|
||||
|
|
@ -118,7 +118,7 @@ describe('Fix 1: auto-layout child transforms', () => {
|
|||
// layoutMode defaults to 'NONE'
|
||||
})
|
||||
|
||||
const child = graph.createNode('FRAME', parent.id, {
|
||||
graph.createNode('FRAME', parent.id, {
|
||||
name: 'Child',
|
||||
x: 30,
|
||||
y: 45,
|
||||
|
|
@ -591,7 +591,7 @@ describe('Directionality plugin fallback', () => {
|
|||
width: 240,
|
||||
height: 80
|
||||
})
|
||||
const text = graph.createNode('TEXT', frame.id, {
|
||||
graph.createNode('TEXT', frame.id, {
|
||||
text: 'مرحبا',
|
||||
textDirection: 'RTL',
|
||||
width: 120,
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
import { describe, expect, test } from 'bun:test'
|
||||
|
||||
import {
|
||||
computeLayout,
|
||||
computeAllLayouts,
|
||||
computeLayout,
|
||||
createEditor,
|
||||
FigmaAPI,
|
||||
SceneGraph,
|
||||
setTextMeasurer
|
||||
} from '@open-pencil/core'
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ describe('MCP tool execution', () => {
|
|||
name: 'Parent'
|
||||
}) as { id: string }
|
||||
|
||||
const child = findTool('create_shape').execute(api, {
|
||||
findTool('create_shape').execute(api, {
|
||||
type: 'TEXT',
|
||||
x: 0,
|
||||
y: 0,
|
||||
|
|
@ -128,7 +128,7 @@ describe('MCP tool execution', () => {
|
|||
height: 30,
|
||||
name: 'Child',
|
||||
parent_id: parent.id
|
||||
}) as { id: string }
|
||||
})
|
||||
|
||||
const tree = findTool('get_page_tree').execute(api, {}) as {
|
||||
children: { id: string; children?: unknown[] }[]
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { describe, expect, test, beforeEach, afterEach } from 'bun:test'
|
||||
import { afterEach, beforeEach, describe, expect, test } from 'bun:test'
|
||||
import type { AddressInfo } from 'node:net'
|
||||
|
||||
import type { Client } from '@modelcontextprotocol/sdk/client/index.js'
|
||||
|
|
@ -161,7 +161,6 @@ describe('MCP stdio transport', () => {
|
|||
expect(data.type).toBe('FRAME')
|
||||
expect(data.name).toBe('StdioFrame')
|
||||
|
||||
const node = app.graph.getNode(data.id)
|
||||
expect(getNodeOrThrow(app.graph, data.id).width).toBe(200)
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -19,12 +19,7 @@ import { SkiaRenderer } from '#core/canvas'
|
|||
import { SceneGraph } from '#core/scene-graph'
|
||||
import { fontManager } from '#core/text'
|
||||
|
||||
import {
|
||||
cliSourcePath,
|
||||
coreSourcePath,
|
||||
publicPath,
|
||||
testPath as repoTestPath
|
||||
} from '#tests/helpers/paths'
|
||||
import { coreSourcePath, publicPath, testPath as repoTestPath } from '#tests/helpers/paths'
|
||||
|
||||
// === CLAIM EXTRACTION ===
|
||||
// Each claim is: [doc_section, claim_text, verification_strategy]
|
||||
|
|
@ -499,7 +494,7 @@ describe('Doc 01/03 — Runtime Behavior Verification', () => {
|
|||
]
|
||||
})
|
||||
|
||||
const child = graph.createNode('RECTANGLE', parentWithFill.id, {
|
||||
graph.createNode('RECTANGLE', parentWithFill.id, {
|
||||
x: 25,
|
||||
y: 25,
|
||||
width: 50,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { describe, test, expect } from 'bun:test'
|
||||
import { describe, expect, test } from 'bun:test'
|
||||
|
||||
import { SceneGraph } from '@open-pencil/core'
|
||||
|
||||
|
|
@ -801,7 +801,7 @@ describe('hitTest', () => {
|
|||
test('hidden node is not hittable', () => {
|
||||
const graph = new SceneGraph()
|
||||
const page = pageId(graph)
|
||||
const rectId = graph.createNode('RECTANGLE', page, {
|
||||
graph.createNode('RECTANGLE', page, {
|
||||
name: 'Hidden',
|
||||
x: 0,
|
||||
y: 0,
|
||||
|
|
@ -809,7 +809,7 @@ describe('hitTest', () => {
|
|||
height: 100,
|
||||
fills: [{ type: 'SOLID', color: { r: 1, g: 0, b: 0, a: 1 }, opacity: 1, visible: true }],
|
||||
visible: false
|
||||
}).id
|
||||
})
|
||||
// Hidden nodes should be skipped during hit testing
|
||||
expect(graph.hitTest(50, 50, page)).toBeNull()
|
||||
})
|
||||
|
|
@ -851,7 +851,6 @@ describe('hitTest', () => {
|
|||
describe('updateNode', () => {
|
||||
test('non-layout change does not clear absPosCache', () => {
|
||||
const graph = new SceneGraph()
|
||||
const page = pageId(graph)
|
||||
const rId = rect(graph, 'R', 100, 200)
|
||||
// Populate absPosCache by calling getAbsolutePosition
|
||||
const absPos = graph.getAbsolutePosition(rId)
|
||||
|
|
@ -865,7 +864,6 @@ describe('updateNode', () => {
|
|||
|
||||
test('layout change clears absPosCache', () => {
|
||||
const graph = new SceneGraph()
|
||||
const page = pageId(graph)
|
||||
const rId = rect(graph, 'R', 100, 200)
|
||||
const absPos = graph.getAbsolutePosition(rId)
|
||||
expect(absPos).toEqual({ x: 100, y: 200 })
|
||||
|
|
@ -1107,7 +1105,6 @@ describe('countDescendants', () => {
|
|||
|
||||
test('root node count includes all pages and their children', () => {
|
||||
const graph = new SceneGraph()
|
||||
const page = pageId(graph)
|
||||
rect(graph, 'R1')
|
||||
rect(graph, 'R2')
|
||||
graph.addPage('Page 2')
|
||||
|
|
|
|||
|
|
@ -5,10 +5,9 @@
|
|||
* correct world coordinates for rotated, flipped, and nested nodes.
|
||||
* The tests exercise the full transform chain through the SceneGraph API.
|
||||
*/
|
||||
import { describe, test, expect } from 'bun:test'
|
||||
import { describe, expect, test } from 'bun:test'
|
||||
|
||||
import { SceneGraph, getWorldMatrix, TransformMatrix } from '@open-pencil/core'
|
||||
import type { SceneNode } from '@open-pencil/core'
|
||||
import { getWorldMatrix, SceneGraph, TransformMatrix } from '@open-pencil/core'
|
||||
|
||||
function pageId(graph: SceneGraph) {
|
||||
return graph.getPages()[0].id
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@ import { describe, expect, test } from 'bun:test'
|
|||
|
||||
import {
|
||||
SceneGraph,
|
||||
renderNodesToSVG,
|
||||
geometryBlobToSVGPath,
|
||||
vectorNetworkToSVGPaths,
|
||||
renderNodesToSVG,
|
||||
renderSVGNode,
|
||||
svg,
|
||||
renderSVGNode
|
||||
vectorNetworkToSVGPaths
|
||||
} from '@open-pencil/core'
|
||||
|
||||
function makeGraph() {
|
||||
|
|
@ -69,16 +69,6 @@ describe('svg() and renderSVGNode()', () => {
|
|||
// --- geometryBlobToSVGPath tests ---
|
||||
|
||||
describe('geometryBlobToSVGPath()', () => {
|
||||
function makeBlob(commands: number[]): Uint8Array {
|
||||
const buf = new ArrayBuffer(commands.length)
|
||||
const view = new DataView(buf)
|
||||
let o = 0
|
||||
for (const cmd of commands) {
|
||||
view.setUint8(o++, cmd)
|
||||
}
|
||||
return new Uint8Array(buf)
|
||||
}
|
||||
|
||||
function makeBlobWithFloats(ops: Array<{ cmd: number; floats?: number[] }>): Uint8Array {
|
||||
let size = 0
|
||||
for (const op of ops) {
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
import { describe, test, expect } from 'bun:test'
|
||||
import { describe, expect, test } from 'bun:test'
|
||||
|
||||
import {
|
||||
getStyleAt,
|
||||
adjustRunsForDelete,
|
||||
adjustRunsForInsert,
|
||||
applyStyleToRange,
|
||||
getStyleAt,
|
||||
removeStyleFromRange,
|
||||
selectionHasStyle,
|
||||
adjustRunsForInsert,
|
||||
adjustRunsForDelete,
|
||||
toggleBoldInRange,
|
||||
toggleItalicInRange,
|
||||
toggleDecorationInRange,
|
||||
toggleItalicInRange,
|
||||
type StyleRun
|
||||
} from '@open-pencil/core'
|
||||
|
||||
|
|
@ -124,7 +124,7 @@ describe('toggleBoldInRange', () => {
|
|||
|
||||
test('bold to non-bold', () => {
|
||||
const existing: StyleRun[] = [{ start: 0, length: 5, style: { fontWeight: 700 } }]
|
||||
const { runs, newWeight } = toggleBoldInRange(existing, 0, 5, 400, 10)
|
||||
const { newWeight } = toggleBoldInRange(existing, 0, 5, 400, 10)
|
||||
expect(newWeight).toBe(400)
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ describe('AI adapter', () => {
|
|||
|
||||
test('each tool has description and execute', () => {
|
||||
const { tools } = setup()
|
||||
for (const [name, t] of Object.entries(tools)) {
|
||||
for (const t of Object.values(tools)) {
|
||||
const aiTool = t as AdapterTool
|
||||
expect(aiTool.description).toBeTruthy()
|
||||
expect(typeof aiTool.execute).toBe('function')
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import { describe, expect, test, setDefaultTimeout } from 'bun:test'
|
||||
import { join } from 'path'
|
||||
import { expect, setDefaultTimeout, test } from 'bun:test'
|
||||
|
||||
import { cliSourcePath, repoPath } from '#tests/helpers/paths'
|
||||
import { heavy } from '#tests/helpers/test-utils'
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { describe, expect, test } from 'bun:test'
|
|||
|
||||
import { computeAllLayouts } from '@open-pencil/core'
|
||||
|
||||
import { ALL_TOOLS, getTool, setupToolTest, type ToolResult } from '#tests/helpers/tools'
|
||||
import { getTool, setupToolTest, type ToolResult } from '#tests/helpers/tools'
|
||||
|
||||
describe('set_fill', () => {
|
||||
test('sets solid fill', () => {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ describe('tool definitions', () => {
|
|||
|
||||
test('required params are marked', () => {
|
||||
for (const t of ALL_TOOLS) {
|
||||
for (const [key, param] of Object.entries(t.params)) {
|
||||
for (const param of Object.values(t.params)) {
|
||||
expect(typeof param.type).toBe('string')
|
||||
expect(typeof param.description).toBe('string')
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ import { join } from 'node:path'
|
|||
|
||||
import { initCanvasKit } from '#cli/headless'
|
||||
import { SkiaRenderer } from '#core/canvas'
|
||||
import { SceneGraph } from '#core/scene-graph'
|
||||
import type { SceneNode } from '#core/scene-graph'
|
||||
import { SceneGraph } from '#core/scene-graph'
|
||||
import { fontManager } from '#core/text'
|
||||
|
||||
async function main() {
|
||||
|
|
@ -53,8 +53,7 @@ async function main() {
|
|||
]
|
||||
} satisfies Partial<SceneNode>
|
||||
|
||||
const textNode = graph.createNode('TEXT', pageId, textProps)
|
||||
const nodeId = textNode.id
|
||||
graph.createNode('TEXT', pageId, textProps)
|
||||
|
||||
const surface = ck.MakeSurface(width, height)!
|
||||
const canvas = surface.getCanvas()
|
||||
|
|
|
|||
Loading…
Reference in a new issue