Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

test(notes): wait for the caret frame before typing in the numbered list test

Maurice965b519f2327
diff --git a/client/src/components/shared/NoteFormatToolbar.test.tsx b/client/src/components/shared/NoteFormatToolbar.test.tsx
index c27b41771..a45e0d2d9 100644
--- a/client/src/components/shared/NoteFormatToolbar.test.tsx
+++ b/client/src/components/shared/NoteFormatToolbar.test.tsx
@@ -1,5 +1,5 @@
import { describe, it, expect, vi } from 'vitest'
-import { screen, waitFor } from '@testing-library/react'
+import { act, screen, waitFor } from '@testing-library/react'
import { render } from '../../../tests/helpers/render'
import userEvent from '@testing-library/user-event'
import { useRef, useState } from 'react'
@@ -83,7 +83,9 @@ describe('NoteFormatToolbar', () => {
for (const [i, item] of ['Breakfast', 'Lunch', 'Dinner'].entries()) {
if (i > 0) await user.keyboard('{Enter}')
await user.click(numbered)
- await waitFor(() => expect(field().selectionStart).toBe(field().value.length))
+ // The toolbar puts the caret back one frame later; typing before that
+ // frame would have it jump into the middle of the word.
+ await act(() => new Promise<void>(resolve => requestAnimationFrame(() => resolve())))
await user.keyboard(item)
}