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>
This commit is contained in:
fuomag9
2026-04-06 09:59:11 +02:00
parent 785cfb6cc5
commit 2f12475ab0
5 changed files with 4 additions and 5 deletions

View File

@@ -16,7 +16,7 @@ test.describe('Dashboard home page', () => {
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+Proxy Hosts/ })).toBeVisible();
await expect(page.getByRole('link', { name: /\d+\s*Certificates/ })).toBeVisible();
await expect(page.getByRole('link', { name: /\d+\s*Access Lists/ })).toBeVisible();
});

View File

@@ -94,7 +94,6 @@ test.describe('Groups page', () => {
test('shows empty state when no groups exist', async ({ page }) => {
// If there are no groups, the empty state text should be visible
// (This may or may not show depending on existing data)
const emptyText = page.getByText('No groups yet. Create one to organize user access.');
const newGroupBtn = page.getByRole('button', { name: /new group/i });
// At minimum the button should always be visible
await expect(newGroupBtn).toBeVisible();

View File

@@ -25,7 +25,7 @@ test.describe('Link Account page', () => {
await expect(page).toHaveURL(/\/login/, { timeout: 10_000 });
});
test('redirects authenticated users to /', async ({ page, context }) => {
test('redirects authenticated users to /', async ({ page }) => {
// First log in
await page.goto('http://localhost:3000/login');
await page.getByRole('textbox', { name: /username/i }).fill('testadmin');

View File

@@ -303,7 +303,7 @@ test.describe('Role-based access control', () => {
const page = await adminContext.newPage();
await page.goto('/');
await expect(page.getByRole('link', { name: 'Overview' })).toBeVisible();
await expect(page.getByRole('link', { name: 'Proxy Hosts' })).toBeVisible();
await expect(page.getByRole('link', { name: 'Proxy Hosts', exact: true })).toBeVisible();
await expect(page.getByRole('link', { name: 'Settings' })).toBeVisible();
await expect(page.getByRole('link', { name: 'Users' })).toBeVisible();
await page.close();

View File

@@ -17,7 +17,7 @@ test.describe('Users page', () => {
});
test('displays at least one user (the admin)', async ({ page }) => {
await expect(page.getByText(/1 user/)).toBeVisible({ timeout: 5000 });
await expect(page.getByText(/\d+ users?/)).toBeVisible({ timeout: 5000 });
});
test('search input filters users', async ({ page }) => {