From d56cc0558f64b8c5be237c7d9ae5b66c3841041b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Wed, 19 Oct 2022 18:12:43 +0200 Subject: [PATCH] fix stan, improve test --- demos/interactive/modal.php | 2 +- src/Behat/Context.php | 3 ++- tests-behat/form.feature | 4 ++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/demos/interactive/modal.php b/demos/interactive/modal.php index cfbbff13a1..3aae80d403 100644 --- a/demos/interactive/modal.php +++ b/demos/interactive/modal.php @@ -168,7 +168,7 @@ $stepModal->addButtonAction($action); // Set modal functionality. Will changes content according to page being displayed. -$stepModal->set(function (View $p) use ($stepModal, $session, $prevAction, $nextAction) { +$stepModal->set(function (View $p) use ($session, $prevAction, $nextAction) { $page = $session->recall('page', 1); $success = $session->recall('success', false); if (isset($_GET['move'])) { diff --git a/src/Behat/Context.php b/src/Behat/Context.php index 23728bf336..4e75e194a5 100644 --- a/src/Behat/Context.php +++ b/src/Behat/Context.php @@ -402,7 +402,8 @@ public function iClickCloseModal(): void */ public function iHideJsModal(): void { - $this->getSession()->executeScript('$(".modal.active.front").modal("hide")'); + $modal = $this->findElement(null, '.modal.visible.active.front'); + $this->getSession()->executeScript('$(arguments[0]).modal("hide")', [$modal]); } // }}} diff --git a/tests-behat/form.feature b/tests-behat/form.feature index c5a097987c..2eb5ef0ac7 100644 --- a/tests-behat/form.feature +++ b/tests-behat/form.feature @@ -41,6 +41,10 @@ Feature: Form When I press Modal button "Save" Then Modal is open with text "Atk4\Core\Exception: Test exception II." Then I hide js modal + Then I hide js modal When I press button "Modal Test" When I press Modal button "Save" Then Modal is open with text "Atk4\Core\Exception: Test exception II." + Then I hide js modal + When I press Modal button "Save" + Then Modal is open with text "Atk4\Core\Exception: Test exception II."