fix(e2e): improve WebDAV sync test reliability

- Add waitForAppReady and tour dismissal after page reload in
  webdav-sync-tags test to prevent task-list timeout
- Use existing providerSelect locator instead of role-based combobox
  selector in sync.page.ts for more reliable dropdown interaction
- Add graceful error handling for scrollIntoViewIfNeeded with fallback
This commit is contained in:
Johannes Millan 2026-01-02 19:59:59 +01:00
parent 092d32a39e
commit e6b6468d2a
2 changed files with 31 additions and 7 deletions

View file

@ -71,22 +71,28 @@ export class SyncPage extends BasePage {
// Click on provider select to open dropdown with retry
const webdavOption = this.page.locator('mat-option').filter({ hasText: 'WebDAV' });
// Try using role-based selector for the combobox
const combobox = this.page.getByRole('combobox', { name: 'Sync Provider' });
// Use the existing providerSelect locator which targets the mat-select directly
const selectElement = this.providerSelect;
for (let attempt = 0; attempt < 5; attempt++) {
// Ensure the select is in view
await combobox.scrollIntoViewIfNeeded();
await selectElement.scrollIntoViewIfNeeded({ timeout: 5000 }).catch(async () => {
// If scrollIntoViewIfNeeded fails, try scrolling the dialog content
const dialogContent = this.page.locator('mat-dialog-content');
if (await dialogContent.isVisible()) {
await dialogContent.evaluate((el) => el.scrollTo(0, 0));
}
});
await this.page.waitForTimeout(300);
// Focus the combobox first
await combobox.focus();
// Focus and click the select element
await selectElement.focus().catch(() => {});
await this.page.waitForTimeout(200);
// Try multiple ways to open the dropdown
if (attempt === 0) {
// First attempt: regular click
await combobox.click();
await selectElement.click().catch(() => {});
} else if (attempt === 1) {
// Second attempt: use Space key to open
await this.page.keyboard.press('Space');
@ -95,7 +101,7 @@ export class SyncPage extends BasePage {
await this.page.keyboard.press('ArrowDown');
} else {
// Later attempts: force click
await combobox.click({ force: true });
await selectElement.click({ force: true }).catch(() => {});
}
await this.page.waitForTimeout(500);

View file

@ -10,6 +10,7 @@ import {
setupClient,
waitForSync,
} from '../../utils/sync-helpers';
import { waitForAppReady } from '../../utils/waits';
test.describe('WebDAV Sync Tags', () => {
// Run sync tests serially to avoid WebDAV server contention
@ -213,6 +214,23 @@ test.describe('WebDAV Sync Tags', () => {
// Reload to ensure UI updates
await pageB.reload();
await waitForAppReady(pageB);
// Dismiss tour if it appears
try {
const tourElement = pageB.locator('.shepherd-element').first();
await tourElement.waitFor({ state: 'visible', timeout: 2000 });
const cancelIcon = pageB.locator('.shepherd-cancel-icon').first();
if (await cancelIcon.isVisible()) {
await cancelIcon.click();
} else {
await pageB.keyboard.press('Escape');
}
await tourElement.waitFor({ state: 'hidden', timeout: 3000 });
} catch {
// Tour didn't appear or wasn't dismissable
}
await workViewPageB.waitForTaskList();
// Verify task still exists but without the specific tag indicator