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

DDLS-387 Pull the NDR report through to the reports page #1734

Merged
merged 45 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
c8248d2
NDR redirects to Lay Homepage
Nov 13, 2024
0423b90
Combine NDR into Report Controller and Report index template
Nov 13, 2024
988c574
Set ndr fixture to be primary
Nov 13, 2024
af0b462
Direct to lay homepage once ndr is submitted
Nov 13, 2024
6f2ee81
Merge branch 'main' into DDLS-387
iqpalm Nov 13, 2024
4f46455
Include ndr template in report index template
Nov 14, 2024
6b269f9
Return client for ndr
Nov 14, 2024
9d71e0d
Return ndr using ndrId and then client
Nov 15, 2024
d589e08
Submit NDR for client attached to non-primary user account
Nov 15, 2024
cac1e98
Deprecate existing ndr endpoint and amend references to use reports page
Nov 19, 2024
655bb4e
Test using NDR checkbox results in correct type of report on report page
Nov 21, 2024
53e6174
Missing parameters for breadcrumb on ndr review
Nov 21, 2024
92ba8b7
Merge NDR checkbox into 1 step
Nov 21, 2024
1865fa7
Solve failing test
Nov 21, 2024
c2c5b24
Solve failing test
Nov 21, 2024
e1caa04
NDR enabled results in NDR on report page
Nov 21, 2024
53d4b33
Delete name tag
Nov 21, 2024
f826419
Fix failing test
Nov 21, 2024
c84a27f
Fix failing test
Nov 21, 2024
105f0c1
Add test for unticking NDR checkbox
Nov 22, 2024
f0586f9
Merge branch 'main' into DDLS-387
iqpalm Nov 22, 2024
dcdb9d3
Delete tag
Nov 22, 2024
7466b81
Amend step to pick up correct fixture
Nov 22, 2024
da4c601
Client benefits check section for NDR requires client id for lay_home
Nov 22, 2024
fbd6772
Client not being pulled through therefore same text as report has bee…
Nov 25, 2024
663f713
Multi-client breadcrumb for overview NDR page
Nov 25, 2024
3dfebe3
Multi-client breadcrumb for visits and care NDR page
Nov 25, 2024
cba9488
Multi-client breadcrumb for deputy expense NDR page
Nov 25, 2024
07488fa
Multi-client breadcrumb for income and benefits NDR page
Nov 25, 2024
0ff61fc
Multi-client breadcrumb for accounts NDR page
Nov 25, 2024
32823c9
Multi-client breadcrumb for assets NDR page
Nov 25, 2024
d564be9
Multi-client breadcrumb for debts NDR page
Nov 25, 2024
ca36296
Multi-client breadcrumb for actions NDR page
Nov 25, 2024
7d7284c
Multi-client breadcrumb for other info NDR page
Nov 25, 2024
20815d6
Multi-client breadcrumb for review NDR page
Nov 25, 2024
30566a9
Multi-client breadcrumb for declaration NDR page
Nov 25, 2024
f7ecee1
Merge branch 'main' into DDLS-387
iqpalm Nov 25, 2024
92a66a4
Return to lay_home when looking at NDR submitted reports
Nov 26, 2024
c103162
Add missing type to ndrId
Dec 2, 2024
bb8b4df
Add false for type consistency
Dec 2, 2024
54fcb88
Merge branch 'main' into DDLS-387
iqpalm Dec 2, 2024
5407971
Move check for Lay Deputy to inside the function
Dec 3, 2024
6e6b403
Merge branch 'DDLS-387' of https://github.com/ministryofjustice/opg-d…
Dec 3, 2024
e4a2a30
Merge branch 'main' into DDLS-387
iqpalm Dec 4, 2024
3f1a553
Merge branch 'main' into DDLS-387
iqpalm Dec 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions api/app/tests/Behat/bootstrap/v2/Common/AuthTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -552,4 +552,20 @@ private function getActiveClientIds(): void
}
}
}

/**
* @Then I should see the NDR report on the reports page
*/
public function theyShouldBeOnNDRReportPage(): void
{
$this->assertPageContainsText('New deputy report');
}

/**
* @Then I should not see the NDR report on the reports page
*/
public function theyShouldNotBeOnNDRReportPage(): void
{
$this->assertPageNotContainsText('New deputy report');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,6 @@ public function iAmOnLayMainPage(): bool
return $this->iAmOnPage('/client\/.*/');
}

/**
* @Then I should be on the Ndr Lay homepage
*/
public function iAmOnNdrLayMainPage(): bool
{
return $this->iAmOnPage('/ndr$/');
}

