Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

963 B
Raw Blame
import { fireEvent, render } from '@testing-library/react'

import { Link } from 'lib/lemon-ui/Link'
import { resetLinkDragHook } from 'lib/lemon-ui/Link/useLinkDrag'

import { initKeaTests } from '~/test/init'

import { registerNotebookLinkDrag } from './registerNotebookLinkDrag'

describe('registerNotebookLinkDrag', () => {
    beforeEach(() => {
        initKeaTests()
    })

    afterEach(() => {
        resetLinkDragHook()
    })

    it('wires notebook drag into Link so dragging an internal link carries its url', () => {
        registerNotebookLinkDrag()
        const { container } = render(<Link to="/insights">Insights</Link>)
        const anchor = container.querySelector('a')
        expect(anchor).toBeTruthy()

        const dataTransfer = { setData: jest.fn() }
        fireEvent.dragStart(anchor!, { dataTransfer })

        expect(dataTransfer.setData).toHaveBeenCalledWith('text/uri-list', `${window.location.origin}/insights`)
    })
})