[Cypress] Add timeouts to the click retry helper

Just to be sure we do not try to click endlessly here.

Change-Id: I9d7fd5f1380a2ce38a93c61dc1a8e5280f626ec9
This commit is contained in:
WMDE-Fisch 2024-03-28 14:22:28 +01:00
parent 48e65a0317
commit 6b13325961

View file

@ -5,15 +5,21 @@ export function waitForVEToLoad() {
.should( 'be.visible' );
}
function clickUntilVisible( clickElement, expectedSelector ) {
function clickUntilVisible( clickElement, expectedSelector, timeout = 5000 ) {
const timeoutTime = Date.now() + timeout;
function clickUntilVisibleWithinTime() {
cy.get( expectedSelector ).then( ( $element ) => {
if ( $element.is( ':visible' ) ) {
if ( Date.now() > timeoutTime || $element.is( ':visible' ) ) {
return;
}
clickElement.click();
clickUntilVisible( clickElement, expectedSelector );
clickUntilVisibleWithinTime();
} );
}
clickUntilVisibleWithinTime();
}
export function getTestString( prefix = '' ) {