File size: 1,084 Bytes
82be208
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Regression test: opening a chat-form picker must not scroll the
// conversation to the top. Root cause: the list's scroll effect fired
// scrollIntoView on the initial mount, before the popover was positioned,
// so the browser scrolled every scrollable ancestor to reveal the row.

import PickerListScrollHarness from './components/PickerListScrollHarness.svelte';
import { tick } from 'svelte';
import { describe, expect, it } from 'vitest';
import { render } from 'vitest-browser-svelte';

describe('ChatFormPickerList mount scroll', () => {
	it('does not scroll documentElement when the picker mounts', async () => {
		const screen = render(PickerListScrollHarness);

		await tick();

		document.documentElement.scrollTop = document.documentElement.scrollHeight;
		await tick();
		const before = document.documentElement.scrollTop;

		expect(before).toBeGreaterThan(0);

		screen.component.openPicker();
		await tick();
		await new Promise((r) => setTimeout(r, 100));
		await tick();

		const after = document.documentElement.scrollTop;

		expect(after).toBe(before);
	});
});