Add GDPR compliant cookie banner and update footer/privacy policy to include GA and Clarity; added e2e and unit tests for cookie handling; updated snapshots
This commit is contained in:
46
tests/cookie-options.spec.ts
Normal file
46
tests/cookie-options.spec.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
test.describe('visual regression', () => {
|
||||
test('cookie banner is visible', async ({ page }) => {
|
||||
await page.goto('/');
|
||||
await expect(page.locator('#cookie-banner')).toBeVisible();
|
||||
});
|
||||
|
||||
test('cookie banner is not visible when choices are accepted', async ({ page }) => {
|
||||
await page.goto('/');
|
||||
|
||||
await page.evaluate(() => {
|
||||
localStorage.setItem('mifi-ventures-cookie-consent', 'accept');
|
||||
});
|
||||
|
||||
await page.goto('/');
|
||||
await expect(page.locator('#cookie-banner')).not.toBeVisible();
|
||||
});
|
||||
|
||||
test('cookie banner is not visible when choices are rejected', async ({ page }) => {
|
||||
await page.goto('/');
|
||||
|
||||
await page.evaluate(() => {
|
||||
localStorage.setItem('mifi-ventures-cookie-consent', 'reject');
|
||||
});
|
||||
|
||||
await page.goto('/');
|
||||
await expect(page.locator('#cookie-banner')).not.toBeVisible();
|
||||
});
|
||||
|
||||
test('cookie banner is hidden when user selects accept', async ({ page }) => {
|
||||
await page.goto('/');
|
||||
await expect(page.locator('#cookie-banner')).toBeVisible();
|
||||
await page.locator('[data-consent="accept"]').click();
|
||||
await expect(page.locator('#cookie-banner')).not.toBeVisible();
|
||||
await expect(await page.evaluate(() => localStorage.getItem('mifi-ventures-cookie-consent'))).toBe('accept');
|
||||
});
|
||||
|
||||
test('cookie banner is hidden when user selects reject', async ({ page }) => {
|
||||
await page.goto('/');
|
||||
await expect(page.locator('#cookie-banner')).toBeVisible();
|
||||
await page.locator('[data-consent="reject"]').click();
|
||||
await expect(page.locator('#cookie-banner')).not.toBeVisible();
|
||||
await expect(await page.evaluate(() => localStorage.getItem('mifi-ventures-cookie-consent'))).toBe('reject');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user