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 <noreply@anthropic.com>
This commit is contained in:
@@ -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');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user