From 1d7b91f47f2b0119113f6a7c9965b811939c6d9f Mon Sep 17 00:00:00 2001 From: Mishkat Najam Date: Wed, 29 Nov 2023 17:05:26 +0000 Subject: [PATCH] fix behat tests --- .../features/context/UI/AccountContext.php | 28 +++++-------------- service-front/app/features/one-login.feature | 13 ++++----- 2 files changed, 13 insertions(+), 28 deletions(-) diff --git a/service-front/app/features/context/UI/AccountContext.php b/service-front/app/features/context/UI/AccountContext.php index 2966c6ced2..c7f2457c49 100644 --- a/service-front/app/features/context/UI/AccountContext.php +++ b/service-front/app/features/context/UI/AccountContext.php @@ -2078,8 +2078,8 @@ public function iClickTheOneLoginButton(): void public function iHaveLoggedInToOneLogin($language): void { $this->iAmOnTheTemporaryOneLoginPage(); - $language = $language === 'English' ? 'en' : 'cy'; - if ($language === 'cy') { + $this->language = $language === 'English' ? 'en' : 'cy'; + if ($this->language === 'cy') { $this->iSelectTheWelshLanguage(); } $this->iClickTheOneLoginButton(); @@ -2119,26 +2119,12 @@ public function oneLoginReturnsAError($errorType): void } /** - * @Then /^I am redirected to the login page with a "(.*)" error message$/ + * @Then /^I am redirected to the login page with a "(.*)" error and "(.*)"$/ */ - public function iAmRedirectedToTheErrorPage($errorType): void + public function iAmRedirectedToTheLanguageErrorPage($errorType, $errorMessage): void { - $this->ui->assertPageAddress('/home?error=' . $errorType); - } - - /** - * @Then /^I am redirected to the Welsh login page with a "(.*)" error message$/ - */ - public function iAmRedirectedToTheWelshErrorPage($errorType): void - { - $this->ui->assertPageAddress('/cy/home?error=' . $errorType); - } - - /** - * @Then /^I should be told "(.*)"$/ - */ - public function iSeeTheText($text): void - { - $this->ui->assertPageContainsText($text); + $basePath = $this->language === 'cy' ? '/cy' : ''; + $this->ui->assertPageAddress($basePath . '/home?error=' . $errorType); + $this->ui->assertPageContainsText($errorMessage); } } diff --git a/service-front/app/features/one-login.feature b/service-front/app/features/one-login.feature index 3fc637bcb1..f798ffec41 100644 --- a/service-front/app/features/one-login.feature +++ b/service-front/app/features/one-login.feature @@ -18,15 +18,14 @@ Scenario Outline: One Login returns a specific error Given I have logged in to one login in When One Login returns a "" error - Then I am redirected to the login page with a "" error message - And I should be told "" + Then I am redirected to the login page with a "" error and "" Examples: - |language | error_type | error_message | - | English | access_denied | Tried to login however access is denied | - | English | temporarily_unavailable | One Login is temporarily unavailable | - | Welsh | access_denied | Mae problem | - | Welsh | temporarily_unavailable | Mae problem | + | language | error_type | error_message | + | English | access_denied | Tried to login however access is denied | + | English | temporarily_unavailable | One Login is temporarily unavailable | + | Welsh | access_denied | Mae problem | + | Welsh | temporarily_unavailable | Mae problem | @ui @actor @ff:allow_gov_one_login:true Scenario Outline: One Login returns a generic error