Skip to content

Commit

Permalink
UML-3394 updated frontend tests - fixed behat tests
Browse files Browse the repository at this point in the history
  • Loading branch information
allenannom committed Dec 27, 2024
1 parent 77be6c7 commit 429c79b
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 2 deletions.
4 changes: 2 additions & 2 deletions service-front/app/features/actor-one-login.feature
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Feature: Authenticate One Login
@ui
Scenario: I am redirected to the dashboard when local account does exist
Given I have logged in to one login in English
When I have an email address that matches a local account
When I have an email address that matches a local account with LPAs
Then I see the LPA dashboard with any LPAs that are in the account

@ui
Expand All @@ -66,7 +66,7 @@ Feature: Authenticate One Login
@ui
Scenario: I am redirected to the dashboard when local account already flagged as one-login
Given I have logged in to one login in English
When I have an account whose sub matches a local account
When I have an account whose sub matches a local account with LPAs
Then I see the LPA dashboard with any LPAs that are in the account

@ui
Expand Down
77 changes: 77 additions & 0 deletions service-front/app/features/context/UI/AccountContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -2259,6 +2259,83 @@ public function iHaveAMatchingLocalAccount(): void
$this->ui->assertResponseStatus(StatusCodeInterface::STATUS_OK);
}

/**
* @Then /^I have an account whose sub matches a local account with LPAs$/
* @Then /^I have an email address that matches a local account with LPAs$/
*/
public function iHaveAMatchingLocalAccountWithLpas(): void
{
$lpa = json_decode(file_get_contents(__DIR__ . '../../../../test/fixtures/full_example.json'));

$userLpaActorToken = '987654321';

$lpaData = [
'user-lpa-actor-token' => $userLpaActorToken,
'date' => 'today',
'actor' => [
'type' => 'primary-attorney',
'details' => $lpa->attorneys[0],
],
'applicationHasRestrictions' => true,
'applicationHasGuidance' => false,
'lpa' => $lpa,
'added' => '2021-10-5 12:00:00',
];

$dashboardLPAs = [$userLpaActorToken => $lpaData];

$this->apiFixtures->append(
ContextUtilities::newResponse(
StatusCodeInterface::STATUS_OK,
json_encode(
[
'user' => [
'Id' => 'bf9e7e77-f283-49c6-a79c-65d5d309ef77',
'Identity' => 'fakeSub',
'Email' => $this->userEmail,
'LastLogin' => (new DateTime('-1 day'))->format(DateTimeInterface::ATOM),
],
'token' => 'users_login_token',
],
),
self::ONE_LOGIN_SERVICE_CALLBACK
)
);

if ($dashboardLPAs) {
//API call for getting all the users added LPAs
$this->apiFixtures->append(
ContextUtilities::newResponse(
StatusCodeInterface::STATUS_OK,
json_encode($dashboardLPAs),
self::LPA_SERVICE_GET_LPAS
)
);


foreach ($dashboardLPAs as $lpa) {
$this->apiFixtures->append(
ContextUtilities::newResponse(
StatusCodeInterface::STATUS_OK,
json_encode([]),
self::VIEWER_CODE_SERVICE_GET_SHARE_CODES
)
);
}
}

$this->apiFixtures->append(
ContextUtilities::newResponse(
StatusCodeInterface::STATUS_OK,
json_encode([]),
self::SYSTEM_MESSAGE_SERVICE_GET_MESSAGES
)
);

$this->ui->visit('/home/login?code=FakeCode&state=FakeState');
$this->ui->assertResponseStatus(StatusCodeInterface::STATUS_OK);
}

/**
* @Then /^I have an email address that does not match a local account$/
*/
Expand Down

0 comments on commit 429c79b

Please sign in to comment.