diff --git a/frontend/e2e/ocr-multiple-languages.spec.ts b/frontend/e2e/ocr-multiple-languages.spec.ts index f89c6b9..6366f4d 100644 --- a/frontend/e2e/ocr-multiple-languages.spec.ts +++ b/frontend/e2e/ocr-multiple-languages.spec.ts @@ -158,9 +158,24 @@ test.describe('OCR Multiple Languages', () => { await page.goto('/upload'); await helpers.waitForLoadingToComplete(); - // Upload Spanish test document - const fileInput = page.locator('input[type="file"]').first(); - await expect(fileInput).toBeAttached({ timeout: 10000 }); + // Wait for page to be fully loaded and rendered (WebKit needs more time) + await page.waitForLoadState('networkidle'); + await page.waitForTimeout(2000); + + // Upload Spanish test document - try multiple selectors for better WebKit compatibility + let fileInput = page.locator('input[type="file"]').first(); + + // If file input is not immediately available, try alternative approaches + if (!(await fileInput.isVisible({ timeout: 5000 }))) { + // Look for the dropzone or upload area that might contain the hidden input + const uploadArea = page.locator('[data-testid="dropzone"], .dropzone, .upload-area').first(); + if (await uploadArea.isVisible({ timeout: 5000 })) { + // Try to find file input within the upload area + fileInput = uploadArea.locator('input[type="file"]').first(); + } + } + + await expect(fileInput).toBeAttached({ timeout: 15000 }); try { await fileInput.setInputFiles(MULTILINGUAL_TEST_FILES.spanish); @@ -217,9 +232,24 @@ test.describe('OCR Multiple Languages', () => { await page.goto('/upload'); await helpers.waitForLoadingToComplete(); - // Upload English test document - const fileInput = page.locator('input[type="file"]').first(); - await expect(fileInput).toBeAttached({ timeout: 10000 }); + // Wait for page to be fully loaded and rendered (WebKit needs more time) + await page.waitForLoadState('networkidle'); + await page.waitForTimeout(2000); + + // Upload English test document - try multiple selectors for better WebKit compatibility + let fileInput = page.locator('input[type="file"]').first(); + + // If file input is not immediately available, try alternative approaches + if (!(await fileInput.isVisible({ timeout: 5000 }))) { + // Look for the dropzone or upload area that might contain the hidden input + const uploadArea = page.locator('[data-testid="dropzone"], .dropzone, .upload-area').first(); + if (await uploadArea.isVisible({ timeout: 5000 })) { + // Try to find file input within the upload area + fileInput = uploadArea.locator('input[type="file"]').first(); + } + } + + await expect(fileInput).toBeAttached({ timeout: 15000 }); try { await fileInput.setInputFiles(MULTILINGUAL_TEST_FILES.english); diff --git a/frontend/e2e/webdav-workflow.spec.ts b/frontend/e2e/webdav-workflow.spec.ts index 75cd4ab..9239392 100644 --- a/frontend/e2e/webdav-workflow.spec.ts +++ b/frontend/e2e/webdav-workflow.spec.ts @@ -28,25 +28,49 @@ test.describe('WebDAV Workflow', () => { await expect(loadingSpinner).not.toBeVisible({ timeout: TIMEOUTS.long }); } - // Wait a bit more for the page to fully render - await page.waitForTimeout(2000); + // Wait extra time for WebKit to fully render the page + await page.waitForTimeout(5000); - // Look for add source button (try multiple selectors) - const addSourceButton = page.locator('[data-testid="add-source"], button:has-text("Add Source"), button:has-text("Add"), button:has-text("New")').first(); + // For WebKit, try to wait for specific page elements to be loaded + await page.waitForFunction(() => { + return document.querySelector('[data-testid="add-source"]') !== null || + document.querySelector('button:has-text("Add Source")') !== null || + document.body.textContent?.includes('Add Source'); + }, { timeout: TIMEOUTS.long }); + + // Look for add source button (try multiple selectors in order of preference) + let addSourceButton = page.locator('[data-testid="add-source"]').first(); - if (await addSourceButton.isVisible({ timeout: TIMEOUTS.medium })) { + if (!(await addSourceButton.isVisible({ timeout: 5000 }))) { + addSourceButton = page.locator('button:has-text("Add Source")').first(); + } + + if (!(await addSourceButton.isVisible({ timeout: 5000 }))) { + addSourceButton = page.locator('button:has-text("Add")').first(); + } + + if (!(await addSourceButton.isVisible({ timeout: 5000 }))) { + addSourceButton = page.locator('button[aria-label*="add"], button[title*="add"]').first(); + } + + if (await addSourceButton.isVisible({ timeout: 5000 })) { + console.log('Found add source button, clicking...'); await addSourceButton.click(); } else { - // Alternative: look for floating action button or plus button - const fabButton = page.locator('button[aria-label*="add"], button[title*="add"], .fab, .add-button').first(); - if (await fabButton.isVisible({ timeout: TIMEOUTS.medium })) { - await fabButton.click(); - } else { - // Debug: log what's actually visible on the page - const pageContent = await page.textContent('body'); - console.log('Page content:', pageContent?.substring(0, 500)); - throw new Error('Could not find add source button'); - } + // Enhanced debugging for WebKit + const pageContent = await page.textContent('body'); + console.log('Page content (first 500 chars):', pageContent?.substring(0, 500)); + console.log('Page URL:', page.url()); + + // Check if we're actually on the sources page + const pageTitle = await page.title(); + console.log('Page title:', pageTitle); + + // Try to find any buttons on the page + const allButtons = await page.locator('button').count(); + console.log('Total buttons found:', allButtons); + + throw new Error('Could not find add source button'); } // Wait for source creation form/modal to appear