utopia-ui/lib/setupTest.ts
mahula 942559247e test: add component tests for TipTap editor integration
- Add TextViewStatic.spec.tsx (16 tests): static HTML renderer tests
- Add TextView.spec.tsx (10 tests): TipTap read-only viewer tests
- Add RichTextEditor.spec.tsx (9 tests): editable editor tests
- Update setupTest.ts with TipTap DOM mocks (Range, Document APIs)

Tests cover rendering, truncation, hashtag/mention styling and clicks,
link navigation, and video embed rendering.
2026-01-19 10:29:54 +01:00

27 lines
588 B
TypeScript

// eslint-disable-next-line import-x/no-unassigned-import
import '@testing-library/jest-dom'
import { vi } from 'vitest'
// TipTap requires Range and Document APIs that happy-dom doesn't fully implement
Range.prototype.getBoundingClientRect = () => ({
bottom: 0,
height: 0,
left: 0,
right: 0,
top: 0,
width: 0,
x: 0,
y: 0,
toJSON: vi.fn(),
})
Range.prototype.getClientRects = () => ({
item: () => null,
length: 0,
[Symbol.iterator]: vi.fn(),
})
if (typeof Document.prototype.elementFromPoint === 'undefined') {
Document.prototype.elementFromPoint = vi.fn()
}