From efee601918b3630b46ef559e5e85a0217d1afbb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Fri, 15 Dec 2023 16:09:40 +0100 Subject: [PATCH] MOBILE-3947 behat: Fix backdrop selector Co-authored-by: NoelDeMartin --- src/testing/services/behat-runtime.ts | 11 +++++++---- src/tests/behat/navigation_externallinks.feature | 1 - 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/testing/services/behat-runtime.ts b/src/testing/services/behat-runtime.ts index bb0bd4740..0b938c175 100644 --- a/src/testing/services/behat-runtime.ts +++ b/src/testing/services/behat-runtime.ts @@ -186,17 +186,20 @@ export class TestingBehatRuntimeService { closePopup(): string { this.log('Action - Close popup'); - let backdrops = Array.from(document.querySelectorAll('ion-backdrop')); - backdrops = backdrops.filter((backdrop) => !!backdrop.offsetParent); + const backdrops = Array + .from(document.querySelectorAll('ion-popover, ion-modal')) + .map(popover => popover.shadowRoot?.querySelector('ion-backdrop')) + .filter(backdrop => !!backdrop); if (!backdrops.length) { return 'ERROR: Could not find backdrop'; } + if (backdrops.length > 1) { return 'ERROR: Found too many backdrops ('+backdrops.length+')'; } - const backdrop = backdrops[0]; - backdrop.click(); + + backdrops[0]?.click(); // Mark busy until the click finishes processing. TestingBehatBlocking.delay(); diff --git a/src/tests/behat/navigation_externallinks.feature b/src/tests/behat/navigation_externallinks.feature index 3b4c497d0..b68264704 100644 --- a/src/tests/behat/navigation_externallinks.feature +++ b/src/tests/behat/navigation_externallinks.feature @@ -18,7 +18,6 @@ Feature: It opens external links properly. | forum | user | name | message | | Test forum | student1 | Forum topic | See moodle.org external link | - @ionic7_failure Scenario: Click an external link Given I entered the forum activity "Test forum" on course "Course 1" as "student1" in the app When I press "Forum topic" in the app