Skip to content

Commit 417faf0

Browse files
cdervclaude
andcommitted
Simplify scroll persistence test to use actual scrolling
The previous test dispatched quarto-hrChanged/quarto-sectionChanged custom events, which were leftovers from when search code listened to those events. Since #13442 removed those listeners entirely, dispatching those events tested nothing. Replace with actual scroll behavior which is the real user scenario from #14047. Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent a5434e6 commit 417faf0

1 file changed

Lines changed: 4 additions & 14 deletions

File tree

tests/integration/playwright/tests/html-search-highlight.spec.ts

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,17 @@ import { test, expect } from "@playwright/test";
22

33
const BASE = './html/search-highlight/_site/index.html';
44

5-
test('Search highlights not cleared by scroll events', async ({ page }) => {
5+
test('Search highlights persist after scrolling', async ({ page }) => {
66
await page.goto(`${BASE}?q=special`);
77
const marks = page.locator('mark');
88

99
await expect(marks.first()).toBeVisible({ timeout: 5000 });
1010
const initialCount = await marks.count();
1111
expect(initialCount).toBeGreaterThanOrEqual(2);
1212

13-
// Dispatch layout events immediately (previously cleared marks via quarto-hrChanged)
14-
await page.evaluate(() => {
15-
window.dispatchEvent(new CustomEvent('quarto-hrChanged'));
16-
window.dispatchEvent(new CustomEvent('quarto-sectionChanged'));
17-
});
18-
await expect(marks).toHaveCount(initialCount);
19-
20-
// Wait and dispatch again — marks should persist at any time
21-
await page.waitForTimeout(1500);
22-
await page.evaluate(() => {
23-
window.dispatchEvent(new CustomEvent('quarto-hrChanged'));
24-
window.dispatchEvent(new CustomEvent('quarto-sectionChanged'));
25-
});
13+
// Scroll the page — marks should not be cleared
14+
await page.evaluate(() => window.scrollBy(0, 300));
15+
await page.waitForTimeout(500);
2616
await expect(marks).toHaveCount(initialCount);
2717
});
2818

0 commit comments

Comments
 (0)