|
| 1 | +import { expect, test } from '@playwright/test' |
| 2 | + |
| 3 | +test.describe('cookie banner does not block page interaction', () => { |
| 4 | + test.beforeEach(async ({ context }) => { |
| 5 | + // Force first-visit state: no cookiesAccepted cookie, so the consent |
| 6 | + // banner is rendered. |
| 7 | + await context.clearCookies() |
| 8 | + }) |
| 9 | + |
| 10 | + test('top bar "Links" anchor scrolls to the Links section while banner is shown', async ({ page }) => { |
| 11 | + await page.goto('/') |
| 12 | + |
| 13 | + // Sanity check: the cookie banner is open. |
| 14 | + await expect(page.getByRole('button', { name: 'Accept cookies' })).toBeVisible() |
| 15 | + |
| 16 | + // Click the "Links" item in the top bar. The Header's onClick handler |
| 17 | + // calls router.push('/#links') and scrolls to #links. If the modal |
| 18 | + // dialog is blocking pointer events, the click never fires and the URL |
| 19 | + // stays at "/". (The nav anchors have no href, so we locate by text.) |
| 20 | + await page.locator('#nav').getByText('Links', { exact: true }).click() |
| 21 | + |
| 22 | + await expect(page).toHaveURL(/#links$/) |
| 23 | + await expect(page.locator('#links')).toBeInViewport() |
| 24 | + }) |
| 25 | + |
| 26 | + test('cookie banner buttons are clickable', async ({ page }) => { |
| 27 | + await page.goto('/') |
| 28 | + |
| 29 | + const acceptButton = page.getByRole('button', { name: 'Accept cookies' }) |
| 30 | + await expect(acceptButton).toBeVisible() |
| 31 | + |
| 32 | + // pointer-events:none on Dialog.Content inherits to children, so the |
| 33 | + // banner buttons themselves stop receiving clicks. Tapping Accept must |
| 34 | + // dismiss the banner. |
| 35 | + await acceptButton.click() |
| 36 | + |
| 37 | + await expect(acceptButton).toBeHidden() |
| 38 | + }) |
| 39 | + |
| 40 | + test('Links section anchors fire clicks while banner is shown', async ({ page, context }) => { |
| 41 | + await page.goto('/') |
| 42 | + await expect(page.getByRole('button', { name: 'Accept cookies' })).toBeVisible() |
| 43 | + |
| 44 | + await page.locator('#links').scrollIntoViewIfNeeded() |
| 45 | + |
| 46 | + // The Blog anchor opens in a new tab (target="_blank"). If pointer |
| 47 | + // events are blocked we never get a popup event. |
| 48 | + const blogLink = page.getByRole('link', { name: 'Blog' }) |
| 49 | + const popupPromise = context.waitForEvent('page', { timeout: 5_000 }) |
| 50 | + await blogLink.click() |
| 51 | + const popup = await popupPromise |
| 52 | + expect(popup.url()).toContain('blog.etherpad.org') |
| 53 | + await popup.close() |
| 54 | + }) |
| 55 | +}) |
0 commit comments