feat: scroll to current contact in sidebar by default
This commit is contained in:
parent
0baf51646e
commit
62b0efac04
4 changed files with 36 additions and 7 deletions
|
|
@ -81,3 +81,21 @@ test('upcoming and recent show at least one birthday a week away', async ({ page
|
|||
await expect(page.locator('#upcoming').getByRole('link')).toHaveCount(4);
|
||||
await expect(page.locator('#recent').getByRole('link')).toHaveCount(4);
|
||||
});
|
||||
|
||||
|
||||
test('contact list scrolls (independently) to current contact in center of view', async ({ page }) => {
|
||||
for (let count = 0; count < 30; count++) {
|
||||
await verifyCreateUser(page, { names: [`Contact${count < 10 ? '0' + count : count}`] });
|
||||
}
|
||||
|
||||
await page.goto('/contact/28');
|
||||
await expect(page.getByRole('navigation').getByRole('link', { name: /Contact28/ })).toBeVisible();
|
||||
expect(await page.locator('main').evaluate(e => e.scrollTop)).toEqual(0);
|
||||
|
||||
await page.goto('/contact/16');
|
||||
await expect(page.locator('#nav-link-16')).toBeVisible();
|
||||
const linkPos: number = await page.locator('#nav-link-16').evaluate(e => e.getBoundingClientRect().y);
|
||||
|
||||
// roughly centered is fine, not that fussy about headers and whatnot
|
||||
expect(Math.abs(linkPos - (await page.evaluate('window.innerHeight/2') as number))).toBeLessThan(200);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue