Merge claude/cookie-button-bottom: the cookie button stays in the bottom corner of the window
Conflicts in the 1.17.2 changelog draft and the upgrade skill: both sides kept (rewritten into one entry at release). Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -493,6 +493,70 @@ test('consent: withdrawal — reopen, reject: analytics cookies and listed stora
|
||||
expect((await consentRecord(context))!.state).toMatchObject({ analytics: false, functional: false, marketing: false })
|
||||
})
|
||||
|
||||
// The "cookie settings" button stays in the bottom corner of the window (1.17.2): it does not climb above the footer.
|
||||
// At the very end of the page it steps above a link it would keep covered.
|
||||
for (const device of [
|
||||
{ name: 'desktop', viewport: { height: 800, width: 1280 } },
|
||||
{ name: 'phone', viewport: { height: 844, width: 390 } },
|
||||
]) {
|
||||
test(`cookie button, ${device.name}: bottom corner on long and short pages, never on a link at the page end, no layout shift`, async ({ browser }) => {
|
||||
const context = await browser.newContext({ viewport: device.viewport })
|
||||
const page = await context.newPage()
|
||||
await page.addInitScript(() => {
|
||||
const w = window as unknown as { __cls: number }
|
||||
w.__cls = 0
|
||||
new PerformanceObserver((list) => {
|
||||
for (const entry of list.getEntries() as unknown as { hadRecentInput: boolean; value: number }[]) {
|
||||
if (!entry.hadRecentInput) {w.__cls += entry.value}
|
||||
}
|
||||
}).observe({ buffered: true, type: 'layout-shift' })
|
||||
})
|
||||
await page.goto('/pl')
|
||||
await page.locator('[data-ipal="reject"]').click()
|
||||
const button = page.locator('[data-ipal="cookie-button"]')
|
||||
const probe = () =>
|
||||
button.evaluate((b: HTMLElement) => {
|
||||
const r = b.getBoundingClientRect()
|
||||
b.style.pointerEvents = 'none'
|
||||
const covered = [[r.left + 4, r.top + 4], [r.right - 4, r.top + 4], [r.left + 4, r.bottom - 4], [r.right - 4, r.bottom - 4], [r.left + r.width / 2, r.top + r.height / 2]]
|
||||
.map(([x, y]) => document.elementFromPoint(x, y)?.closest('a, button, input, select, textarea, summary'))
|
||||
.filter(Boolean)
|
||||
.map((el) => (el!.textContent ?? '').trim().slice(0, 30))
|
||||
b.style.pointerEvents = ''
|
||||
return { covered, gap: Math.round(window.innerHeight - r.bottom), inFooter: !!b.closest('footer'), left: Math.round(r.left), position: getComputedStyle(b).position }
|
||||
})
|
||||
for (const path of ['/pl', '/pl/regulamin', '/pl/kontakt']) {
|
||||
await page.goto(path)
|
||||
await expect(button).toBeVisible()
|
||||
const shifts = () => page.evaluate(() => (window as unknown as { __cls: number }).__cls)
|
||||
await page.waitForTimeout(300)
|
||||
const before = await shifts()
|
||||
const height = await page.evaluate(() => document.documentElement.scrollHeight)
|
||||
for (const y of [0, Math.max(0, (height - device.viewport.height) / 2)]) {
|
||||
await page.evaluate((to) => window.scrollTo(0, to), y)
|
||||
await page.waitForTimeout(350)
|
||||
if (y + device.viewport.height < height - 2) {
|
||||
// anywhere above the end of the page: exactly in the corner, the footer in view or not
|
||||
expect(await probe(), `${path} at ${Math.round(y)}`).toMatchObject({ gap: 16, inFooter: false, left: 16, position: 'fixed' })
|
||||
}
|
||||
}
|
||||
await page.evaluate(() => window.scrollTo(0, document.documentElement.scrollHeight))
|
||||
await page.waitForTimeout(450)
|
||||
const end = await probe()
|
||||
expect(end, `${path} at the end`).toMatchObject({ covered: [], inFooter: false, left: 16, position: 'fixed' })
|
||||
expect(end.gap, `${path}: still at the bottom, not above the footer`).toBeLessThan(120)
|
||||
expect((await shifts()) - before, `${path}: layout shift while scrolling`).toBeLessThan(0.001)
|
||||
}
|
||||
// keyboard: reachable and it reopens the banner
|
||||
await button.focus()
|
||||
await expect(button).toBeFocused()
|
||||
await page.keyboard.press('Enter')
|
||||
await expect(page.locator('[data-ipal="banner"]')).toBeVisible()
|
||||
await expect(button).toHaveCount(0)
|
||||
await context.close()
|
||||
})
|
||||
}
|
||||
|
||||
test('admin: sign in through 2FA, agency credit, panel link preview', async ({ page, request }) => {
|
||||
const head = await (await request.get('/admin/login')).text()
|
||||
expect(head).toMatch(/noindex/)
|
||||
|
||||
Reference in New Issue
Block a user