fix(tests): resolve issues in integration tests for the new multiple ocr languages

This commit is contained in:
perf3ct 2025-07-14 23:22:55 +00:00
parent 0894abd484
commit 628fe8cb7b
No known key found for this signature in database
GPG Key ID: 569C4EEC436F5232
2 changed files with 75 additions and 21 deletions

View File

@ -158,9 +158,24 @@ test.describe('OCR Multiple Languages', () => {
await page.goto('/upload'); await page.goto('/upload');
await helpers.waitForLoadingToComplete(); await helpers.waitForLoadingToComplete();
// Upload Spanish test document // Wait for page to be fully loaded and rendered (WebKit needs more time)
const fileInput = page.locator('input[type="file"]').first(); await page.waitForLoadState('networkidle');
await expect(fileInput).toBeAttached({ timeout: 10000 }); 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 { try {
await fileInput.setInputFiles(MULTILINGUAL_TEST_FILES.spanish); await fileInput.setInputFiles(MULTILINGUAL_TEST_FILES.spanish);
@ -217,9 +232,24 @@ test.describe('OCR Multiple Languages', () => {
await page.goto('/upload'); await page.goto('/upload');
await helpers.waitForLoadingToComplete(); await helpers.waitForLoadingToComplete();
// Upload English test document // Wait for page to be fully loaded and rendered (WebKit needs more time)
const fileInput = page.locator('input[type="file"]').first(); await page.waitForLoadState('networkidle');
await expect(fileInput).toBeAttached({ timeout: 10000 }); 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 { try {
await fileInput.setInputFiles(MULTILINGUAL_TEST_FILES.english); await fileInput.setInputFiles(MULTILINGUAL_TEST_FILES.english);

View File

@ -28,25 +28,49 @@ test.describe('WebDAV Workflow', () => {
await expect(loadingSpinner).not.toBeVisible({ timeout: TIMEOUTS.long }); await expect(loadingSpinner).not.toBeVisible({ timeout: TIMEOUTS.long });
} }
// Wait a bit more for the page to fully render // Wait extra time for WebKit to fully render the page
await page.waitForTimeout(2000); await page.waitForTimeout(5000);
// Look for add source button (try multiple selectors) // For WebKit, try to wait for specific page elements to be loaded
const addSourceButton = page.locator('[data-testid="add-source"], button:has-text("Add Source"), button:has-text("Add"), button:has-text("New")').first(); 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(); await addSourceButton.click();
} else { } else {
// Alternative: look for floating action button or plus button // Enhanced debugging for WebKit
const fabButton = page.locator('button[aria-label*="add"], button[title*="add"], .fab, .add-button').first(); const pageContent = await page.textContent('body');
if (await fabButton.isVisible({ timeout: TIMEOUTS.medium })) { console.log('Page content (first 500 chars):', pageContent?.substring(0, 500));
await fabButton.click(); console.log('Page URL:', page.url());
} else {
// Debug: log what's actually visible on the page // Check if we're actually on the sources page
const pageContent = await page.textContent('body'); const pageTitle = await page.title();
console.log('Page content:', pageContent?.substring(0, 500)); console.log('Page title:', pageTitle);
throw new Error('Could not find add source button');
} // 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 // Wait for source creation form/modal to appear