Skip to content

Commit

Permalink
Add behat test
Browse files Browse the repository at this point in the history
  • Loading branch information
MishNajam committed Nov 1, 2023
1 parent 18de379 commit ed449b2
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 14 deletions.
44 changes: 30 additions & 14 deletions service-front/app/features/context/UI/AccountContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -2047,6 +2047,36 @@ public function iAmOnTheTemporaryOneLoginPage(): void
* @When /^I click the one login button$/
*/
public function iClickTheOneLoginButton(): void
{
$this->signInViaOneLogin();
$request = $this->apiFixtures->getLastRequest();
$params = $request->getUri()->getQuery();
Assert::assertStringContainsString('ui_locale=en', $params);
}

/**
* @When /^I click the one login button in welsh$/
*/
public function iClickTheOneLoginButtonInWelsh(): void
{
$this->signInViaOneLogin();

$request = $this->apiFixtures->getLastRequest();
$params = $request->getUri()->getQuery();
Assert::assertStringContainsString('ui_locale=cy', $params);
}

/**
* @Then /^I am redirected to the redirect page$/
*/
public function iAmRedirectedToTheRedirectPage(): void
{
$locationHeader = $this->ui->getSession()->getResponseHeader('Location');
assert::assertTrue(isset($locationHeader));
assert::assertEquals($locationHeader, 'http://fake.url/authorize');
}

public function signInViaOneLogin(): void
{
$this->apiFixtures->append(
ContextUtilities::newResponse(
Expand All @@ -2065,19 +2095,5 @@ public function iClickTheOneLoginButton(): void
$this->iDoNotFollowRedirects();
$this->ui->pressButton('Sign in via One Login');
$this->iDoFollowRedirects();

$request = $this->apiFixtures->getLastRequest();
$params = $request->getUri()->getQuery();
Assert::assertStringContainsString('ui_locale=en', $params);
}

/**
* @Then /^I am redirected to the redirect page$/
*/
public function iAmRedirectedToTheRedirectPage(): void
{
$locationHeader = $this->ui->getSession()->getResponseHeader('Location');
assert::assertTrue(isset($locationHeader));
assert::assertEquals($locationHeader, 'http://fake.url/authorize');
}
}
7 changes: 7 additions & 0 deletions service-front/app/features/one-login.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,10 @@
Given I am on the temporary one login page
When I click the one login button
Then I am redirected to the redirect page

@ui @actor @ff:allow_gov_one_login:true @welsh
Scenario: I initiate authentication via one login in Welsh
Given I am on the temporary one login page
And I request to view the content in welsh
When I click the one login button in welsh
Then I am redirected to the redirect page

0 comments on commit ed449b2

Please sign in to comment.