From a9eacdb73d2e3e5e222550928ec549fc0a4dfabb Mon Sep 17 00:00:00 2001 From: Mishkat Najam Date: Wed, 15 Nov 2023 17:00:04 +0000 Subject: [PATCH] Add UI test coverage --- .../app/features/actor-view-lpa.feature | 14 ++ .../app/features/context/UI/LpaContext.php | 120 ++++++++---------- 2 files changed, 68 insertions(+), 66 deletions(-) diff --git a/service-front/app/features/actor-view-lpa.feature b/service-front/app/features/actor-view-lpa.feature index 797cb42f82..4f35ed3134 100644 --- a/service-front/app/features/actor-view-lpa.feature +++ b/service-front/app/features/actor-view-lpa.feature @@ -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 \ No newline at end of file diff --git a/service-front/app/features/context/UI/LpaContext.php b/service-front/app/features/context/UI/LpaContext.php index 8e02c10291..19ed35e2bc 100644 --- a/service-front/app/features/context/UI/LpaContext.php +++ b/service-front/app/features/context/UI/LpaContext.php @@ -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(); } /** @@ -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(); } } @@ -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, @@ -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'); } }