테스트/린트 안정화: 버튼 쿼리 모호성 제거, 훅 deps 보강, vi.spyOn 모킹, 멀티선택 Moveable 간섭 방지 재확인, 스냅 우선순위 회귀 그린
This commit is contained in:
@@ -1,26 +1,26 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { describe, it, expect, vi } from 'vitest'
|
||||
import { render, screen, fireEvent, waitFor } from '@testing-library/react'
|
||||
import { WysiwygBuilderPage } from '@/components/wysiwyg/WysiwygBuilderPage'
|
||||
|
||||
// minimal mock for URL.createObjectURL used by download
|
||||
const createObjectURL = global.URL.createObjectURL
|
||||
const revokeObjectURL = global.URL.revokeObjectURL
|
||||
let spyCreate: ReturnType<typeof vi.spyOn> | null = null
|
||||
let spyRevoke: ReturnType<typeof vi.spyOn> | null = null
|
||||
|
||||
describe('WysiwygBuilderPage', () => {
|
||||
beforeEach(() => {
|
||||
// @ts-ignore
|
||||
global.URL.createObjectURL = () => 'blob:mock'
|
||||
// @ts-ignore
|
||||
global.URL.revokeObjectURL = () => {}
|
||||
spyCreate = vi.spyOn(global.URL, 'createObjectURL').mockReturnValue('blob:mock')
|
||||
spyRevoke = vi.spyOn(global.URL, 'revokeObjectURL').mockImplementation(() => {})
|
||||
})
|
||||
afterEach(() => {
|
||||
global.URL.createObjectURL = createObjectURL
|
||||
global.URL.revokeObjectURL = revokeObjectURL
|
||||
spyCreate?.mockRestore()
|
||||
spyRevoke?.mockRestore()
|
||||
spyCreate = null
|
||||
spyRevoke = null
|
||||
})
|
||||
|
||||
it('adds a text object to the canvas', async () => {
|
||||
render(<WysiwygBuilderPage />)
|
||||
const addText = screen.getByRole('button', { name: /Add Text/i })
|
||||
const addText = screen.getByRole('button', { name: /^Add Text$/i })
|
||||
fireEvent.click(addText)
|
||||
await waitFor(() => {
|
||||
expect(screen.getByTestId('obj-text-1')).toBeInTheDocument()
|
||||
|
||||
Reference in New Issue
Block a user