File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -172,6 +172,33 @@ export class TestingBehatRuntimeService {
172172 const promises = coreLoadingsPromises . concat ( ionLoadingsPromises ) ;
173173
174174 await Promise . all ( promises ) ;
175+
176+ // Wait for ion-spinner to be removed from the DOM after loadings because loadings can contain spinners.
177+ const ionSpinnerPromises : Promise < unknown > [ ] =
178+ Array . from ( document . body . querySelectorAll < HTMLIonSpinnerElement > ( 'ion-spinner' ) )
179+ . filter ( ( element ) => CoreDom . isElementVisible ( element ) )
180+ . map ( ( element ) =>
181+ // Wait to the spinner to be removed from the DOM.
182+ new Promise < void > ( ( resolve ) => {
183+ const parentElement = element . parentElement ;
184+
185+ if ( ! parentElement ) {
186+ resolve ( ) ;
187+
188+ return ;
189+ }
190+
191+ const observer = new MutationObserver ( ( ) => {
192+ if ( ! parentElement . contains ( element ) ) {
193+ observer . disconnect ( ) ;
194+ resolve ( ) ;
195+ }
196+ } ) ;
197+
198+ observer . observe ( parentElement , { childList : true } ) ;
199+ } ) ) ;
200+
201+ await Promise . all ( ionSpinnerPromises ) ;
175202 } ) ;
176203 }
177204
You can’t perform that action at this time.
0 commit comments