From 671d05acac1ffc8ed979df8cb9fcc37fd768680e Mon Sep 17 00:00:00 2001 From: Marcel Date: Tue, 19 May 2026 20:57:15 +0200 Subject: [PATCH] test(transcription): cover MentionDropdown onSearch callback wiring MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For issue #380. Asserts that typing in the search input invokes the onSearch prop with the current value — characterising the boundary that PersonMentionEditor relies on for its debounced fetch. Co-Authored-By: Claude Opus 4.7 --- .../discussion/MentionDropdown.svelte.spec.ts | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/frontend/src/lib/shared/discussion/MentionDropdown.svelte.spec.ts b/frontend/src/lib/shared/discussion/MentionDropdown.svelte.spec.ts index d73ff552..3021fbfa 100644 --- a/frontend/src/lib/shared/discussion/MentionDropdown.svelte.spec.ts +++ b/frontend/src/lib/shared/discussion/MentionDropdown.svelte.spec.ts @@ -7,9 +7,9 @@ * "no results" / "create new" behaviors. Wiring tests against Tiptap live * in PersonMentionEditor.svelte.spec.ts. */ -import { describe, it, expect, afterEach } from 'vitest'; +import { describe, it, expect, afterEach, vi } from 'vitest'; import { cleanup, render } from 'vitest-browser-svelte'; -import { page } from 'vitest/browser'; +import { page, userEvent } from 'vitest/browser'; import MentionDropdown from './MentionDropdown.svelte'; import type { components } from '$lib/generated/api'; @@ -53,4 +53,20 @@ describe('MentionDropdown — search input', () => { expect(input).not.toBeNull(); expect((input as HTMLInputElement).type).toBe('search'); }); + + it('invokes onSearch with the current value whenever the user types', async () => { + const onSearch = vi.fn(); + render(MentionDropdown, { + model: makeModel(), + initialQuery: '', + onSearch + }); + + await userEvent.type(page.getByRole('searchbox'), 'Walter'); + + await vi.waitFor(() => { + expect(onSearch).toHaveBeenCalled(); + expect(onSearch).toHaveBeenLastCalledWith('Walter'); + }); + }); });