test(documents): update selectors and assertions for document actions and accessibility

Revise test helpers and specs to use stricter role-based selectors for document
actions, including delete buttons and document links. Improve accessibility and
upload tests by asserting document presence via explicit file lists instead of
generic text checks. Remove redundant summary assertion from delete flow.
This commit is contained in:
Richard R 2026-05-28 12:34:29 -06:00
parent b9490a53ac
commit e4b0c8358e
4 changed files with 8 additions and 12 deletions

View file

@ -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' });

View file

@ -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 }) => {

View file

@ -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 });

View file

@ -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');