Compare commits

...

3 Commits

Author SHA1 Message Date
lucaronin
cec1627a81 fix: preserve image toolbar hover bridge 2026-04-18 15:12:39 +02:00
lucaronin
b00183419e fix: show Note metadata in autocomplete 2026-04-18 13:37:15 +02:00
lucaronin
ed9ceff1d2 fix: align Notes counts with explicit type 2026-04-18 13:07:17 +02:00
14 changed files with 456 additions and 42 deletions

View File

@@ -658,7 +658,7 @@ describe('wikilink autocomplete', () => {
mockFilterSuggestionItems.mockImplementation((items: unknown[]) => items)
})
it('shows correct noteType and color for typed entries, neutral for untyped', async () => {
it('shows Note chips and icons for explicit Note entries while keeping untyped entries neutral', async () => {
const mixedEntries: VaultEntry[] = [
{ ...mockEntry, title: 'Test Project', filename: 'proj.md', path: '/vault/proj.md', isA: 'Project', aliases: [] },
{ ...mockEntry, title: 'Test Plain', filename: 'plain.md', path: '/vault/plain.md', isA: null, aliases: [] },
@@ -675,20 +675,24 @@ describe('wikilink autocomplete', () => {
/>
)
const items = await capturedGetItems!('Test')
// Typed entries should have noteType and color
// Typed entries should have noteType, color, and a left-side icon
const project = items.find((i: { title: string }) => i.title === 'Test Project')
expect(project).toBeDefined()
expect(project!.noteType).toBe('Project')
expect(project!.typeColor).toBeTruthy()
// Untyped entries (isA: null or 'Note') should have no noteType (grey/neutral)
expect(project!.TypeIcon).toBeTruthy()
const explicitNote = items.find((i: { title: string }) => i.title === 'Test Explicit')
expect(explicitNote).toBeDefined()
expect(explicitNote!.noteType).toBe('Note')
expect(explicitNote!.typeColor).toBeTruthy()
expect(explicitNote!.TypeIcon).toBeTruthy()
// Untyped entries should remain neutral
const plainNote = items.find((i: { title: string }) => i.title === 'Test Plain')
expect(plainNote).toBeDefined()
expect(plainNote!.noteType).toBeUndefined()
expect(plainNote!.typeColor).toBeUndefined()
const explicitNote = items.find((i: { title: string }) => i.title === 'Test Explicit')
expect(explicitNote).toBeDefined()
expect(explicitNote!.noteType).toBeUndefined()
expect(explicitNote!.typeColor).toBeUndefined()
mockFilterSuggestionItems.mockImplementation((items: unknown[]) => items)
})

View File

@@ -262,6 +262,23 @@ describe('NoteList filter pills', () => {
expect(screen.queryByText('Open Project 1')).not.toBeInTheDocument()
})
it('shows only explicit Note entries for the Notes type filter', () => {
const noteEntries = [
makeEntry({ title: 'Note Type', isA: 'Type', path: '/types/note.md', filename: 'note.md' }),
makeEntry({ title: 'Explicit Note', isA: 'Note', path: '/explicit-note.md', filename: 'explicit-note.md' }),
makeEntry({ title: 'Untyped Note', isA: null, path: '/untyped-note.md', filename: 'untyped-note.md' }),
makeEntry({ title: 'Archived Explicit Note', isA: 'Note', archived: true, path: '/archived-note.md', filename: 'archived-note.md' }),
]
renderNoteList({ entries: noteEntries, selection: { kind: 'sectionGroup', type: 'Note' } })
expect(screen.getByText('Explicit Note')).toBeInTheDocument()
expect(screen.queryByText('Untyped Note')).not.toBeInTheDocument()
expect(screen.queryByText('Archived Explicit Note')).not.toBeInTheDocument()
expect(screen.getByTestId('filter-pill-open')).toHaveTextContent('1')
expect(screen.getByTestId('filter-pill-archived')).toHaveTextContent('1')
})
it('shows the archived empty state when a section has no archived notes', () => {
renderNoteList({
entries: projectEntries.filter((entry) => !entry.archived),

View File

@@ -780,6 +780,14 @@ describe('Sidebar', () => {
icon: null, color: null, order: null, sidebarLabel: null, template: null, sort: null,
outgoingLinks: [], properties: {},
},
{
path: '/vault/binary-note.pdf', filename: 'binary-note.pdf', title: 'Binary Note',
isA: 'Note', aliases: [], belongsTo: [], relatedTo: [], status: null, owner: null,
cadence: null, archived: false, modifiedAt: 1700000000,
createdAt: null, fileSize: 150, snippet: '', wordCount: 0, relationships: {},
icon: null, color: null, order: null, sidebarLabel: null, template: null, sort: null,
outgoingLinks: [], properties: {}, fileKind: 'binary',
},
]
it('shows Notes section when Note entries exist', () => {
@@ -787,13 +795,40 @@ describe('Sidebar', () => {
expect(screen.getByText('Notes')).toBeInTheDocument()
})
it('counts both explicit and untyped notes in Notes section chip', () => {
it('counts only explicit Note entries in the Notes section chip', () => {
render(<Sidebar entries={noteEntries} selection={defaultSelection} onSelect={() => {}} />)
const notesHeader = screen.getByText('Notes').closest('[class*="group/section"]')!
expect(notesHeader.textContent).toContain('1')
})
it('ignores non-markdown Note entries in the Notes section chip', () => {
render(<Sidebar entries={noteEntries} selection={defaultSelection} onSelect={() => {}} />)
const notesHeader = screen.getByText('Notes').closest('[class*="group/section"]')!
expect(notesHeader.textContent).toContain('1')
expect(notesHeader.textContent).not.toContain('2')
})
it('keeps the Notes section count aligned when an entry changes to or from Note', () => {
const { rerender } = render(<Sidebar entries={noteEntries} selection={defaultSelection} onSelect={() => {}} />)
let notesHeader = screen.getByText('Notes').closest('[class*="group/section"]')!
expect(notesHeader.textContent).toContain('1')
const withoutExplicitNote = noteEntries.map((entry) =>
entry.path === '/vault/explicit-note.md' ? { ...entry, isA: null } : entry,
)
rerender(<Sidebar entries={withoutExplicitNote} selection={defaultSelection} onSelect={() => {}} />)
notesHeader = screen.getByText('Notes').closest('[class*="group/section"]')!
expect(notesHeader.textContent).toBe('Notes')
const withNewExplicitNote = noteEntries.map((entry) =>
entry.path === '/vault/untyped-note.md' ? { ...entry, isA: 'Note' } : entry,
)
rerender(<Sidebar entries={withNewExplicitNote} selection={defaultSelection} onSelect={() => {}} />)
notesHeader = screen.getByText('Notes').closest('[class*="group/section"]')!
expect(notesHeader.textContent).toContain('2')
})
it('shows Notes section for untyped entries even without explicit Note entries', () => {
it('does not show Notes section for untyped entries without explicit Note entries', () => {
const untypedOnly: VaultEntry[] = [
{
path: '/vault/plain.md', filename: 'plain.md', title: 'Plain Note',
@@ -805,7 +840,7 @@ describe('Sidebar', () => {
},
]
render(<Sidebar entries={untypedOnly} selection={defaultSelection} onSelect={() => {}} />)
expect(screen.getByText('Notes')).toBeInTheDocument()
expect(screen.queryByText('Notes')).not.toBeInTheDocument()
})
})

View File

@@ -179,6 +179,7 @@ export function SingleEditorView({ editor, entries, onNavigateWikilink, onChange
title: entry.title,
aliases: [...new Set([entry.filename.replace(/\.md$/, ''), ...entry.aliases])],
group: entry.isA || 'Note',
entryType: entry.isA,
entryTitle: entry.title,
path: entry.path,
}))),

View File

@@ -0,0 +1,114 @@
import { describe, expect, it } from 'vitest'
import {
isWithinFormattingToolbarHoverBridge,
shouldSuppressFormattingToolbarHoverUpdate,
} from './blockNoteFormattingToolbarHoverGuard'
function rect(left: number, top: number, width: number, height: number) {
return DOMRect.fromRect({ x: left, y: top, width, height })
}
function setRect(element: HTMLElement, nextRect: DOMRect) {
element.getBoundingClientRect = () => nextRect
}
describe('blockNoteFormattingToolbarHoverGuard', () => {
it('treats the gap between the selected image block and toolbar as part of the hover bridge', () => {
expect(
isWithinFormattingToolbarHoverBridge(
{ x: 368, y: 104 },
rect(300, 130, 140, 90),
rect(322, 78, 96, 24),
),
).toBe(true)
})
it('suppresses hover updates when the pointer is already over the toolbar', () => {
const container = document.createElement('div')
const block = document.createElement('div')
block.className = 'bn-block'
block.dataset.id = 'image-block'
const fileBlock = document.createElement('div')
fileBlock.dataset.fileBlock = 'true'
block.appendChild(fileBlock)
container.appendChild(block)
document.body.appendChild(container)
const toolbar = document.createElement('div')
toolbar.className = 'bn-formatting-toolbar'
const toolbarButton = document.createElement('button')
toolbar.appendChild(toolbarButton)
document.body.appendChild(toolbar)
setRect(fileBlock, rect(300, 130, 140, 90))
setRect(toolbar, rect(322, 78, 96, 24))
expect(
shouldSuppressFormattingToolbarHoverUpdate({
eventTarget: toolbarButton,
point: { x: 350, y: 90 },
container,
doc: document,
selectedFileBlockId: 'image-block',
}),
).toBe(true)
})
it('suppresses hover updates while the pointer crosses the image-toolbar bridge', () => {
const container = document.createElement('div')
const block = document.createElement('div')
block.className = 'bn-block'
block.dataset.id = 'image-block'
const fileBlock = document.createElement('div')
fileBlock.dataset.fileBlock = 'true'
block.appendChild(fileBlock)
container.appendChild(block)
document.body.appendChild(container)
const toolbar = document.createElement('div')
toolbar.className = 'bn-formatting-toolbar'
document.body.appendChild(toolbar)
setRect(fileBlock, rect(300, 130, 140, 90))
setRect(toolbar, rect(322, 78, 96, 24))
expect(
shouldSuppressFormattingToolbarHoverUpdate({
eventTarget: document.body,
point: { x: 368, y: 104 },
container,
doc: document,
selectedFileBlockId: 'image-block',
}),
).toBe(true)
})
it('leaves unrelated pointer movement alone', () => {
const container = document.createElement('div')
const block = document.createElement('div')
block.className = 'bn-block'
block.dataset.id = 'image-block'
const fileBlock = document.createElement('div')
fileBlock.dataset.fileBlock = 'true'
block.appendChild(fileBlock)
container.appendChild(block)
document.body.appendChild(container)
const toolbar = document.createElement('div')
toolbar.className = 'bn-formatting-toolbar'
document.body.appendChild(toolbar)
setRect(fileBlock, rect(300, 130, 140, 90))
setRect(toolbar, rect(322, 78, 96, 24))
expect(
shouldSuppressFormattingToolbarHoverUpdate({
eventTarget: document.body,
point: { x: 520, y: 220 },
container,
doc: document,
selectedFileBlockId: 'image-block',
}),
).toBe(false)
})
})

View File

@@ -0,0 +1,179 @@
import { useEffect, useRef, type RefObject } from 'react'
type RectLike = Pick<DOMRect, 'left' | 'right' | 'top' | 'bottom'>
const HOVER_BRIDGE_PADDING_X = 8
const HOVER_BRIDGE_PADDING_Y = 8
function isVisibleRect(rect: RectLike) {
return rect.right > rect.left && rect.bottom > rect.top
}
function getSelectedFileBlockBridgeElement(
container: HTMLElement,
blockId: string,
) {
const selectedBlock = container.querySelector<HTMLElement>(
`.bn-block[data-id="${blockId}"]`,
)
if (!selectedBlock) return null
return (
selectedBlock.querySelector<HTMLElement>(
'[data-file-block] .bn-visual-media-wrapper',
) ??
selectedBlock.querySelector<HTMLElement>(
'[data-file-block] .bn-file-name-with-icon',
) ??
selectedBlock.querySelector<HTMLElement>('[data-file-block] .bn-add-file-button') ??
selectedBlock.querySelector<HTMLElement>('[data-file-block]')
)
}
export function isWithinFormattingToolbarHoverBridge(
point: { x: number; y: number },
fileBlockRect: RectLike,
toolbarRect: RectLike,
) {
if (!isVisibleRect(fileBlockRect) || !isVisibleRect(toolbarRect)) {
return false
}
const left = Math.min(fileBlockRect.left, toolbarRect.left) - HOVER_BRIDGE_PADDING_X
const right = Math.max(fileBlockRect.right, toolbarRect.right) + HOVER_BRIDGE_PADDING_X
const top = Math.min(fileBlockRect.top, toolbarRect.top) - HOVER_BRIDGE_PADDING_Y
const bottom = Math.max(fileBlockRect.bottom, toolbarRect.bottom) + HOVER_BRIDGE_PADDING_Y
return (
point.x >= left &&
point.x <= right &&
point.y >= top &&
point.y <= bottom
)
}
export function shouldSuppressFormattingToolbarHoverUpdate({
eventTarget,
point,
container,
doc,
selectedFileBlockId,
}: {
eventTarget: EventTarget | null
point: { x: number; y: number }
container: HTMLElement | null
doc: Document
selectedFileBlockId: string | null
}) {
if (!container || !selectedFileBlockId) return false
if (
eventTarget instanceof Element &&
eventTarget.closest('.bn-formatting-toolbar')
) {
return true
}
const selectedFileBlock = getSelectedFileBlockBridgeElement(
container,
selectedFileBlockId,
)
const toolbar = doc.querySelector<HTMLElement>('.bn-formatting-toolbar')
if (!selectedFileBlock || !toolbar) return false
return isWithinFormattingToolbarHoverBridge(
point,
selectedFileBlock.getBoundingClientRect(),
toolbar.getBoundingClientRect(),
)
}
function useLastSelectedFormattingToolbarFileBlockId(
selectedFileBlockId: string | null,
isOpen: boolean,
) {
const lastSelectedFileBlockIdRef = useRef<string | null>(selectedFileBlockId)
useEffect(() => {
if (selectedFileBlockId) {
lastSelectedFileBlockIdRef.current = selectedFileBlockId
return
}
if (!isOpen) {
lastSelectedFileBlockIdRef.current = null
}
}, [isOpen, selectedFileBlockId])
return lastSelectedFileBlockIdRef
}
function getFormattingToolbarHoverGuardEnvironment(container: HTMLElement | null) {
const doc = container?.ownerDocument
const view = doc?.defaultView
if (!container || !doc || !view) return null
return { container, doc, view }
}
function createFormattingToolbarHoverGuardHandler({
container,
doc,
selectedFileBlockIdRef,
}: {
container: HTMLElement
doc: Document
selectedFileBlockIdRef: RefObject<string | null>
}) {
return (event: MouseEvent) => {
if (
!shouldSuppressFormattingToolbarHoverUpdate({
eventTarget: event.target,
point: { x: event.clientX, y: event.clientY },
container,
doc,
selectedFileBlockId: selectedFileBlockIdRef.current,
})
) {
return
}
event.stopPropagation()
}
}
export function useBlockNoteFormattingToolbarHoverGuard({
container,
selectedFileBlockId,
isOpen,
}: {
container: HTMLElement | null
selectedFileBlockId: string | null
isOpen: boolean
}) {
const lastSelectedFileBlockIdRef = useLastSelectedFormattingToolbarFileBlockId(
selectedFileBlockId,
isOpen,
)
useEffect(() => {
if (!isOpen) return
const environment = getFormattingToolbarHoverGuardEnvironment(container)
if (!environment) return
const handleMouseMove = createFormattingToolbarHoverGuardHandler({
container: environment.container,
doc: environment.doc,
selectedFileBlockIdRef: lastSelectedFileBlockIdRef,
})
environment.view.addEventListener('mousemove', handleMouseMove, true)
return () => {
environment.view.removeEventListener('mousemove', handleMouseMove, true)
}
}, [container, isOpen, lastSelectedFileBlockIdRef])
}

View File

@@ -20,6 +20,7 @@ import { TypeCustomizePopover } from '../TypeCustomizePopover'
import { useDragRegion } from '../../hooks/useDragRegion'
import { SidebarGroupHeader } from './SidebarGroupHeader'
import { SidebarViewItem } from './SidebarViewItem'
import { countByFilter } from '../../utils/noteListHelpers'
export { SidebarTopNav } from './SidebarTopNav'
export { FavoritesSection } from './FavoritesSection'
@@ -94,9 +95,7 @@ function SortableSection({
sectionProps: SidebarSectionProps
}) {
const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({ id: group.type })
const itemCount = sectionProps.entries.filter((entry) =>
!entry.archived && (group.type === 'Note' ? (entry.isA === 'Note' || !entry.isA) : entry.isA === group.type),
).length
const itemCount = countByFilter(sectionProps.entries, group.type).open
const isRenaming = sectionProps.renamingType === group.type
return (

View File

@@ -54,6 +54,7 @@ import {
filterTolariaFormattingToolbarItems,
getTolariaBlockTypeSelectItems,
} from './tolariaEditorFormattingConfig'
import { useBlockNoteFormattingToolbarHoverGuard } from './blockNoteFormattingToolbarHoverGuard'
type TolariaBasicTextStyle = 'bold' | 'italic' | 'strike' | 'code'
@@ -166,6 +167,13 @@ type TolariaSelectedBlock = ReturnType<
BlockNoteEditor<BlockSchema, InlineContentSchema, StyleSchema>['getTextCursorPosition']
>['block']
const FORMATTING_TOOLBAR_FILE_BLOCK_TYPES = new Set([
'audio',
'file',
'image',
'video',
])
type TolariaBlockTypeSelectOption = ReturnType<
typeof getTolariaBlockTypeSelectItems
>[number] & {
@@ -263,6 +271,17 @@ function getTolariaBlockTypeSelectOptions(
}))
}
function getFormattingToolbarBridgeBlockId(
editor: BlockNoteEditor<BlockSchema, InlineContentSchema, StyleSchema>,
) {
const selectedBlock =
editor.getSelection()?.blocks[0] ?? editor.getTextCursorPosition().block
return FORMATTING_TOOLBAR_FILE_BLOCK_TYPES.has(selectedBlock.type)
? selectedBlock.id
: null
}
function updateSelectedBlocksToType(
editor: BlockNoteEditor<BlockSchema, InlineContentSchema, StyleSchema>,
selectedBlocks: TolariaSelectedBlock[],
@@ -451,6 +470,19 @@ export function TolariaFormattingToolbarController(props: {
})
const isOpen = show || toolbarHasFocus || toolbarHovered || closeGraceActive
const currentBridgeBlockId = useEditorState({
editor,
selector: ({ editor }) => getFormattingToolbarBridgeBlockId(editor),
})
useBlockNoteFormattingToolbarHoverGuard({
container:
editor.domElement?.closest('.editor__blocknote-container') ??
editor.domElement ??
null,
selectedFileBlockId: currentBridgeBlockId,
isOpen,
})
const position = useEditorState({
editor,

View File

@@ -99,6 +99,7 @@ describe('buildRawEditorBaseItems', () => {
title: 'Project Alpha',
aliases: ['project-alpha', 'Alpha'],
group: 'Project',
entryType: 'Project',
entryTitle: 'Project Alpha',
path: 'projects/project-alpha.md',
},

View File

@@ -8,6 +8,7 @@ export interface RawEditorBaseItem {
title: string
aliases: string[]
group: string
entryType?: string | null
entryTitle: string
path: string
}
@@ -59,6 +60,7 @@ export function buildRawEditorBaseItems(entries: VaultEntry[]): RawEditorBaseIte
title: entry.title,
aliases: [...new Set([entry.filename.replace(/\.md$/, ''), ...entry.aliases])],
group: entry.isA || 'Note',
entryType: entry.isA,
entryTitle: entry.title,
path: entry.path,
})))

View File

@@ -31,13 +31,10 @@ const isMarkdown = (e: VaultEntry) => e.fileKind === 'markdown' || !e.fileKind
const isActive = (e: VaultEntry) => !e.archived
const isSupportedSectionType = (type: string) => !isLegacyJournalingType(type)
function resolveEntrySectionType(entry: VaultEntry): string {
return entry.isA || 'Note'
}
function shouldCollectActiveType(entry: VaultEntry): boolean {
if (!isActive(entry) || !isMarkdown(entry)) return false
return isSupportedSectionType(resolveEntrySectionType(entry))
if (!entry.isA) return false
return isSupportedSectionType(entry.isA)
}
function shouldIncludeTypeDefinition(name: string, entry: VaultEntry): boolean {
@@ -45,12 +42,12 @@ function shouldIncludeTypeDefinition(name: string, entry: VaultEntry): boolean {
return isSupportedSectionType(name)
}
/** Collect unique isA values from active (non-archived) markdown entries. Untyped entries count as 'Note'. */
/** Collect unique explicit isA values from active (non-archived) markdown entries. */
export function collectActiveTypes(entries: VaultEntry[]): Set<string> {
const types = new Set<string>()
for (const e of entries) {
if (!shouldCollectActiveType(e)) continue
types.add(resolveEntrySectionType(e))
types.add(e.isA!)
}
return types
}

View File

@@ -76,8 +76,8 @@ describe('enrichSuggestionItems', () => {
Project: makeEntry({ isA: 'Type', title: 'Project', color: 'blue', icon: 'wrench' }),
}
function makeItem(title: string, group: string, path: string) {
return { title, aliases: [] as string[], group, entryTitle: title, path, onItemClick: vi.fn() }
function makeItem(title: string, group: string, path: string, entryType?: string | null) {
return { title, aliases: [] as string[], group, entryType, entryTitle: title, path, onItemClick: vi.fn() }
}
it('filters items by query', () => {
@@ -88,7 +88,7 @@ describe('enrichSuggestionItems', () => {
})
it('adds type metadata for non-Note groups', () => {
const items = [makeItem('My Project', 'Project', '/p.md')]
const items = [makeItem('My Project', 'Project', '/p.md', 'Project')]
const result = enrichSuggestionItems(items, '', typeEntryMap)
expect(result[0].noteType).toBe('Project')
expect(result[0].typeColor).toBeDefined()
@@ -96,7 +96,15 @@ describe('enrichSuggestionItems', () => {
expect(result[0].TypeIcon).toBeDefined()
})
it('omits type metadata for Note group', () => {
it('preserves Note type metadata for explicit Note entries', () => {
const items = [makeItem('Explicit Note', 'Note', '/n.md', 'Note')]
const result = enrichSuggestionItems(items, '', {})
expect(result[0].noteType).toBe('Note')
expect(result[0].typeColor).toBeDefined()
expect(result[0].TypeIcon).toBeDefined()
})
it('keeps untyped Note-group entries neutral', () => {
const items = [makeItem('Plain Note', 'Note', '/n.md')]
const result = enrichSuggestionItems(items, '', {})
expect(result[0].noteType).toBeUndefined()

View File

@@ -13,6 +13,7 @@ interface BaseSuggestionItem {
title: string
aliases: string[]
group: string
entryType?: string | null
entryTitle: string
path: string
}
@@ -48,15 +49,15 @@ export function enrichSuggestionItems(
)
const sliced = filtered.slice(0, MAX_RESULTS)
const final = disambiguateTitles(deduplicateByPath(sliced))
return final.map(({ group, ...rest }) => {
const noteType = group !== 'Note' ? group : undefined
const te = typeEntryMap[group]
return final.map(({ entryType, ...rest }) => {
const noteType = entryType ?? undefined
const te = noteType ? typeEntryMap[noteType] : undefined
return {
...rest,
noteType,
typeColor: noteType ? getTypeColor(group, te?.color) : undefined,
typeLightColor: noteType ? getTypeLightColor(group, te?.color) : undefined,
TypeIcon: noteType ? getTypeIcon(group, te?.icon) : undefined,
typeColor: noteType ? getTypeColor(noteType, te?.color) : undefined,
typeLightColor: noteType ? getTypeLightColor(noteType, te?.color) : undefined,
TypeIcon: noteType ? getTypeIcon(noteType, te?.icon) : undefined,
}
})
}

View File

@@ -73,6 +73,24 @@ async function seedImageBlock(page: Page) {
return image
}
async function moveMouseInSteps(
page: Page,
from: { x: number; y: number },
to: { x: number; y: number },
{ steps, stepDelayMs }: { steps: number; stepDelayMs: number },
) {
await page.mouse.move(from.x, from.y)
for (let step = 1; step <= steps; step += 1) {
const progress = step / steps
await page.mouse.move(
from.x + (to.x - from.x) * progress,
from.y + (to.y - from.y) * progress,
)
await page.waitForTimeout(stepDelayMs)
}
}
test.beforeEach(async ({ page }, testInfo) => {
testInfo.setTimeout(90_000)
tempVaultDir = createFixtureVaultCopy()
@@ -86,28 +104,34 @@ test.afterEach(async () => {
test('image toolbar stays usable while the pointer crosses onto its controls', async ({ page }) => {
const image = await seedImageBlock(page)
await image.click()
const toolbar = page.locator('.bn-formatting-toolbar')
const replaceButton = page.getByRole('button', { name: /Replace image/i })
await expect(toolbar).toBeVisible({ timeout: 5_000 })
await expect(replaceButton).toBeVisible()
const imageBox = await image.boundingBox()
const replaceButtonBox = await replaceButton.boundingBox()
expect(imageBox).not.toBeNull()
expect(replaceButtonBox).not.toBeNull()
await page.mouse.move(
imageBox!.x + imageBox!.width / 2,
imageBox!.y + imageBox!.height / 2,
)
await page.mouse.move(
replaceButtonBox!.x + replaceButtonBox!.width / 2,
replaceButtonBox!.y + replaceButtonBox!.height / 2,
{ steps: 16 },
await expect(toolbar).toBeVisible({ timeout: 5_000 })
await expect(replaceButton).toBeVisible()
const replaceButtonBox = await replaceButton.boundingBox()
expect(replaceButtonBox).not.toBeNull()
await moveMouseInSteps(
page,
{
x: imageBox!.x + imageBox!.width / 2,
y: imageBox!.y + imageBox!.height / 2,
},
{
x: replaceButtonBox!.x + replaceButtonBox!.width / 2,
y: replaceButtonBox!.y + replaceButtonBox!.height / 2,
},
{ steps: 12, stepDelayMs: 35 },
)
await expect(toolbar).toBeVisible()