diff --git a/admin-compliance/e2e/specs/cmp-dashboard.spec.ts b/admin-compliance/e2e/specs/cmp-dashboard.spec.ts new file mode 100644 index 0000000..6aed9eb --- /dev/null +++ b/admin-compliance/e2e/specs/cmp-dashboard.spec.ts @@ -0,0 +1,235 @@ +import { test, expect } from '@playwright/test' +import { navigateToSDK, waitForPageLoad } from '../utils/test-helpers' + +/** + * CMP Dashboard E2E Tests + * + * Tests the Consent Management Platform overview page (/sdk/cmp): + * - Page load and header + * - KPI cards (4 cards) + * - Site selector dropdown + * - Module navigation grid (8 modules) + * - Module click navigation + * - Compliance checklist items + * - Cookie category acceptance bars + */ + +test.describe('CMP Dashboard — Page Load', () => { + test.beforeEach(async ({ page }) => { + await navigateToSDK(page, '/cmp') + }) + + test('should load without errors', async ({ page }) => { + await expect(page.getByRole('heading', { name: 'Consent Management Platform' })).toBeVisible({ + timeout: 10000, + }) + }) + + test('should display subtitle text', async ({ page }) => { + await expect(page.getByText('Einwilligungen, Betroffenenrechte und Vendor-Compliance')).toBeVisible() + }) + + test('should have "Banner testen" link to preview', async ({ page }) => { + const link = page.locator('a[href="/sdk/cookie-banner/preview"]', { hasText: 'Banner testen' }) + await expect(link).toBeVisible() + }) +}) + + +test.describe('CMP Dashboard — KPI Cards', () => { + test.beforeEach(async ({ page }) => { + await navigateToSDK(page, '/cmp') + }) + + test('should display 4 KPI cards', async ({ page }) => { + await page.waitForTimeout(1000) + + await expect(page.getByText('Consents gesamt')).toBeVisible() + await expect(page.getByText('Aktive Einwilligungen')).toBeVisible() + await expect(page.getByText('Offene DSR-Anfragen')).toBeVisible() + await expect(page.getByText('Konfigurierte Sites')).toBeVisible() + }) + + test('should show numeric values in KPI cards (not loading forever)', async ({ page }) => { + // Wait for loading to finish (values should not be "..." after 5s) + await page.waitForTimeout(5000) + + const kpiContainer = page.locator('.grid.grid-cols-2.md\\:grid-cols-4') + await expect(kpiContainer).toBeVisible() + + // At least one card should have a numeric value (not "...") + const cardTexts = await kpiContainer.textContent() + expect(cardTexts).toBeTruthy() + // After loading, "..." should be replaced by actual numbers + const hasNumber = /\d/.test(cardTexts || '') + expect(hasNumber).toBeTruthy() + }) +}) + + +test.describe('CMP Dashboard — Site Selector', () => { + test.beforeEach(async ({ page }) => { + await navigateToSDK(page, '/cmp') + await page.waitForTimeout(2000) + }) + + test('should show site selector if sites exist', async ({ page }) => { + // The site selector is a