|
| 1 | +import { expect, test as base } from '@playwright/test'; |
| 2 | +import { skipNonProduction } from '../utils'; |
| 3 | + |
| 4 | +skipNonProduction('Cookie banner only on production'); |
| 5 | + |
| 6 | +const test = base.extend({ |
| 7 | + page: async ({ browser }, use) => { |
| 8 | + const context = await browser.newContext({ |
| 9 | + storageState: undefined |
| 10 | + }); |
| 11 | + const page = await context.newPage(); |
| 12 | + |
| 13 | + await use(page); |
| 14 | + |
| 15 | + await page.close(); |
| 16 | + await context.close(); |
| 17 | + } |
| 18 | +}); |
| 19 | + |
| 20 | +test.describe('Cookie banner functionality', () => { |
| 21 | + const PAGE_TYPES_EXAMPLE = [ |
| 22 | + '/', |
| 23 | + '/docs/getting-started.html', |
| 24 | + '/docs/multiplatform/get-started.html', |
| 25 | + '/api/core/kotlin-stdlib/', |
| 26 | + '/api/kotlinx.coroutines/kotlinx-coroutines-core/', |
| 27 | + '/lp/multiplatform/case-studies/autodesk/' |
| 28 | + ]; |
| 29 | + |
| 30 | + for (const path of PAGE_TYPES_EXAMPLE) { |
| 31 | + test(`Cookie banner should be visible and closeable: ${path}`, async ({ page, baseURL }) => { |
| 32 | + await page.goto(`${baseURL}${path}`); |
| 33 | + |
| 34 | + const acceptButton = page.getByRole('button', { name: 'Accept All' }); |
| 35 | + await expect(acceptButton).toBeVisible({ timeout: 10000 }); |
| 36 | + |
| 37 | + await acceptButton.click(); |
| 38 | + await expect(acceptButton).toBeHidden({ timeout: 3000 }); |
| 39 | + |
| 40 | + const cookies = await page.context().cookies(); |
| 41 | + expect(cookies.length).toBeGreaterThan(0); |
| 42 | + }); |
| 43 | + } |
| 44 | +}); |
0 commit comments