fix(e2e): fix keyboard shortcut delete test and reduce sync test flakiness

- Click on .drag-handle instead of task element to properly focus task
  without triggering title edit mode (which would block keyboard shortcuts)
- Verify WebDAV form fields appear after selection before proceeding
- Add clear error message when WebDAV selection fails after retries
This commit is contained in:
Johannes Millan 2026-01-10 11:54:11 +01:00
parent adbea068da
commit 52bf171ec4
2 changed files with 22 additions and 5 deletions

View file

@ -74,6 +74,7 @@ export class SyncPage extends BasePage {
// Use the existing providerSelect locator which targets the mat-select directly
const selectElement = this.providerSelect;
let webdavSelected = false;
for (let attempt = 0; attempt < 5; attempt++) {
// Ensure the select is in view
await selectElement.scrollIntoViewIfNeeded({ timeout: 5000 }).catch(async () => {
@ -121,9 +122,16 @@ export class SyncPage extends BasePage {
if (webdavVisible) {
await webdavOption.click();
// Wait for dropdown to close and form to update
await this.page.waitForTimeout(500);
break;
// Wait for dropdown to close and verify form fields appeared
const formAppeared = await this.baseUrlInput
.waitFor({ state: 'visible', timeout: 3000 })
.then(() => true)
.catch(() => false);
if (formAppeared) {
webdavSelected = true;
break;
}
// Form didn't appear, retry selection
}
}
@ -132,6 +140,13 @@ export class SyncPage extends BasePage {
await this.page.waitForTimeout(500);
}
// Verify WebDAV was selected before proceeding
if (!webdavSelected) {
throw new Error(
'Failed to select WebDAV option after 5 attempts. Check if the dropdown is properly rendered.',
);
}
// Wait for form fields to be visible before filling
await this.baseUrlInput.waitFor({ state: 'visible', timeout: 10000 });

View file

@ -87,8 +87,10 @@ test.describe('Task Delete Confirmation', () => {
await workViewPage.addTask('Task to delete with keyboard');
await expect(page.locator('task')).toHaveCount(1);
// Focus the task
await page.locator('task').first().click();
// Focus the task by clicking on drag-handle (not task-title which would open edit mode)
const task = page.locator('task').first();
await task.locator('.drag-handle').click();
await expect(task).toBeFocused();
// Act: Press Backspace (default delete shortcut)
await page.keyboard.press('Backspace');