diff --git a/tests/accessibility.spec.ts b/tests/accessibility.spec.ts index 21337f2..7bd3ba0 100644 --- a/tests/accessibility.spec.ts +++ b/tests/accessibility.spec.ts @@ -15,7 +15,7 @@ test.describe('Accessibility smoke', () => { test('dropzone input and hint text are accessible', async ({ page }) => { // Input is present and visible - await expect(page.locator('input[type="file"]')).toBeVisible({ timeout: 10000 }); + await expect(page.locator('input[type="file"]').first()).toBeVisible({ timeout: 10000 }); // Hint text present (supports compact or default variants) await expect( @@ -27,9 +27,9 @@ test.describe('Accessibility smoke', () => { await uploadFiles(page, 'sample.pdf', 'sample.epub', 'sample.txt'); await ensureDocumentsListed(page, ['sample.pdf', 'sample.epub', 'sample.txt']); - await expect(page.getByRole('link', { name: /sample\.pdf/i })).toBeVisible(); - await expect(page.getByRole('link', { name: /sample\.epub/i })).toBeVisible(); - await expect(page.getByRole('link', { name: /sample\.txt/i })).toBeVisible(); + await expect(page.getByRole('link', { name: /^sample\.pdf$/i })).toBeVisible(); + await expect(page.getByRole('link', { name: /^sample\.epub$/i })).toBeVisible(); + await expect(page.getByRole('link', { name: /^sample\.txt$/i })).toBeVisible(); }); test('ConfirmDialog exposes role=dialog with title and actions', async ({ page }) => { @@ -37,7 +37,7 @@ test.describe('Accessibility smoke', () => { await ensureDocumentsListed(page, ['sample.pdf']); // Open the confirm dialog by clicking the row delete button - await page.getByRole('button', { name: 'Delete document' }).first().click(); + await page.getByRole('button', { name: /^Delete sample\.pdf$/i }).first().click(); // Title and dialog role visible const heading = page.getByRole('heading', { name: 'Delete Document' }); diff --git a/tests/delete.spec.ts b/tests/delete.spec.ts index 6d8004b..5bdaf54 100644 --- a/tests/delete.spec.ts +++ b/tests/delete.spec.ts @@ -22,9 +22,6 @@ test.describe('Document deletion flow', () => { await expectNoDocumentLink(page, 'sample.txt'); await expectDocumentListed(page, 'sample.pdf'); - // Optional: summary exists (best-effort) - const summary = page.locator('[data-doc-summary]'); - await expect(summary).toBeVisible(); }); test('deletes all local documents from Settings modal', async ({ page }) => { diff --git a/tests/helpers.ts b/tests/helpers.ts index 500b3dc..dc0e2f2 100644 --- a/tests/helpers.ts +++ b/tests/helpers.ts @@ -419,8 +419,7 @@ export async function expectViewerForFile(page: Page, fileName: string) { // Delete a single document by filename via row action and confirm dialog export async function deleteDocumentByName(page: Page, fileName: string) { - const link = page.getByRole('link', { name: new RegExp(escapeRegExp(fileName), 'i') }).first(); - await link.locator('xpath=..').getByRole('button', { name: 'Delete document' }).click(); + await page.getByRole('button', { name: new RegExp(`^Delete\\s+${escapeRegExp(fileName)}$`, 'i') }).first().click(); const heading = page.getByRole('heading', { name: 'Delete Document' }); await expect(heading).toBeVisible({ timeout: 10000 }); diff --git a/tests/upload.spec.ts b/tests/upload.spec.ts index 7c66b73..2008f72 100644 --- a/tests/upload.spec.ts +++ b/tests/upload.spec.ts @@ -130,13 +130,13 @@ test.describe('Document Upload Tests', () => { await clickDocumentLink(page, 'sample.pdf'); await expectViewerForFile(page, 'sample.pdf'); await page.goBack(); - await expect(page.getByText('Your Documents')).toBeVisible({ timeout: 10000 }); + await ensureDocumentsListed(page, ['sample.pdf', 'sample.epub', 'sample.txt']); // EPUB navigation and viewer await clickDocumentLink(page, 'sample.epub'); await expectViewerForFile(page, 'sample.epub'); await page.goBack(); - await expect(page.getByText('Your Documents')).toBeVisible({ timeout: 10000 }); + await ensureDocumentsListed(page, ['sample.pdf', 'sample.epub', 'sample.txt']); // TXT navigation and viewer (HTML viewer) await clickDocumentLink(page, 'sample.txt');