From 197a3e71d52498ecf84c9158b61dfa37ed20b35b Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 20 May 2026 00:02:42 +0200 Subject: [PATCH] test(transcription): replace setTimeout(50) with tick() in sticky-takeover Sara on PR #629 round 3: the magic 50 ms in the @mention sticky-takeover test was anchored to nothing and read as a race-fix it wasn't. Replace with await tick() so the intent ("flush pending Svelte reactivity") is explicit. The expect.element polling already covers timing drift. Co-Authored-By: Claude Opus 4.7 --- .../lib/shared/discussion/MentionDropdown.svelte.test.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/frontend/src/lib/shared/discussion/MentionDropdown.svelte.test.ts b/frontend/src/lib/shared/discussion/MentionDropdown.svelte.test.ts index 5ccc85bb..95124728 100644 --- a/frontend/src/lib/shared/discussion/MentionDropdown.svelte.test.ts +++ b/frontend/src/lib/shared/discussion/MentionDropdown.svelte.test.ts @@ -1,7 +1,7 @@ import { describe, it, expect, vi, afterEach } from 'vitest'; import { cleanup, render } from 'vitest-browser-svelte'; import { page, userEvent } from 'vitest/browser'; -import { flushSync, mount, unmount } from 'svelte'; +import { flushSync, mount, tick, unmount } from 'svelte'; import MentionDropdown from './MentionDropdown.svelte'; import MentionDropdownFixture from './MentionDropdown.test-fixture.svelte'; import { m } from '$lib/paraglide/messages.js'; @@ -241,7 +241,10 @@ describe('MentionDropdown — search input', () => { await expect.element(page.getByRole('searchbox')).toHaveValue('Walter'); setEditorQuery('WdGruyter'); - await new Promise((r) => setTimeout(r, 50)); + // Flush pending Svelte reactivity so any (non-)update from the mirror + // $effect has landed before we assert. expect.element already polls, so + // no fixed-timeout fallback is needed. Sara on PR #629 round 3. + await tick(); await expect.element(page.getByRole('searchbox')).toHaveValue('Walter'); });