feat(transcription): decouple @mention display text from person search (#380) #629

Merged
marcel merged 41 commits from feat/issue-380-decouple-mention-search into main 2026-05-20 20:36:39 +02:00
Showing only changes of commit fb414183be - Show all commits

View File

@@ -15,6 +15,12 @@ import { m } from '$lib/paraglide/messages.js';
type Person = components['schemas']['Person'];
type PersonMention = components['schemas']['PersonMention'];
// Mirror of the debounce in PersonMentionEditor.svelte. Naming the magic and
// using a generous slack (SEARCH_DEBOUNCE_MS + 350 = 500 ms) kills CI-jitter
// flakiness Sara raised on PR #629.
const SEARCH_DEBOUNCE_MS = 150;
const POST_DEBOUNCE_SLACK_MS = 350;
const AUGUSTE: Person = {
id: 'p-aug',
firstName: 'Auguste',
@@ -218,8 +224,7 @@ describe('PersonMentionEditor — AC-2/3: search input drives fetch', () => {
await userEvent.type(page.getByRole('textbox'), '@Walter');
// Wait beyond the 150 ms debounce window so the trailing call has flushed.
await new Promise((r) => setTimeout(r, 300));
await new Promise((r) => setTimeout(r, SEARCH_DEBOUNCE_MS + POST_DEBOUNCE_SLACK_MS));
const personsFetches = fetchMock.mock.calls.filter(
([url]) => typeof url === 'string' && url.startsWith('/api/persons')
@@ -243,8 +248,7 @@ describe('PersonMentionEditor — AC-2/3: search input drives fetch', () => {
await userEvent.clear(page.getByRole('searchbox'));
// Wait beyond the debounce window to confirm no fetch was scheduled.
await new Promise((r) => setTimeout(r, 250));
await new Promise((r) => setTimeout(r, SEARCH_DEBOUNCE_MS + POST_DEBOUNCE_SLACK_MS));
expect(fetchMock.mock.calls.length).toBe(fetchesBeforeClear);
await expect.element(page.getByText('Auguste Raddatz')).not.toBeInTheDocument();
@@ -264,8 +268,7 @@ describe('PersonMentionEditor — whitespace-only query', () => {
await expect.element(page.getByRole('searchbox')).toBeVisible();
});
// Wait beyond the debounce window so any trailing call would have fired.
await new Promise((r) => setTimeout(r, 300));
await new Promise((r) => setTimeout(r, SEARCH_DEBOUNCE_MS + POST_DEBOUNCE_SLACK_MS));
await expect.element(page.getByText(m.person_mention_search_prompt())).toBeInTheDocument();
expect(fetchMock).not.toHaveBeenCalled();