diff --git a/frontend/e2e/documents.spec.ts b/frontend/e2e/documents.spec.ts index 8ddac2b1..20c9a976 100644 --- a/frontend/e2e/documents.spec.ts +++ b/frontend/e2e/documents.spec.ts @@ -327,10 +327,12 @@ test.describe('PDF annotations — admin', () => { await page.waitForSelector('[data-hydrated]'); await page.locator('canvas').first().waitFor({ state: 'visible', timeout: 20000 }); - // Ensure annotation is visible before enabling annotate mode + // Ensure at least one annotation is visible before enabling annotate mode await expect(page.locator('[data-testid^="annotation-"]').first()).toBeVisible({ timeout: 8000 }); + // Record count now — the draw test may have created more than one annotation + const countBefore = await page.locator('[data-testid^="annotation-"]').count(); // Enable annotate mode to show delete buttons await page.getByRole('button', { name: /^annotieren$/i }).click(); @@ -339,7 +341,7 @@ test.describe('PDF annotations — admin', () => { await expect(deleteBtn).toBeVisible({ timeout: 8000 }); await deleteBtn.click(); - await expect(page.locator('[data-testid^="annotation-"]')).toHaveCount(0, { + await expect(page.locator('[data-testid^="annotation-"]')).toHaveCount(countBefore - 1, { timeout: 8000 }); @@ -407,7 +409,10 @@ test.describe('PDF annotations — file hash versioning', () => { await page.waitForSelector('[data-hydrated]'); await page.locator('canvas').first().waitFor({ state: 'visible', timeout: 20000 }); - await expect(page.locator('[data-testid^="annotation-"]')).toHaveCount(0, { timeout: 8000 }); + // Use :not() to exclude the outdated-notice element whose testid also starts with "annotation-" + await expect( + page.locator('[data-testid^="annotation-"]:not([data-testid="annotation-outdated-notice"])') + ).toHaveCount(0, { timeout: 8000 }); await expect(page.locator('[data-testid="annotation-outdated-notice"]')).toBeVisible({ timeout: 5000 });