mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-27 08:20:02 +00:00
[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:
parent
48e65a0317
commit
6b13325961
|
@ -5,15 +5,21 @@ export function waitForVEToLoad() {
|
|||
.should( 'be.visible' );
|
||||
}
|
||||
|
||||
function clickUntilVisible( clickElement, expectedSelector ) {
|
||||
cy.get( expectedSelector ).then( ( $element ) => {
|
||||
if ( $element.is( ':visible' ) ) {
|
||||
return;
|
||||
}
|
||||
function clickUntilVisible( clickElement, expectedSelector, timeout = 5000 ) {
|
||||
const timeoutTime = Date.now() + timeout;
|
||||
|
||||
clickElement.click();
|
||||
clickUntilVisible( clickElement, expectedSelector );
|
||||
} );
|
||||
function clickUntilVisibleWithinTime() {
|
||||
cy.get( expectedSelector ).then( ( $element ) => {
|
||||
if ( Date.now() > timeoutTime || $element.is( ':visible' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
clickElement.click();
|
||||
clickUntilVisibleWithinTime();
|
||||
} );
|
||||
}
|
||||
|
||||
clickUntilVisibleWithinTime();
|
||||
}
|
||||
|
||||
export function getTestString( prefix = '' ) {
|
||||
|
|
Loading…
Reference in a new issue