openpencil/tests/engine/editor-store-path.test.ts
Danila Poyarkov d692953d62 test: fix pre-existing failures and add coverage for new features
- Fix mcp-stdio.test.ts: defer heavy SDK imports to avoid describe()
  registration race when running full suite
- Fix mcp-server.test.ts: add server.close() to properly clean up
  sessions and pending requests between tests (eliminates 8 unhandled
  errors)
- Add mcp-path-scoping tests: path traversal, sibling dir, root prefix
  trick, valid paths
- Add editor-store-path tests: setPlannedFilePath with Unix/Windows
  paths
- Add MCP server tests: open_file/new_document registered when mcpRoot
  is set, absent when null

0 fail, 0 errors, 1108 pass
2026-04-22 17:20:09 +03:00

26 lines
843 B
TypeScript

import { describe, test, expect } from 'bun:test'
import { SceneGraph } from '@open-pencil/core'
// Import the store factory directly
import { createEditorStore } from '../../src/stores/editor'
describe('setPlannedFilePath', () => {
test('sets document name from file path', () => {
const store = createEditorStore()
store.setPlannedFilePath('/tmp/projects/my-design.fig')
expect(store.state.documentName).toBe('my-design')
})
test('handles Windows-style paths', () => {
const store = createEditorStore()
store.setPlannedFilePath('C:\\Users\\test\\design.fig')
expect(store.state.documentName).toBe('design')
})
test('handles path without extension', () => {
const store = createEditorStore()
store.setPlannedFilePath('/tmp/Untitled')
expect(store.state.documentName).toBe('Untitled')
})
})