Files
caddy-proxy-manager/tests/e2e/dashboard.spec.ts
fuomag9 2f12475ab0 Fix E2E test locator ambiguity and lint errors
- dashboard.spec.ts: anchor regex /^\d+\s+Proxy Hosts/ to not match
  "L4 Proxy Hosts" sidebar link
- role-access.spec.ts: use exact: true for "Proxy Hosts" link
- users.spec.ts: match any user count (/\d+ users?/) since other test
  suites create additional users
- groups.spec.ts: remove unused emptyText variable
- link-account.spec.ts: remove unused context parameter

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 09:59:11 +02:00

52 lines
2.0 KiB
TypeScript

/**
* E2E tests: Dashboard (overview) home page.
*
* Verifies stat cards, navigation links, welcome header, and recent activity.
*/
import { test, expect } from '@playwright/test';
test.describe('Dashboard home page', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/');
});
test('displays welcome header with user name', async ({ page }) => {
await expect(page.getByText(/welcome back/i)).toBeVisible();
});
test('shows stat cards for Proxy Hosts, Certificates, and Access Lists', async ({ page }) => {
// Stat card labels are <p> inside link cards — match via the parent link
await expect(page.getByRole('link', { name: /^\d+\s+Proxy Hosts/ })).toBeVisible();
await expect(page.getByRole('link', { name: /\d+\s*Certificates/ })).toBeVisible();
await expect(page.getByRole('link', { name: /\d+\s*Access Lists/ })).toBeVisible();
});
test('shows Traffic (24h) card', async ({ page }) => {
await expect(page.getByText('Traffic (24h)')).toBeVisible();
});
test('stat card links navigate to correct pages', async ({ page }) => {
await page.getByRole('link', { name: /proxy hosts/i }).first().click();
await expect(page).toHaveURL(/\/proxy-hosts/);
});
test('Certificates stat card navigates to /certificates', async ({ page }) => {
await page.getByRole('link', { name: /certificates/i }).first().click();
await expect(page).toHaveURL(/\/certificates/);
});
test('Access Lists stat card navigates to /access-lists', async ({ page }) => {
await page.getByRole('link', { name: /access lists/i }).first().click();
await expect(page).toHaveURL(/\/access-lists/);
});
test('Traffic card navigates to /analytics', async ({ page }) => {
await page.getByRole('link', { name: /traffic/i }).first().click();
await expect(page).toHaveURL(/\/analytics/);
});
test('shows Recent Activity section', async ({ page }) => {
await expect(page.getByText(/recent activity/i)).toBeVisible();
});
});