fix(tests): replace flaky waitFor with synchronous dispatchEvent in edit-page delete spec
Some checks failed
CI / Unit & Component Tests (pull_request) Failing after 3m54s
CI / OCR Service Tests (pull_request) Successful in 32s
CI / Backend Unit Tests (pull_request) Failing after 3m18s
CI / Unit & Component Tests (push) Failing after 3m51s
CI / OCR Service Tests (push) Successful in 47s
CI / Backend Unit Tests (push) Failing after 3m19s
Some checks failed
CI / Unit & Component Tests (pull_request) Failing after 3m54s
CI / OCR Service Tests (pull_request) Successful in 32s
CI / Backend Unit Tests (pull_request) Failing after 3m18s
CI / Unit & Component Tests (push) Failing after 3m51s
CI / OCR Service Tests (push) Successful in 47s
CI / Backend Unit Tests (push) Failing after 3m19s
The Playwright CDP click latency occasionally pushed past vi.waitFor's 1000ms deadline, making the "opens a confirm dialog" test flaky. Switched to btn.dispatchEvent(new MouseEvent(...)) — the same synchronous in-browser pattern already used in GeschichteEditor.svelte.spec.ts. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit was merged in pull request #456.
This commit is contained in:
@@ -61,8 +61,14 @@ describe('Edit page — delete button', () => {
|
||||
context: new Map([[CONFIRM_KEY, mockService]])
|
||||
});
|
||||
|
||||
await page.getByRole('button', { name: /löschen/i }).click();
|
||||
await vi.waitFor(() => expect(capturedOptions).not.toBeNull());
|
||||
// Playwright CDP click has latency that can exceed vi.waitFor's 1000ms deadline.
|
||||
// Dispatching the MouseEvent directly from browser-JS context is synchronous and
|
||||
// reliably triggers Svelte 5 onclick — same pattern as GeschichteEditor.svelte.spec.ts.
|
||||
const btn = (await page
|
||||
.getByRole('button', { name: /löschen/i })
|
||||
.element()) as HTMLButtonElement;
|
||||
btn.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true }));
|
||||
expect(capturedOptions).not.toBeNull();
|
||||
expect(capturedOptions).toMatchObject({ destructive: true });
|
||||
settleRef?.(false);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user