diff --git a/tests/e2e/access-lists.spec.ts b/tests/e2e/access-lists.spec.ts index bd190a02..752fdd2d 100644 --- a/tests/e2e/access-lists.spec.ts +++ b/tests/e2e/access-lists.spec.ts @@ -15,27 +15,34 @@ test.describe('Access Lists', () => { test('create access list — appears in the list', async ({ page }) => { await page.goto('/access-lists'); - // The form is inline on the page (no dialog) — fill Name directly - await page.getByLabel('Name').fill('E2E Test List'); + // Note initial count (may be non-zero from other tests) + const initialCount = await page.getByRole('button', { name: /delete list/i }).count(); + + // The form is inline on the page (no dialog) — use placeholder to uniquely target create form + await page.getByPlaceholder('Internal users').fill('E2E Test List'); await page.getByRole('button', { name: /create access list/i }).click(); - // The created list card appears with a "Delete list" button - await expect(page.getByRole('button', { name: /delete list/i })).toBeVisible({ timeout: 10000 }); + // A new card with a "Delete list" button should appear + await expect(page.getByRole('button', { name: /delete list/i })).toHaveCount(initialCount + 1, { timeout: 10000 }); }); test('delete access list removes it', async ({ page }) => { await page.goto('/access-lists'); - // Create one to delete via the inline form - await page.getByLabel('Name').fill('Delete This List'); + // Note initial count + const initialCount = await page.getByRole('button', { name: /delete list/i }).count(); + + // Create via the inline form — use placeholder to uniquely target create form + await page.getByPlaceholder('Internal users').fill('Delete This List'); await page.getByRole('button', { name: /create access list/i }).click(); - // The card appears with a "Delete list" button - await expect(page.getByRole('button', { name: /delete list/i })).toBeVisible({ timeout: 10000 }); + // Wait for new card + await expect(page.getByRole('button', { name: /delete list/i })).toHaveCount(initialCount + 1, { timeout: 10000 }); - // Delete it — no confirmation dialog, deletes immediately - await page.getByRole('button', { name: /delete list/i }).click(); + // Delete the first card — no confirmation dialog, deletes immediately + await page.getByRole('button', { name: /delete list/i }).first().click(); - await expect(page.getByRole('button', { name: /delete list/i })).not.toBeVisible({ timeout: 10000 }); + // Count should return to initial + await expect(page.getByRole('button', { name: /delete list/i })).toHaveCount(initialCount, { timeout: 10000 }); }); }); diff --git a/tests/e2e/proxy-hosts.spec.ts b/tests/e2e/proxy-hosts.spec.ts index d2e4d7bf..e99d79cb 100644 --- a/tests/e2e/proxy-hosts.spec.ts +++ b/tests/e2e/proxy-hosts.spec.ts @@ -44,14 +44,16 @@ test.describe('Proxy Hosts', () => { await expect(page.getByRole('dialog')).not.toBeVisible({ timeout: 10000 }); await expect(page.getByText('Host To Delete')).toBeVisible({ timeout: 10000 }); - // Click the Delete icon button for that row + // Click the Delete icon button for that row (last button in actions column) const row = page.locator('tr', { hasText: 'Host To Delete' }); - await row.getByTitle('Delete').click(); + await row.getByRole('button').last().click(); // Confirm dialog await expect(page.getByRole('dialog')).toBeVisible(); await page.getByRole('button', { name: /^delete$/i }).click(); - await expect(page.getByText('Host To Delete')).not.toBeVisible({ timeout: 10000 }); + // Wait for dialog to close, then verify the row is gone from the table + await expect(page.getByRole('dialog')).not.toBeVisible({ timeout: 10000 }); + await expect(page.locator('tbody').getByText('Host To Delete')).not.toBeVisible({ timeout: 5000 }); }); });