/**
* @Then I should be on the Lay reports overview page
*/
Expand Down
28 changes: 28 additions & 0 deletions api/app/tests/Behat/bootstrap/v2/Common/UserExistsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,32 @@ public function aProfessionalTeamDeputyExists()

$this->interactingWithUserDetails = $this->profTeamDeputyNotStartedHealthWelfareDetails;
}

/**
* @Given a Multi-client Lay Deputy exists and I select the non-primary user
*
* @throws BehatException
*/
public function aMultiClientLayDeputyExists()
{
if (empty($this->layPfaHighNotStartedMultiClientDeputyNonPrimaryUser)) {
throw new BehatException('It looks like fixtures are not loaded - missing $layPfaHighNotStartedMultiClientDeputyNonPrimaryUser');
}

$this->interactingWithUserDetails = $this->layPfaHighNotStartedMultiClientDeputyNonPrimaryUser;
}

/**
* @Given a Multi-client Lay Deputy exists and I select the primary user with NDR
*
* @throws BehatException
*/
public function aMultiClientLayDeputyExistsWithNDR()
{
if (empty($this->layPfaHighNotStartedMultiClientDeputyPrimaryUser)) {
throw new BehatException('It looks like fixtures are not loaded - missing $layPfaHighNotStartedMultiClientDeputyPrimaryUser');
}

$this->interactingWithUserDetails = $this->layPfaHighNotStartedMultiClientDeputyPrimaryUser;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,30 @@ public function iShouldNotBeAbleToAccessClientDetailsLink()
{
$this->assertElementNotOnPage('govuk-link behat-link-client-show');
}

/**
* @Then /^I enable the NDR for this user$/
*/
public function iShouldBeAbleToToggleNdrEnabled()
{
$this->iVisitAdminEditUserPageForInteractingWithUser();

$this->checkOption('admin_ndrEnabled');

$this->pressButton('Update user');
$this->em->clear();
}

/**
* @Then /^I disable the NDR for this user$/
*/
public function iShouldBeDisableNdrEnabled()
{
$this->iVisitAdminEditUserPageForInteractingWithUser();

$this->uncheckOption('admin_ndrEnabled');

$this->pressButton('Update user');
$this->em->clear();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ public function createLayNdrNotStarted(string $testRunId, ?string $caseNumber =
null,
$caseNumber,
true,
false,
true,
$deputyUid
);

Expand Down
20 changes: 20 additions & 0 deletions api/app/tests/Behat/features-v2/acl/login/login.feature
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,23 @@ Feature: Users logging into the service
And they discharge the deputy from "2" secondary client(s)
Then a Lay Deputy tries to login with their "primary" email address
Then they should be on the add your client page

@super-admin @lay-pfa-high-not-started-multi-client-deputy
Scenario: A user logs into the service with their primary account and ticks the NDR checkbox attached to non-primary account
Given a super admin user accesses the admin app
When a Multi-client Lay Deputy exists and I select the non-primary user
And I enable the NDR for this user
Then a Lay Deputy tries to login with their "primary" email address
When they choose their "non-primary" Client
Then they should be on the "non-primary" Client's dashboard
And I should see the NDR report on the reports page

@super-admin @lay-pfa-high-not-started-multi-client-deputy-with-ndr
Scenario: A user logs into the service with their primary account and unticks the NDR checkbox attached to primary account
Given a super admin user accesses the admin app
When a Multi-client Lay Deputy exists and I select the primary user with NDR
And I disable the NDR for this user
Then a Lay Deputy tries to login with their "primary" email address
When they choose their "primary" Client
Then they should be on the "primary" Client's dashboard
And I should not see the NDR report on the reports page
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Feature: Activate user account - Lay users (NDR)
Then the partially registered users 'active flag' should 'not be' set
And the partially registered users 'registration date' should 'not be' set
When the user completes the final registration step
Then I should be on the Ndr Lay homepage
Then I should be on the Lay homepage
And an admin user accesses the admin app
Then the partially registered users 'active flag' should 'be' set
And the partially registered users 'registration date' should 'be' set
2 changes: 1 addition & 1 deletion client/app/src/Controller/ClientController.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public function addAction(Request $request, Redirector $redirector, TranslatorIn
$this->clientApi->updateDeputy($response['id'], $deputyResponse['id']);

$url = $currentUser->isNdrEnabled()
? $this->generateUrl('ndr_index')
? $this->generateUrl('lay_home', ['clientId' => $response['id']])
: $this->generateUrl('report_create', ['clientId' => $response['id']]);

if ($currentUser->isNdrEnabled()) {
Expand Down
8 changes: 2 additions & 6 deletions client/app/src/Controller/CoDeputyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,7 @@ public function addAction(Request $request, Redirector $redirector)
$invitedUser = new User();
$form = $this->createForm(FormDir\CoDeputyInviteType::class, $invitedUser);

$backLink = $loggedInUser->isNdrEnabled() ?
$this->generateUrl('ndr_index')
: $this->generateUrl('lay_home', ['clientId' => $loggedInUser->getFirstClient()->getId()]);
$backLink = $this->generateUrl('lay_home', ['clientId' => $loggedInUser->getFirstClient()->getId()]);

$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
Expand Down Expand Up @@ -229,9 +227,7 @@ public function resendActivationAction(Request $request, string $email)

$form = $this->createForm(FormDir\CoDeputyInviteType::class, $existingCoDeputy);

$backLink = $loggedInUser->isNdrEnabled() ?
$this->generateUrl('ndr_index')
: $this->generateUrl('lay_home', ['clientId' => $loggedInUser->getFirstClient()->getId()]);
$backLink = $this->generateUrl('lay_home', ['clientId' => $loggedInUser->getFirstClient()->getId()]);

$form->handleRequest($request);

Expand Down
21 changes: 17 additions & 4 deletions client/app/src/Controller/Ndr/ActionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Controller\AbstractController;
use App\Form as FormDir;
use App\Service\Client\Internal\ClientApi;
use App\Service\Client\Internal\ReportApi;
use App\Service\Client\RestClient;
use App\Service\NdrStatusService;
Expand Down Expand Up @@ -36,39 +37,50 @@ class ActionController extends AbstractController
'ndr-action-more-info',
];

/**
* @var ClientApi
*/
private $clientApi;

public function __construct(
ReportApi $reportApi,
RestClient $restClient,
StepRedirector $stepRedirector
StepRedirector $stepRedirector,
ClientApi $clientApi
iqpalm marked this conversation as resolved.
Show resolved Hide resolved
) {
$this->reportApi = $reportApi;
$this->restClient = $restClient;
$this->stepRedirector = $stepRedirector;
$this->clientApi = $clientApi;
}

/**
* @Route("/ndr/{ndrId}/actions", name="ndr_actions")
* @Template("@App/Ndr/Action/start.html.twig")
*
* @param Request $request
* @param $ndrId
* @Template("@App/Ndr/Action/start.html.twig")
*
* @return array|RedirectResponse
*/
public function startAction($ndrId)
{
/** @var User $user */
$user = $this->getUser();
$isMultiClientDeputy = 'ROLE_LAY_DEPUTY' == $user->getRoleName() ? $this->clientApi->checkDeputyHasMultiClients($user->getDeputyUid()) : null;

$ndr = $this->reportApi->getNdrIfNotSubmitted($ndrId, self::$jmsGroups);
if (NdrStatusService::STATE_NOT_STARTED != $ndr->getStatusService()->getActionsState()['state']) {
return $this->redirectToRoute('ndr_actions_summary', ['ndrId' => $ndrId]);
}

return [
'ndr' => $ndr,
'isMultiClientDeputy' => $isMultiClientDeputy,
];
}

/**
* @Route("/ndr/{ndrId}/actions/step/{step}", name="ndr_actions_step")
*
* @Template("@App/Ndr/Action/step.html.twig")
*/
public function stepAction(Request $request, $ndrId, $step)
Expand Down Expand Up @@ -115,6 +127,7 @@ public function stepAction(Request $request, $ndrId, $step)

/**
* @Route("/ndr/{ndrId}/actions/summary", name="ndr_actions_summary")
*
* @Template("@App/Ndr/Action/summary.html.twig")
*/
public function summaryAction(Request $request, $ndrId)
Expand Down
30 changes: 24 additions & 6 deletions client/app/src/Controller/Ndr/AssetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Controller\AbstractController;
use App\Entity as EntityDir;
use App\Form as FormDir;
use App\Service\Client\Internal\ClientApi;
use App\Service\Client\Internal\ReportApi;
use App\Service\Client\RestClient;
use App\Service\NdrStatusService;
Expand Down Expand Up @@ -33,38 +34,50 @@ class AssetController extends AbstractController
*/
private $stepRedirector;

/**
* @var ClientApi
*/
private $clientApi;

public function __construct(
ReportApi $reportApi,
RestClient $restClient,
StepRedirector $stepRedirector
StepRedirector $stepRedirector,
ClientApi $clientApi
) {
$this->reportApi = $reportApi;
$this->restClient = $restClient;
$this->stepRedirector = $stepRedirector;
$this->clientApi = $clientApi;
}

/**
* @Route("/ndr/{ndrId}/assets", name="ndr_assets")
* @Template("@App/Ndr/Asset/start.html.twig")
*
* @param $ndrId
* @Template("@App/Ndr/Asset/start.html.twig")
*
* @return array|RedirectResponse
*/
public function startAction($ndrId)
{
/** @var User $user */
$user = $this->getUser();
$isMultiClientDeputy = 'ROLE_LAY_DEPUTY' == $user->getRoleName() ? $this->clientApi->checkDeputyHasMultiClients($user->getDeputyUid()) : null;

$ndr = $this->reportApi->getNdrIfNotSubmitted($ndrId, self::$jmsGroups);
if (NdrStatusService::STATE_NOT_STARTED != $ndr->getStatusService()->getAssetsState()['state']) {
return $this->redirectToRoute('ndr_assets_summary', ['ndrId' => $ndrId]);
}

return [
'ndr' => $ndr,
'isMultiClientDeputy' => $isMultiClientDeputy,
];
}

/**
* @Route("/ndr/{ndrId}/assets/exist", name="ndr_assets_exist")
*
* @Template("@App/Ndr/Asset/exist.html.twig")
*/
public function existAction(Request $request, $ndrId)
Expand All @@ -85,7 +98,7 @@ public function existAction(Request $request, $ndrId)
switch ($ndr->getNoAssetToAdd()) {
case 0: // yes
return $this->redirectToRoute('ndr_assets_type', ['ndrId' => $ndrId]);
case 1: //no
case 1: // no
$this->restClient->put('ndr/'.$ndrId, $ndr, ['noAssetsToAdd']);

return $this->redirectToRoute('ndr_assets_summary', ['ndrId' => $ndrId]);
Expand All @@ -106,6 +119,7 @@ public function existAction(Request $request, $ndrId)

/**
* @Route("/ndr/{ndrId}/assets/step-type", name="ndr_assets_type")
*
* @Template("@App/Ndr/Asset/type.html.twig")
*/
public function typeAction(Request $request, $ndrId)
Expand Down Expand Up @@ -135,6 +149,7 @@ public function typeAction(Request $request, $ndrId)

/**
* @Route("/ndr/{ndrId}/assets/other/{title}/add", name="ndr_asset_other_add")
*
* @Template("@App/Ndr/Asset/Other/add.html.twig")
*/
public function otherAddAction(Request $request, $ndrId, $title)
Expand Down Expand Up @@ -166,6 +181,7 @@ public function otherAddAction(Request $request, $ndrId, $title)

/**
* @Route("/ndr/{ndrId}/assets/other/edit/{assetId}", name="ndr_asset_other_edit")
*
* @Template("@App/Ndr/Asset/Other/edit.html.twig")
*/
public function otherEditAction(Request $request, $ndrId, $assetId = null)
Expand Down Expand Up @@ -199,6 +215,7 @@ public function otherEditAction(Request $request, $ndrId, $assetId = null)

/**
* @Route("/ndr/{ndrId}/assets/add_another", name="ndr_assets_add_another")
*
* @Template("@App/Ndr/Asset/addAnother.html.twig")
*/
public function addAnotherAction(Request $request, $ndrId)
Expand All @@ -225,6 +242,7 @@ public function addAnotherAction(Request $request, $ndrId)

/**
* @Route("/ndr/{ndrId}/assets/property/step{step}/{assetId}", name="ndr_assets_property_step", requirements={"step":"\d+"})
*
* @Template("@App/Ndr/Asset/Property/step.html.twig")
*/
public function propertyStepAction(Request $request, $ndrId, $step, $assetId = null)
Expand Down Expand Up @@ -346,9 +364,8 @@ public function propertyStepAction(Request $request, $ndrId, $step, $assetId = n

/**
* @Route("/ndr/{ndrId}/assets/summary", name="ndr_assets_summary")
* @Template("@App/Ndr/Asset/summary.html.twig")
*
* @param $ndrId
* @Template("@App/Ndr/Asset/summary.html.twig")
*
* @return array|RedirectResponse
*/
Expand All @@ -366,6 +383,7 @@ public function summaryAction($ndrId)

/**
* @Route("/ndr/{ndrId}/assets/{assetId}/delete", name="ndr_asset_delete")
*
* @Template("@App/Common/confirmDelete.html.twig")
*
* @return array|RedirectResponse
Expand Down
Loading
Loading