fix: allow note drops to insert wikilinks
This commit is contained in:
@@ -70,6 +70,7 @@ describe('NoteDropTarget', () => {
|
||||
|
||||
const dragStartData = createMockDataTransfer()
|
||||
fireEvent.dragStart(screen.getByTestId(`draggable-note:${NOTE_PATH}`), { dataTransfer: dragStartData })
|
||||
expect(dragStartData.effectAllowed).toBe('linkMove')
|
||||
|
||||
const target = screen.getByText('CircleCI Series').parentElement
|
||||
expect(target).not.toBeNull()
|
||||
|
||||
@@ -5,7 +5,7 @@ let activeDraggedNotePath: string | null = null
|
||||
|
||||
export function writeDraggedNotePath(event: DragEvent<HTMLElement>, notePath: string): void {
|
||||
activeDraggedNotePath = notePath
|
||||
event.dataTransfer.effectAllowed = 'move'
|
||||
event.dataTransfer.effectAllowed = 'linkMove'
|
||||
event.dataTransfer.setData(NOTE_DRAG_MIME, notePath)
|
||||
event.dataTransfer.setData('text/plain', notePath)
|
||||
}
|
||||
|
||||
34
tests/smoke/note-drop-wikilink.spec.ts
Normal file
34
tests/smoke/note-drop-wikilink.spec.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { test, expect, type Page } from '@playwright/test'
|
||||
import path from 'path'
|
||||
import { createFixtureVaultCopy, openFixtureVault, removeFixtureVaultCopy } from '../helpers/fixtureVault'
|
||||
|
||||
let tempVaultDir: string
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
tempVaultDir = createFixtureVaultCopy()
|
||||
await openFixtureVault(page, tempVaultDir)
|
||||
})
|
||||
|
||||
test.afterEach(async () => {
|
||||
removeFixtureVaultCopy(tempVaultDir)
|
||||
})
|
||||
|
||||
async function openNote(page: Page, title: string) {
|
||||
await page.getByTestId('note-list-container').getByText(title, { exact: true }).click()
|
||||
await expect(page.getByRole('heading', { name: title, level: 1 })).toBeVisible({ timeout: 5_000 })
|
||||
}
|
||||
|
||||
test('dragging a note into the rich editor inserts a canonical wikilink', async ({ page }) => {
|
||||
await openNote(page, 'Note B')
|
||||
|
||||
const editor = page.locator('.bn-editor')
|
||||
await expect(editor).toBeVisible({ timeout: 5_000 })
|
||||
await editor.locator('p').last().click()
|
||||
await page.keyboard.press('End')
|
||||
await page.keyboard.press('Enter')
|
||||
|
||||
const draggedNotePath = path.join(tempVaultDir, 'project', 'alpha-project.md')
|
||||
await page.getByTestId(`draggable-note:${draggedNotePath}`).dragTo(editor)
|
||||
|
||||
await expect(editor.locator('.wikilink[data-target="project/alpha-project"]')).toBeVisible({ timeout: 5_000 })
|
||||
})
|
||||
Reference in New Issue
Block a user