Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UML-3628 Request a key templates to work with combined format #2978

Merged
merged 13 commits into from
Jan 2, 2025
Merged
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ services:
ALLOW_MERIS_LPAS: "false"
INSTRUCTIONS_AND_PREFERENCES: "true"
ALLOW_GOV_ONE_LOGIN: "true"
SUPPORT_DATASTORE_LPAS: "false"
SUPPORT_DATASTORE_LPAS: "true"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be set to false as the feature isn't ready for production yet

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I need a run to get the dev links for UAT. will revert after UAT


# Local only
API_SERVICE_URL:
Expand Down
2 changes: 1 addition & 1 deletion service-front/app/features/actor-view-lpa.feature
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Feature: View an LPA that I have added to my account
Scenario Outline: The user can view a Combined LPA added to their account
Given I have added a Combined LPA to my account
And I am on the dashboard page
When I request to view an LPA which status is "<status>"
When I request to view a Combined LPA which status is "<status>"
Then The full LPA is displayed with the correct <message>
Examples:
| status | message |
Expand Down
140 changes: 140 additions & 0 deletions service-front/app/features/context/Integration/LpaContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,146 @@ public function iHaveAddedAnLPAToMyAccount()
$this->theLPAIsSuccessfullyAdded();
}

/**
* @Given /^I have added a Combined LPA to my account$/
*/
public function iHaveAddedACombinedLPAToMyAccount()
{
$this->iHaveBeenGivenAccessToUseACombinedLPAViaCredentials();
$this->iAmOnTheAddAnLPAPage();
$this->iRequestToAddACombinedLPAWithValidDetailsUsing($this->activation_key, $this->activation_key);
$this->theCorrectLPAIsFoundAndICanConfirmToAddIt();
$this->theLPAIsSuccessfullyAdded();
}

/**
* @Given /^I have been given access to use a Combined LPA via credentials$/
*/
public function iHaveBeenGivenAccessToUseACombinedLPAViaCredentials()
{
$this->lpa = json_decode(file_get_contents(__DIR__ . '../../../../test/fixtures/combined_lpa.json'));

$this->activation_key = 'XYUPHWQRECHV';
$this->referenceNo = '700000000138';
$this->userDob = '1975-10-05';
$this->actorLpaToken = '24680';
$this->actorId = 0;

$this->lpaData = [
'user-lpa-actor-token' => $this->actorLpaToken,
'date' => 'today',
'actor' => [
'type' => 'primary-attorney',
'details' => [
'addresses' => [
[
'addressLine1' => '',
'addressLine2' => '',
'addressLine3' => '',
'country' => '',
'county' => '',
'id' => 0,
'postcode' => '',
'town' => '',
'type' => 'Primary',
],
],
'companyName' => null,
'dob' => '1975-10-05',
'email' => '[email protected]',
'firstname' => 'Ian',
'id' => 0,
'middlenames' => null,
'salutation' => 'Mr',
'surname' => 'Deputy',
'systemStatus' => true,
'uId' => '700000000054',
],
],
'lpa' => $this->lpa,
];
}

public function iRequestToAddACombinedLPAWithValidDetailsUsing(string $code, string $storedCode)
{
// API call for checking LPA
$this->apiFixtures->append(
ContextUtilities::newResponse(
StatusCodeInterface::STATUS_OK,
json_encode($this->lpaData),
self::ADD_LPA_VALIDATE
)
);

$addLpa = $this->container->get(AddLpa::class);
$lpaData = $addLpa->validate(
$this->userIdentity,
$storedCode,
$this->referenceNo,
$this->userDob
);

Assert::assertInstanceOf(AddLpaApiResult::class, $lpaData);
Assert::assertEquals(AddLpaApiResult::ADD_LPA_FOUND, $lpaData->getResponse());
Assert::assertEquals(($lpaData->getData()['lpa'])->getUId(), $this->lpa->uId);
}

