[Cypress] Retry toolbar clicks to open submenu

Introducing a little helper function that retries clicks until
some element becomes visible.

Bug: T360026
Change-Id: I45b7802c8009b9b552b41c1fcaf861f2a7afb495
This commit is contained in:
WMDE-Fisch 2024-03-26 19:52:45 +01:00
parent 4e935abb2e
commit 66996fe45d

View file

@ -5,6 +5,17 @@ export function waitForVEToLoad() {
.should( 'be.visible' );
}
function clickUntilVisible( clickElement, expectedSelector ) {
cy.get( expectedSelector ).then( ( $element ) => {
if ( $element.is( ':visible' ) ) {
return;
}
clickElement.click();
clickUntilVisible( clickElement, expectedSelector );
} );
}
export function getTestString( prefix = '' ) {
return prefix + Math.random().toString();
}
@ -81,7 +92,10 @@ export function getVEReferenceEditDialog() {
}
export function openVECiteReuseDialog() {
cy.get( '.ve-ui-toolbar-group-cite' ).click();
clickUntilVisible(
cy.get( '.ve-ui-toolbar-group-cite' ),
'.ve-ui-toolbar .oo-ui-tool-name-reference-existing'
);
cy.get( '.ve-ui-toolbar .oo-ui-tool-name-reference-existing' ).click();
}