Skip to content

Commit

Permalink
Add UI test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
MishNajam committed Nov 15, 2023
1 parent 30d1bef commit a9eacdb
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 66 deletions.
14 changes: 14 additions & 0 deletions service-front/app/features/actor-view-lpa.feature
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,17 @@ Feature: View an LPA that I have added to my account
And I am on the dashboard page
When I request to view an LPA which has an inactive attorney named 'Harold Stallman'
Then I will not see 'Harold Stallman' in the attorney section of LPA summary

@ui
Scenario: Show also known as when an actor has other names defined
Given I have added an LPA to my account
And I am on the dashboard page
When I request to view an LPA with a donor who is also known as 'Ezra'
Then I will see 'Ezra' in the also known as field

@ui
Scenario: Do not show also known as when no actors have other names defined
Given I have added an LPA to my account
And I am on the dashboard page
When I request to view an LPA where all actors do not have an also known by name
Then I will not see the also known as field
120 changes: 54 additions & 66 deletions service-front/app/features/context/UI/LpaContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -2369,37 +2369,7 @@ public function iRequestToViewAnLPAWhichHasADonorSignatureBefore2016(): void
{
$this->ui->assertPageContainsText('View LPA summary');

$this->apiFixtures->append(
ContextUtilities::newResponse(
StatusCodeInterface::STATUS_OK,
json_encode(
[
'user-lpa-actor-token' => $this->userLpaActorToken,
'date' => 'date',
'lpa' => $this->lpa,
'actor' => $this->lpaData['actor'],
]
),
self::LPA_SERVICE_GET_LPA_BY_ID
)
);

// InstAndPrefImagesService::getImagesById
$this->apiFixtures->append(
ContextUtilities::newResponse(
StatusCodeInterface::STATUS_OK,
json_encode(
[
'uId' => (int) $this->lpa->uId,
'status' => 'COLLECTION_COMPLETE',
'signedUrls' => [],
]
),
self::INPSERVICE_GET_BY_ID
)
);

$this->ui->clickLink('View LPA summary');
$this->mockApiGetLpaByIdAndGetImagesById();
}

/**
Expand Down Expand Up @@ -2427,37 +2397,7 @@ public function iRequestToViewAnLPAWhichStatusIs($status): void
);
} else {
// API call for get LpaById
$this->apiFixtures->append(
ContextUtilities::newResponse(
StatusCodeInterface::STATUS_OK,
json_encode(
[
'user-lpa-actor-token' => $this->userLpaActorToken,
'date' => 'date',
'lpa' => $this->lpa,
'actor' => $this->lpaData['actor'],
]
),
self::LPA_SERVICE_GET_LPA_BY_ID
)
);

// InstAndPrefImagesService::getImagesById
$this->apiFixtures->append(
ContextUtilities::newResponse(
StatusCodeInterface::STATUS_OK,
json_encode(
[
'uId' => (int) $this->lpa->uId,
'status' => 'COLLECTION_COMPLETE',
'signedUrls' => [],
]
),
self::INPSERVICE_GET_BY_ID
)
);

$this->ui->clickLink('View LPA summary');
$this->mockApiGetLpaByIdAndGetImagesById();
}
}

Expand Down Expand Up @@ -3053,6 +2993,45 @@ public function iRequestToViewAnLPAWhichHasAnInactiveAttorney($name): void
{
$this->ui->assertPageContainsText('View LPA summary');

$this->mockApiGetLpaByIdAndGetImagesById();
}

/**
* @Then /^I will not see (.*) in the attorney section of LPA summary$/
*/
public function iWillNotSeeInactiveAttorneyInTheListOfAttorneys($name): void
{
$this->ui->assertPageAddress('/lpa/view-lpa');
$this->ui->assertPageContainsText('The attorneys');
$this->ui->assertPageNotContainsText($name);
}

/**
* @When /^I request to view an LPA with a donor who is also known as (.*)$/
*/
public function iRequestToViewAnLPAWithADonorWhoIsAlsoKnownAs($name): void
{
$this->ui->assertPageContainsText('View LPA summary');
$this->lpa->donor->otherNames = $name;
$this->mockApiGetLpaByIdAndGetImagesById();
}

/**
* @When /^I request to view an LPA where all actors do not have an also known by name$/
*/
public function iRequestToViewAnWhereAllActorsDoNotHaveAnAlsoKnownByName(): void
{
$this->ui->assertPageContainsText('View LPA summary');
$this->lpa->donor->otherNames = null;

foreach($this->lpa->attorneys as $attorney) {
$attorney->otherNames = null;
}
$this->mockApiGetLpaByIdAndGetImagesById();
}

public function mockApiGetLpaByIdAndGetImagesById(): void
{
$this->apiFixtures->append(
ContextUtilities::newResponse(
StatusCodeInterface::STATUS_OK,
Expand Down Expand Up @@ -3087,12 +3066,21 @@ public function iRequestToViewAnLPAWhichHasAnInactiveAttorney($name): void
}

/**
* @Then /^I will not see (.*) in the attorney section of LPA summary$/
* @Then /^I will see (.*) in the also known as field$/
*/
public function iWillNotSeeInactiveAttorneyInTheListOfAttorneys($name): void
public function iWillSeeNameInTheAlsoKnownAsField($name): void
{
$this->ui->assertPageAddress('/lpa/view-lpa');
$this->ui->assertPageContainsText('The attorneys');
$this->ui->assertPageNotContainsText($name);
$this->ui->assertPageContainsText('Also known as');
$this->ui->assertPageContainsText($name);
}

/**
* @Then /^I will not see the also known as field$/
*/
public function iWillNotSeeTheAlsoKnownAsField(): void
{
$this->ui->assertPageAddress('/lpa/view-lpa');
$this->ui->assertPageNotContainsText('Also known as');
}
}

0 comments on commit a9eacdb

Please sign in to comment.