test(e2e): click first visible interactive element

Avoid failing on mobile-only hidden buttons in desktop viewport.

Co-authored-by: dennis <dennis@konkol.net>
This commit is contained in:
Cursor Agent
2026-01-14 22:00:39 +00:00
parent 721bdfaf53
commit 63fc45488a

View File

@@ -119,13 +119,20 @@ test.describe('Hydration Tests', () => {
const buttonCount = await buttons.count();
if (buttonCount > 0) {
const firstButton = buttons.first();
await expect(firstButton).toBeVisible();
// Try clicking (should not throw)
await firstButton.click().catch(() => {
// Some buttons might be disabled, that's OK
});
// Find a visible interactive element (desktop hides some mobile-only buttons)
let clicked = false;
for (let i = 0; i < Math.min(buttonCount, 25); i++) {
const candidate = buttons.nth(i);
// eslint-disable-next-line no-await-in-loop
if (await candidate.isVisible()) {
await candidate.click().catch(() => {
// Some buttons might be disabled or covered, that's OK
});
clicked = true;
break;
}
}
expect(clicked).toBe(true);
}
});
});