From f695617ba7a8f29f731f7f109c3ef3d5f5c26b7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Szo=C5=82tysek?= Date: Wed, 12 Feb 2025 15:42:38 +0100 Subject: [PATCH 1/6] Bump BaseElement timeout --- src/lib/Browser/Element/BaseElement.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/Browser/Element/BaseElement.php b/src/lib/Browser/Element/BaseElement.php index 7ca8d45c..a00b72c8 100644 --- a/src/lib/Browser/Element/BaseElement.php +++ b/src/lib/Browser/Element/BaseElement.php @@ -17,7 +17,7 @@ abstract class BaseElement implements BaseElementInterface { - protected int $timeout = 1; + protected int $timeout = 3; private ElementFactoryInterface $elementFactory; From cb15c49e886a5e627bbcae942889cbb58297f606 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Szo=C5=82tysek?= Date: Fri, 14 Feb 2025 16:01:18 +0100 Subject: [PATCH 2/6] retry on random login failure --- src/lib/Browser/Page/RedirectLoginPage.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/lib/Browser/Page/RedirectLoginPage.php b/src/lib/Browser/Page/RedirectLoginPage.php index 7a1112ba..0d923bbb 100644 --- a/src/lib/Browser/Page/RedirectLoginPage.php +++ b/src/lib/Browser/Page/RedirectLoginPage.php @@ -8,8 +8,10 @@ namespace Ibexa\Behat\Browser\Page; +use Exception; use Ibexa\Behat\Browser\Locator\CSSLocator; use PHPUnit\Framework\Assert; +use Ibexa\Behat\Browser\Exception\ElementNotFoundException; class RedirectLoginPage extends LoginPage { @@ -25,10 +27,18 @@ public function verifyIsLoaded(): void public function loginSuccessfully($username, $password): void { - parent::loginSuccessfully($username, $password); - $this->getHTMLPage() - ->findAll(new CSSLocator('loginSuccess', '#login-success')) - ->assert()->hasElements(); + for ($attempt = 0; $attempt < 3; $attempt++) { + try { + parent::loginSuccessfully($username, $password); + $this->getHTMLPage() + ->findAll(new CSSLocator('loginSuccess', '#login-success')) + ->assert()->hasElements(); + return; + } catch (Exception $e) { + // Retry on failure + } + } + throw new ElementNotFoundException('Login failed after multiple attempts.'); } protected function getRoute(): string From 27259ad6f21e02851ae13f8c3cd416151c6be188 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Szo=C5=82tysek?= Date: Mon, 17 Feb 2025 10:23:37 +0100 Subject: [PATCH 3/6] cs --- src/lib/Browser/Page/RedirectLoginPage.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib/Browser/Page/RedirectLoginPage.php b/src/lib/Browser/Page/RedirectLoginPage.php index 0d923bbb..3a0a8e60 100644 --- a/src/lib/Browser/Page/RedirectLoginPage.php +++ b/src/lib/Browser/Page/RedirectLoginPage.php @@ -9,9 +9,9 @@ namespace Ibexa\Behat\Browser\Page; use Exception; +use Ibexa\Behat\Browser\Exception\ElementNotFoundException; use Ibexa\Behat\Browser\Locator\CSSLocator; use PHPUnit\Framework\Assert; -use Ibexa\Behat\Browser\Exception\ElementNotFoundException; class RedirectLoginPage extends LoginPage { @@ -27,12 +27,13 @@ public function verifyIsLoaded(): void public function loginSuccessfully($username, $password): void { - for ($attempt = 0; $attempt < 3; $attempt++) { + for ($attempt = 0; $attempt < 3; ++$attempt) { try { parent::loginSuccessfully($username, $password); $this->getHTMLPage() ->findAll(new CSSLocator('loginSuccess', '#login-success')) ->assert()->hasElements(); + return; } catch (Exception $e) { // Retry on failure From b37a2fbc7e7a62b598692b7fb488ad6e075664f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Szo=C5=82tysek?= Date: Mon, 17 Feb 2025 12:52:21 +0100 Subject: [PATCH 4/6] Revert "phpstan" This reverts commit 0d99a6dad30fd5adfadba6c93d54404414910032. --- phpstan-baseline.neon | 5 ----- 1 file changed, 5 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 14bd2055..ce11fd35 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -230,11 +230,6 @@ parameters: count: 1 path: src/bundle/Initializer/BehatSiteAccessInitializer.php - - - message: "#^Call to an undefined method Behat\\\\Gherkin\\\\Node\\\\ScenarioLikeInterface\\:\\:hasTag\\(\\)\\.$#" - count: 1 - path: src/bundle/Subscriber/StartScenarioSubscriber.php - - message: "#^Cannot call method isStarted\\(\\) on object\\|null\\.$#" count: 1 From 61f8cc857744c79b940225e3b530acce560667dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Szo=C5=82tysek?= Date: Mon, 17 Feb 2025 13:10:36 +0100 Subject: [PATCH 5/6] adjust unit test to changed timeout --- tests/lib/Browser/Element/ElementTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/lib/Browser/Element/ElementTest.php b/tests/lib/Browser/Element/ElementTest.php index b40ad725..ecad04a7 100644 --- a/tests/lib/Browser/Element/ElementTest.php +++ b/tests/lib/Browser/Element/ElementTest.php @@ -55,7 +55,7 @@ public function testFindElementWhenNotExists(): void $element = $this->createElementWithMinkElement($minkElement); $this->expectException(TimeoutException::class); - $this->expectExceptionMessage("CSS selector 'invalid-id': 'invalid-selector' not found in 1 seconds."); + $this->expectExceptionMessage("CSS selector 'invalid-id': 'invalid-selector' not found in 3 seconds."); $element->find($this->invalidLocator); } From 8ba3720b4b3bf95803755646a16d778429345063 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Szo=C5=82tysek?= Date: Mon, 17 Feb 2025 13:31:40 +0100 Subject: [PATCH 6/6] fixup! Revert "phpstan" --- phpstan-baseline.neon | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index ce11fd35..14bd2055 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -230,6 +230,11 @@ parameters: count: 1 path: src/bundle/Initializer/BehatSiteAccessInitializer.php + - + message: "#^Call to an undefined method Behat\\\\Gherkin\\\\Node\\\\ScenarioLikeInterface\\:\\:hasTag\\(\\)\\.$#" + count: 1 + path: src/bundle/Subscriber/StartScenarioSubscriber.php + - message: "#^Cannot call method isStarted\\(\\) on object\\|null\\.$#" count: 1