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