/**
* @When /^I request to view a Combined LPA which status is "([^"]*)"$/
*/
public function iRequestToViewACombinedLPAWhichStatusIs($status)
{
$this->lpa->status = $status;

if ($status === 'Revoked') {
// API call for getting the LPA by id
$this->apiFixtures->append(
ContextUtilities::newResponse(
StatusCodeInterface::STATUS_OK,
json_encode(
[
'user-lpa-actor-token' => $this->actorLpaToken,
'date' => 'date',
'lpa' => [],
'actor' => $this->lpaData['actor'],
]
)
)
);
} else {
// API call for getting the LPA by id
$this->apiFixtures->append(
ContextUtilities::newResponse(
StatusCodeInterface::STATUS_OK,
json_encode(
[
'user-lpa-actor-token' => $this->actorLpaToken,
'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
)
);
}
}

/**
* @Given /^I have been given access to use an LPA via a paper document$/
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Log\LoggerInterface;
use Common\Service\Features\FeatureEnabled;

/**
* @codeCoverageIgnore
Expand Down Expand Up @@ -66,6 +67,7 @@ public function __construct(
private RateLimitService $rateLimitService,
private TranslatorInterface $translator,
private AddLpa $addLpa,
private FeatureEnabled $featureEnabled,
) {
parent::__construct($renderer, $urlHelper, $logger);

Expand Down Expand Up @@ -195,9 +197,14 @@ public function handleGet(
$lpa->getCaseSubtype() === 'hw' ? 'health and welfare' : 'property and finance'
);

$templateName = 'actor::check-lpa';
if (($this->featureEnabled)('support_datastore_lpas')) {
$templateName = 'actor::check-combined-lpa';
}

return new HtmlResponse(
$this->renderer->render(
'actor::check-lpa',
$templateName,
[
'form' => $this->form,
'lpa' => $lpa,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@ public function handle(ServerRequestInterface $request): ResponseInterface
$lpaData = $this->lpaService->getLpaById($identity, $validated['lpa_token']);
$actorRole = $lpaData['actor']['type'] === 'donor' ? 'Donor' : 'Attorney';

return new HtmlResponse($this->renderer->render('actor::lpa-show-viewercode', [
$templateName = 'actor::lpa-show-viewercode';
if (($this->featureEnabled)('support_datastore_lpas')) {
$templateName = 'actor::lpa-show-viewercode-combined-lpa';
}

return new HtmlResponse($this->renderer->render($templateName, [
'user' => $user,
'actorToken' => $validated['lpa_token'],
'code' => $codeData['code'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;
use Acpr\I18n\TranslatorInterface;
use Common\Service\Features\FeatureEnabled;

class CheckLpaHandlerFactory
{
Expand All @@ -29,7 +30,8 @@ public function __invoke(ContainerInterface $container)
$container->get(LpaService::class),
$rateLimitFactory->factory('actor_code_failure'),
$container->get(TranslatorInterface::class),
$container->get(AddLpa::class)
$container->get(AddLpa::class),
$container->get(FeatureEnabled::class),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
{% extends '@actor/layout.html.twig' %}

{% block html_title %}{% trans %}Confirm this is the correct LPA{% endtrans %} - {{ parent() }} {% endblock %}

{% block content %}
<div class="govuk-width-container">
<div role="navigation" aria-labelledby="back-link-navigation">
<a href="{{ path('lpa.add-by-key') }}" class="govuk-back-link" id="back-link-navigation">
{% trans %}Back{% endtrans %}</a>
</div>

<main class="govuk-main-wrapper" id="main-content" role="main">

<h1 class="govuk-heading-xl">{% trans %}Confirm this is the correct LPA{% endtrans %}</h1>

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">

<dl class="govuk-summary-list govuk-summary-list">
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">
{% trans %}Type of LPA{% endtrans %}
</dt>
<dd class="govuk-summary-list__value">
{% if lpa.caseSubtype.value|lower == "pfa" %}
{% trans %}Property and finance{% endtrans %}
{% else %}
{% trans %}Health and welfare{% endtrans %}
{% endif %}
</dd>
</div>
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">
{% trans %}Donor name{% endtrans %}
</dt>
<dd class="govuk-summary-list__value">
{{ actor_name(lpa.donor) }}
</dd>
</div>
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">
{% trans %}Your name{% endtrans %}
</dt>
<dd class="govuk-summary-list__value">
{% if userRole == "Trust corporation" %}
{{ actor.companyName }} {% trans %}(Trust corporation){% endtrans %}
{% else %}
{{ actor_name(actor) }}
{% endif %}
</dd>
</div>
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">
{% trans %}Your role on this LPA{% endtrans %}
</dt>
<dd class="govuk-summary-list__value">
{% if userRole == "Attorney" or userRole == "Trust corporation" %}
{% trans %}Attorney{% endtrans %}
{% elseif userRole == "Donor" %}
{% trans %}Donor{% endtrans %}
{% endif %}
</dd>
</div>
</dl>

<div class="govuk-warning-text">
<span class="govuk-warning-text__icon" aria-hidden="true">!</span>
<strong class="govuk-warning-text__text">
<span class="govuk-visually-hidden">{% trans %}Warning{% endtrans %}</span>
{% trans %}Check that these details are correct before continuing{% endtrans %}
</strong>
</div>

<details class="govuk-details" data-module="govuk-details" data-gaEventType="onClick"
data-gaAction="Details" data-gaCategory="Wrong Details"
data-gaLabel="What to do if the details are wrong">
<summary class="govuk-details__summary">
<span class="govuk-details__summary-text">
{% trans %}What to do if the details are wrong{% endtrans %}
</span>
</summary>
<div class="govuk-details__text">
<p>
{% trans %}If the information is wrong, or if a name is misspelt, please call us:{% endtrans %}
</p>
{{ include('@partials/contact-details/telephone.html.twig', {heading_level: 2 }) }}
</div>
</details>

{{ govuk_form_open(form) }}

{{ govuk_form_element(form.get('__csrf')) }}

<div class="moj-button-menu">
<div class="moj-button-menu__wrapper">

<button role="button" data-prevent-double-click="true" type="submit" draggable="false"
class="govuk-button moj-button-menu__item " data-module="govuk-button">
{% trans %}Confirm{% endtrans %}</button>
</button>

<a href="{{ path('lpa.dashboard') }}" role="button" draggable="false"
class="govuk-button moj-button-menu__item govuk-button--secondary "
data-module="govuk-button">
{% trans %}Cancel{% endtrans %}
</a>
</div>
</div>


{{ govuk_form_close() }}
</div>
</div>
</main>
</div>
{% endblock %}
Loading
Loading