From 4581fc0b1f1253e249ef8222f216a2bd404d1762 Mon Sep 17 00:00:00 2001 From: Marcel Date: Thu, 28 May 2026 12:53:36 +0200 Subject: [PATCH] test(discussion): atomically clear mention searchbox to kill CI flake MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit userEvent.clear deletes per-keystroke, so intermediate values 'Au'/'A' transit through the bound searchQuery and each schedules a debounced fetch. When CI keystroke jitter exceeds SEARCH_DEBOUNCE_MS (150 ms), an intermediate timer fires before the input reaches '' and the count assertion sees a phantom q=Au call. fill('') drops a single input event so the empty-query branch wins deterministically — same pattern this test file already uses for fill('Walter'). Co-Authored-By: Claude Opus 4.7 --- .../discussion/PersonMentionEditor.svelte.spec.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/frontend/src/lib/shared/discussion/PersonMentionEditor.svelte.spec.ts b/frontend/src/lib/shared/discussion/PersonMentionEditor.svelte.spec.ts index b8e33739..164e9b32 100644 --- a/frontend/src/lib/shared/discussion/PersonMentionEditor.svelte.spec.ts +++ b/frontend/src/lib/shared/discussion/PersonMentionEditor.svelte.spec.ts @@ -283,7 +283,15 @@ describe('PersonMentionEditor — AC-2/3: search input drives fetch', () => { const fetchesBeforeClear = fetchMock.mock.calls.length; - await userEvent.clear(page.getByRole('searchbox')); + // `fill('')` atomically sets the input value in a single input event — + // same rationale as the `fill('Walter')` call above. `userEvent.clear` + // deletes per-keystroke, so intermediate values 'Au'/'A' transit through + // the bound `searchQuery` and each schedules a debounced fetch. Under + // CI-runner jitter, if two consecutive keystrokes land more than + // SEARCH_DEBOUNCE_MS (150 ms) apart, an intermediate timer fires before + // the input reaches '' and adds a phantom call — unrelated to the + // contract under test, which is "empty query => no fetch". + await page.getByRole('searchbox').fill(''); // Negative assertion: wait past the debounce window to confirm no // trailing fetch was scheduled. Removing this wait would mask a