* refactor(app): isolate system clipboard adapters - Split browser and Tauri clipboard behavior into focused adapters\n- Inject browser clipboard capabilities into unit-testable operations\n- Remove navigator and document mutation from headless clipboard tests * refactor(app): delegate browser clipboard fallbacks - Use copy-to-clipboard for modern rich MIME writes and execCommand fallback\n- Keep OpenPencil-specific HTML and plain-text payload construction at the adapter boundary\n- Remove hand-rolled browser capability and selection handling * test(clipboard): verify rich browser menu round-trip - Exercise copy from the browser Edit menu under a user gesture\n- Verify text/html and text/plain ClipboardItem formats\n- Paste the system clipboard payload back into the canvas * refactor(clipboard): reduce adapter surface - Expose only command dispatch and the injectable system clipboard contract\n- Keep browser and Tauri copy/paste operations private to their adapters\n- Rename the in-memory DataTransfer fallback and share design HTML recognition * fix(clipboard): harden format and fallback handling - Require complete OpenPencil or Figma clipboard markers\n- Await browser writes so adapter failures resolve false\n- Write plain-only Tauri payloads as text and reject unrelated clipboard text * fix(clipboard): reject unrelated current browser data * fix(clipboard): bind fallbacks to copied selection - Match cached rich HTML to the current Tauri plain-text fallback\n- Preserve nodes when selection changes during an asynchronous cut\n- Reject unrelated current browser HTML before consulting memory * fix(clipboard): reuse the shared memory payload type * fix(clipboard): scan design markers linearly * fix(clipboard): distinguish unavailable and empty reads * style(clipboard): use includes for marker closure * test(clipboard): avoid wall-clock marker assertions
23 lines
841 B
TypeScript
23 lines
841 B
TypeScript
import { describe, expect, test } from 'bun:test'
|
|
|
|
import { isDesignClipboardHTML } from '@/app/editor/clipboard/html'
|
|
|
|
describe('design clipboard HTML recognition', () => {
|
|
test('accepts complete OpenPencil and Figma clipboard comments', () => {
|
|
expect(isDesignClipboardHTML('<!--(openpencil)payload(/openpencil)-->')).toBe(true)
|
|
expect(isDesignClipboardHTML('<span data-buffer="<!--(figma)payload(/figma)-->"></span>')).toBe(
|
|
true
|
|
)
|
|
expect(
|
|
isDesignClipboardHTML('<span data-buffer="<!--(figma)payload(/figma)-->"></span>')
|
|
).toBe(true)
|
|
})
|
|
|
|
test('rejects malformed repeated opening markers', () => {
|
|
expect(isDesignClipboardHTML('ordinary clipboard text')).toBe(false)
|
|
const malformed = '<!--(openpencil)'.repeat(10_000)
|
|
|
|
expect(isDesignClipboardHTML(malformed)).toBe(false)
|
|
})
|
|
})
|