-
Notifications
You must be signed in to change notification settings - Fork 3
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
Uar 1285 need changes entity before removed #1233
base: main
Are you sure you want to change the base?
Changes from all commits
74cdc53
36bf120
45f7560
813d820
0c20b12
6bf3561
797186f
629b969
6714f4c
7a5fad5
7d3ce88
be4f283
4720cb3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { NextFunction, Request, Response } from "express"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given my comments below and the fact that this is basically just an update screen, I wonder if the new controller for remove (and HTML template page) is required. |
||
import * as config from "../../config"; | ||
import { logger } from "../../utils/logger"; | ||
|
||
export const get = (req: Request, res: Response, next: NextFunction) => { | ||
try { | ||
logger.debugRequest(req, `GET ${config.REMOVE_NEED_MAKE_CHANGES_PAGE}`); | ||
return res.render(config.REMOVE_NEED_MAKE_CHANGES_PAGE, { | ||
journey: config.JourneyType.remove, | ||
backLinkUrl: `${config.OVERSEAS_ENTITY_PRESENTER_URL}${config.JOURNEY_REMOVE_QUERY_PARAM}`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In theory, back link here doesn't need to set the JOURNEY_REMOVE_QUERY_PARAM because by this point the 'is_remove=true' flag is set in the session and Mongo JSON, so that screen can pick it up from there (changes will be required for this though...). A discussion required, perhaps. |
||
templateName: config.REMOVE_NEED_MAKE_CHANGES_PAGE | ||
}); | ||
} catch (error) { | ||
next(error); | ||
} | ||
}; | ||
|
||
export const post = (req: Request, res: Response, next: NextFunction) => { | ||
try { | ||
logger.debugRequest(req, `POST ${config.REMOVE_NEED_MAKE_CHANGES_PAGE}`); | ||
|
||
if (req.body["make_changes"] === 'yes') { | ||
return res.redirect(`${config.WHO_IS_MAKING_UPDATE_URL}${config.JOURNEY_REMOVE_QUERY_PARAM}`); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need to pass the JOURNEY_REMOVE_QUERY_PARAM in now for future pages as it is the update journey and we are avoiding changing all those controllers (for now). |
||
} | ||
// TODO redirect to new component - Has the overseas entity identified any registrable beneficial owners? | ||
return res.redirect(`${config.UPDATE_LANDING_URL}${config.JOURNEY_REMOVE_QUERY_PARAM}`); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From Mural board, looks like the 'No' option takes you to an existing update screen, so in theory this could be done now (no need for TODO). |
||
} catch (error) { | ||
next(error); | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -199,6 +199,7 @@ export enum ErrorMessages { | |
SELECT_DO_YOU_WANT_TO_MAKE_CHANGES_UPDATE_STATEMENT = "Select yes if all the information in this update statement is correct", | ||
SELECT_UPDATE_STATEMENT_VALIDATION_RESOLUTION = "Select if you want to change your statements or change the information provided in this update", | ||
SELECT_IF_REMOVE_SOLD_ALL_LAND_FILTER = "Select yes if the entity has disposed of all its property or land in the UK", | ||
SELECT_REMOVE_NEED_TO_MAKE_CHANGES = "Select yes if you need to make changes to this overseas entity before it is removed", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the validation error message is the only thing changing here for the remove journey, I think we can probably use the |
||
|
||
// MAX Lengths | ||
MAX_FIRST_NAME_LENGTH = "First name must be 50 characters or less", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { body } from "express-validator"; | ||
|
||
import { ErrorMessages } from "../error.messages"; | ||
|
||
export const removeNeedMakeChanges = [ | ||
body("make_changes").not().isEmpty().withMessage(ErrorMessages.SELECT_REMOVE_NEED_TO_MAKE_CHANGES) | ||
]; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -250,6 +250,7 @@ export const UPDATE_MANAGE_TRUSTS_REVIEWED_HEADING = "What you have reviewed"; | |
export const REMOVE_SOLD_ALL_LAND_FILTER_PAGE_TITLE = "Has the overseas entity disposed of all its property or land in the UK?"; | ||
export const REMOVE_IS_ENTITY_REGISTERED_OWNER_TITLE = "Is the overseas entity currently listed on any land registry records as the registered owner of property or land in the UK?"; | ||
export const REMOVE_INTERRUPT_CARD_TEXT = "Once an overseas entity is removed"; | ||
export const REMOVE_NEED_MAKE_CHANGES_TITLE = "Do you need to make any changes to this overseas entity before it is removed?"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, we should be able to vary the title displayed in the existing HTML template without the need for a new controller and template for Remove. |
||
|
||
// Manage Trusts | ||
export const UPDATE_MANAGE_TRUSTS_REVIEW_FORMER_BO_TITLE = "Review former beneficial owners"; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
jest.mock("ioredis"); | ||
jest.mock("../../../src/utils/logger"); | ||
jest.mock('../../../src/middleware/authentication.middleware'); | ||
jest.mock('../../../src/middleware/company.authentication.middleware'); | ||
jest.mock('../../../src/middleware/service.availability.middleware'); | ||
jest.mock('../../../src/middleware/navigation/update/has.presenter.middleware'); | ||
jest.mock('../../../src/utils/application.data'); | ||
|
||
import { NextFunction, Request, Response } from "express"; | ||
import * as config from "../../../src/config"; | ||
import request from "supertest"; | ||
import { logger } from "../../../src/utils/logger"; | ||
import app from "../../../src/app"; | ||
import { ErrorMessages } from '../../../src/validation/error.messages'; | ||
import { hasUpdatePresenter } from "../../../src/middleware/navigation/update/has.presenter.middleware"; | ||
import { serviceAvailabilityMiddleware } from "../../../src/middleware/service.availability.middleware"; | ||
import { authentication } from "../../../src/middleware/authentication.middleware"; | ||
import { companyAuthentication } from "../../../src/middleware/company.authentication.middleware"; | ||
import { | ||
ANY_MESSAGE_ERROR, | ||
PAGE_TITLE_ERROR, | ||
FOUND_REDIRECT_TO, | ||
REMOVE_NEED_MAKE_CHANGES_TITLE, | ||
SERVICE_UNAVAILABLE, | ||
} from "../../__mocks__/text.mock"; | ||
import { REMOVE_SERVICE_NAME } from "../../../src/config"; | ||
import { getApplicationData } from "../../../src/utils/application.data"; | ||
import { APPLICATION_DATA_CH_REF_UPDATE_MOCK } from "../../__mocks__/session.mock"; | ||
|
||
const mockGetApplicationData = getApplicationData as jest.Mock; | ||
|
||
const mockHasUpdatePresenter = hasUpdatePresenter as jest.Mock; | ||
mockHasUpdatePresenter.mockImplementation((req: Request, res: Response, next: NextFunction) => next() ); | ||
|
||
const mockCompanyAuthenticationMiddleware = companyAuthentication as jest.Mock; | ||
mockCompanyAuthenticationMiddleware.mockImplementation((req: Request, res: Response, next: NextFunction) => next() ); | ||
|
||
const mockAuthenticationMiddleware = authentication as jest.Mock; | ||
mockAuthenticationMiddleware.mockImplementation((req: Request, res: Response, next: NextFunction) => next()); | ||
|
||
const mockServiceAvailabilityMiddleware = serviceAvailabilityMiddleware as jest.Mock; | ||
mockServiceAvailabilityMiddleware.mockImplementation((req: Request, res: Response, next: NextFunction) => next()); | ||
|
||
const mockLoggerDebugRequest = logger.debugRequest as jest.Mock; | ||
|
||
describe("Remove need to make changes to entity controller", () => { | ||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
describe("GET tests", () => { | ||
test(`renders the ${config.REMOVE_NEED_MAKE_CHANGES_URL} page`, async () => { | ||
mockGetApplicationData.mockReturnValueOnce({ | ||
...APPLICATION_DATA_CH_REF_UPDATE_MOCK | ||
}); | ||
const resp = await request(app).get(`${config.REMOVE_NEED_MAKE_CHANGES_URL}${config.JOURNEY_REMOVE_QUERY_PARAM}`); | ||
expect(resp.status).toEqual(200); | ||
expect(resp.text).toContain(REMOVE_NEED_MAKE_CHANGES_TITLE); | ||
expect(resp.text).toContain(REMOVE_SERVICE_NAME); | ||
expect(resp.text).not.toContain(PAGE_TITLE_ERROR); | ||
expect(mockLoggerDebugRequest).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
test("catch error on current page for GET method", async () => { | ||
mockLoggerDebugRequest.mockImplementationOnce(() => { throw new Error(ANY_MESSAGE_ERROR); }); | ||
const resp = await request(app).get(`${config.REMOVE_NEED_MAKE_CHANGES_URL}${config.JOURNEY_REMOVE_QUERY_PARAM}`); | ||
expect(resp.status).toEqual(500); | ||
expect(resp.text).toContain(SERVICE_UNAVAILABLE); | ||
}); | ||
}); | ||
|
||
describe("POST tests", () => { | ||
test(`redirects to the ${config.REMOVE_NEED_MAKE_CHANGES_URL} page when yes is selected`, async () => { | ||
const resp = await request(app) | ||
.post(`${config.REMOVE_NEED_MAKE_CHANGES_URL}${config.JOURNEY_REMOVE_QUERY_PARAM}`) | ||
.send({ make_changes: 'yes' }); | ||
expect(resp.status).toEqual(302); | ||
expect(resp.text).toEqual(`${FOUND_REDIRECT_TO} ${config.WHO_IS_MAKING_UPDATE_URL}${config.JOURNEY_REMOVE_QUERY_PARAM}`); | ||
expect(resp.header.location).toEqual(`${config.WHO_IS_MAKING_UPDATE_URL}${config.JOURNEY_REMOVE_QUERY_PARAM}`); | ||
expect(mockLoggerDebugRequest).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
test(`redirects to the ${config.REMOVE_NEED_MAKE_CHANGES_URL} page when no is selected`, async () => { | ||
const resp = await request(app) | ||
.post(`${config.REMOVE_NEED_MAKE_CHANGES_URL}${config.JOURNEY_REMOVE_QUERY_PARAM}`) | ||
.send({ make_changes: 'no' }); | ||
expect(resp.status).toEqual(302); | ||
// TODO redirect to new component - Has the overseas entity identified any registrable beneficial owners? | ||
expect(resp.text).toEqual(`${FOUND_REDIRECT_TO} ${config.UPDATE_LANDING_URL}${config.JOURNEY_REMOVE_QUERY_PARAM}`); | ||
expect(resp.header.location).toEqual(`${config.UPDATE_LANDING_URL}${config.JOURNEY_REMOVE_QUERY_PARAM}`); | ||
expect(mockLoggerDebugRequest).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
test("renders the current page with error message and correct page title", async () => { | ||
const resp = await request(app) | ||
.post(`${config.REMOVE_NEED_MAKE_CHANGES_URL}${config.JOURNEY_REMOVE_QUERY_PARAM}`); | ||
|
||
expect(resp.status).toEqual(200); | ||
expect(resp.text).toContain(REMOVE_NEED_MAKE_CHANGES_TITLE); | ||
expect(resp.text).toContain(PAGE_TITLE_ERROR); | ||
expect(resp.text).toContain(ErrorMessages.SELECT_REMOVE_NEED_TO_MAKE_CHANGES); | ||
expect(resp.text).toContain(REMOVE_SERVICE_NAME); | ||
}); | ||
|
||
test("catch error on current page for POST method", async () => { | ||
mockLoggerDebugRequest.mockImplementationOnce(() => { throw new Error(ANY_MESSAGE_ERROR); }); | ||
const resp = await request(app) | ||
.post(`${config.REMOVE_SOLD_ALL_LAND_FILTER_URL}${config.JOURNEY_REMOVE_QUERY_PARAM}`) | ||
.send({ disposed_all_land: 'yes' }); | ||
|
||
expect(resp.status).toEqual(500); | ||
expect(resp.text).toContain(SERVICE_UNAVAILABLE); | ||
}); | ||
|
||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
{% extends "update-layout.html" %} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Potentially, no new template required here - see earlier comments and take a look at |
||
|
||
{% set title = "Do you need to make any changes to this overseas entity before it is removed?" %} | ||
|
||
{% block pageTitle %} | ||
{% include "includes/update-page-title.html" %} | ||
{% endblock %} | ||
|
||
{% block backLink %} | ||
{% include "includes/back-link.html" %} | ||
{% endblock %} | ||
|
||
{% block content %} | ||
|
||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds"> | ||
|
||
{% include "includes/list/errors.html" %} | ||
|
||
<form method="post"> | ||
<input type="hidden" name="journey" value="{{ journey }}"/> | ||
<span class="govuk-caption-l">{{ data['overseas-name'] }} - OE001485</span> | ||
<h1 class="govuk-heading-xl">Do you need to make any changes to this overseas entity before it is removed?</h1> | ||
<p class="govuk-hint govuk-!-margin-bottom-5 govuk-!-margin-top-5"> | ||
All information about the overseas entity must be up to date before the entity can be removed. It should be correct as at the date of this application. This includes information about any beneficial owners and managing officers. | ||
</p> | ||
{{ govukRadios({ | ||
errorMessage: errors.make_changes if errors, | ||
idPrefix: "make_changes", | ||
name: "make_changes", | ||
fieldset: { | ||
legend: { | ||
text: "Have you made any changes to the overseas entity?", | ||
isPageHeading: false, | ||
classes: "govuk-visually-hidden" | ||
} | ||
}, | ||
items: [ | ||
{ | ||
value: "yes", | ||
text: "Yes, I need to make changes", | ||
attributes: { | ||
"data-event-id": "make_changes" | ||
} | ||
}, | ||
{ | ||
value: "no", | ||
text: "No, I do not need to make changes", | ||
attributes: { | ||
"data-event-id": "make_changes" | ||
} | ||
} | ||
] | ||
}) | ||
}} | ||
{{ govukButton({ | ||
text: "Save and continue" | ||
}) | ||
}} | ||
<details class="govuk-details" data-module="govuk-details"> | ||
<summary class="govuk-details__summary"> | ||
<span class="govuk-details__summary-text"> | ||
What verification checks are needed? | ||
</span> | ||
</summary> | ||
<div class="govuk-details__text"> | ||
Verification checks are needed on any changes made to information about the overseas entity, its beneficial owners or managing officers. | ||
</div> | ||
<div class="govuk-details__text"> | ||
Verification checks can only be carried out by a UK-regulated agent, and must have been completed no more than 3 months before the date of this update statement. </div> | ||
</div> | ||
</details> | ||
</form> | ||
</div> | ||
</div> | ||
{% endblock %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not a great choice of words for a constant name but totally understand that you've tried to match the defined HTML page name. How about if you drop the
_MAKE_
so we're left with justREMOVE_NEED_CHANGES_PAGE
?(
REMOVE_CHANGES_REQUIRED_PAGE
would be my first choice, but then we diverge from the HTML page name)