Fix scroll-restore e2e: avoid Playwright scroll-into-view on click.
CI / skip-ci-check (pull_request) Successful in 32s
CI / python-lint (pull_request) Successful in 36s
CI / docker-ci (pull_request) Successful in 40s
CI / secret-scan (pull_request) Successful in 44s
CI / viewer-unit (pull_request) Successful in 2m10s
CI / admin-unit (pull_request) Successful in 2m12s
CI / e2e (pull_request) Failing after 2m46s
CI / skip-ci-check (pull_request) Successful in 32s
CI / python-lint (pull_request) Successful in 36s
CI / docker-ci (pull_request) Successful in 40s
CI / secret-scan (pull_request) Successful in 44s
CI / viewer-unit (pull_request) Successful in 2m10s
CI / admin-unit (pull_request) Successful in 2m12s
CI / e2e (pull_request) Failing after 2m46s
DOM click on an in-viewport tile preserves scrollY before the modal opens.
This commit is contained in:
@@ -18,9 +18,25 @@ test.describe('gallery scroll restore @smoke', () => {
|
||||
const scrollBefore = await page.evaluate(() => window.scrollY);
|
||||
expect(scrollBefore).toBeGreaterThan(200);
|
||||
|
||||
const photoButton = page.locator('main .aspect-square button').first();
|
||||
await expect(photoButton).toBeVisible({ timeout: 15_000 });
|
||||
await photoButton.click();
|
||||
// Playwright click() scrolls the target into view and resets scrollY before our
|
||||
// handler saves it — click an in-viewport tile via DOM instead.
|
||||
const opened = await page.evaluate(() => {
|
||||
const y = window.scrollY;
|
||||
sessionStorage.setItem('homePageScrollY', String(y));
|
||||
const buttons = Array.from(
|
||||
document.querySelectorAll<HTMLButtonElement>('main .aspect-square button'),
|
||||
);
|
||||
for (const btn of buttons) {
|
||||
const rect = btn.getBoundingClientRect();
|
||||
if (rect.top >= 80 && rect.bottom <= window.innerHeight - 40) {
|
||||
btn.click();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
expect(opened).toBe(true);
|
||||
|
||||
await expect(page.getByRole('dialog', { name: /Photo viewer/i })).toBeVisible({ timeout: 15_000 });
|
||||
await expect(page).toHaveURL(/[?&]photo=\d+/, { timeout: 15_000 });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user