Skip to content

Commit

Permalink
Merge pull request #1438 from companieshouse/ROECCT-97-tell-us-about-…
Browse files Browse the repository at this point in the history
…the-government-or-public-authority

Roecct 97 tell us about the government or public authority
  • Loading branch information
ndeekonda-ch committed Jul 3, 2024
2 parents 71ce6c6 + a0c7e7d commit aecc1b6
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 30 deletions.
2 changes: 2 additions & 0 deletions src/controllers/update/beneficial.owner.type.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ const getNextPage = (beneficialOwnerTypeChoices: BeneficialOwnerTypeChoice | Man
return config.UPDATE_MANAGING_OFFICER_URL;
case BeneficialOwnerTypeChoice.relevantPeriodOtherLegal:
return config.UPDATE_BENEFICIAL_OWNER_OTHER_URL + config.RELEVANT_PERIOD_QUERY_PARAM;
case BeneficialOwnerTypeChoice.relevantPeriodGovernment:
return config.UPDATE_BENEFICIAL_OWNER_GOV_URL + config.RELEVANT_PERIOD_QUERY_PARAM;
default:
return config.UPDATE_BENEFICIAL_OWNER_INDIVIDUAL_URL;
}
Expand Down
3 changes: 2 additions & 1 deletion src/model/beneficial.owner.type.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ export enum BeneficialOwnerTypeChoice {
individual = "individualOwner",
otherLegal = "otherLegalOwner",
government = "governmentOrPublicOwner",
relevantPeriodOtherLegal = "relevantPeriodOtherLegalOwner"
relevantPeriodOtherLegal = "relevantPeriodOtherLegalOwner",
relevantPeriodGovernment = "relevantPeriodGovernment"
}

export enum ManagingOfficerTypeChoice {
Expand Down
3 changes: 2 additions & 1 deletion src/utils/beneficial.owner.gov.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ export const getBeneficialOwnerGov = (req: Request, res: Response, templateName:
res.render(templateName, {
backLinkUrl,
templateName: templateName,
...appData
...appData,
relevant_period: req.query["relevant-period"] === "true",
});
};

Expand Down
1 change: 1 addition & 0 deletions test/__mocks__/text.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ export const RELEVANT_PERIOD_NO_TRUSTEE_INVOLVED = "anyone was a registrable ben
export const RELEVANT_PERIOD_CHANGE_BENEFICIARY = "at least one person became or ceased to be a beneficiary of a trust";
export const RELEVANT_PERIOD_NO_CHANGE_BENEFICIARY = "anyone became or ceased to be a beneficiary of a trust";
export const RELEVANT_PERIOD_INDIVIDUAL_BENEFICIAL_OWNER = "Individual beneficial owner";
export const RELEVANT_PERIOD_INFORMATION = "You need to enter information that is correct as at the date it ceased to be a registrable beneficial owner.";
export const SELECT_IF_REGISTER_DURING_PRE_REG_PERIOD = "Select yes if the overseas entity was the registered owner of UK land during the pre-registration period.";
export const RELEVANT_PERIOD_EXTRA_INFO_REQUIRED = "Based on the pre-registration statement you provided earlier in this service";
export const RELEVANT_PERIOD_OTHER_LEGAL_ENTITY_INFORMATION = "You need to enter information that is correct as at the date it ceased to be a registrable beneficial owner.";
Expand Down
18 changes: 17 additions & 1 deletion test/controllers/update/update.beneficial.owner.gov.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import {
UPDATE_BENEFICIAL_OWNER_GOV_PAGE,
UPDATE_BENEFICIAL_OWNER_GOV_URL,
UPDATE_BENEFICIAL_OWNER_TYPE_URL,
UPDATE_LANDING_PAGE_URL
UPDATE_LANDING_PAGE_URL,
RELEVANT_PERIOD_QUERY_PARAM,
} from "../../../src/config";
import {
getFromApplicationData,
Expand All @@ -42,6 +43,8 @@ import {
SERVICE_UNAVAILABLE,
SHOW_INFORMATION_ON_PUBLIC_REGISTER,
TRUSTS_NOC_HEADING,
RELEVANT_PERIOD,
RELEVANT_PERIOD_INFORMATION,
} from "../../__mocks__/text.mock";
import { logger } from "../../../src/utils/logger";
import {
Expand Down Expand Up @@ -126,6 +129,19 @@ describe("UPDATE BENEFICIAL OWNER GOV controller", () => {
expect(resp.status).toEqual(500);
expect(resp.text).toContain(SERVICE_UNAVAILABLE);
});

test(`renders the ${UPDATE_BENEFICIAL_OWNER_GOV_PAGE} page with relevant period content when query param is passed`, async () => {
mockGetApplicationData.mockReturnValueOnce({ ...APPLICATION_DATA_UPDATE_BO_MOCK });

const resp = await request(app).get(UPDATE_BENEFICIAL_OWNER_GOV_URL + RELEVANT_PERIOD_QUERY_PARAM);

expect(resp.status).toEqual(200);
expect(resp.text).toContain(RELEVANT_PERIOD);
expect(resp.text).toContain(RELEVANT_PERIOD_INFORMATION);
expect(resp.text).toContain("1");
expect(resp.text).toContain("January");
expect(resp.text).toContain("2023");
});
});

describe("GET BY ID tests", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ describe("BENEFICIAL OWNER TYPE controller", () => {
expect(resp.status).toEqual(200);
expect(resp.text).toContain(RELEVANT_PERIOD_INDIVIDUAL_BENEFICIAL_OWNER);
expect(resp.text).toContain(BENEFICIAL_OWNER_TYPE_PAGE_CORPORATE_BO);
expect(resp.text).toContain(BENEFICIAL_OWNER_TYPE_PAGE_GOVERNMENT_BO);
});

test(`renders the ${config.UPDATE_BENEFICIAL_OWNER_TYPE_URL} page with first statement de-selected`, async () => {
Expand All @@ -236,6 +237,7 @@ describe("BENEFICIAL OWNER TYPE controller", () => {
expect(resp.status).toEqual(200);
expect(resp.text).toContain(RELEVANT_PERIOD_INDIVIDUAL_BENEFICIAL_OWNER);
expect(resp.text).toContain(BENEFICIAL_OWNER_TYPE_PAGE_CORPORATE_BO );
expect(resp.text).toContain(BENEFICIAL_OWNER_TYPE_PAGE_GOVERNMENT_BO);
});
});

Expand Down Expand Up @@ -449,6 +451,18 @@ describe("BENEFICIAL OWNER TYPE controller", () => {
expect(resp.header.location).toEqual(config.UPDATE_BENEFICIAL_OWNER_OTHER_URL + RELEVANT_PERIOD_QUERY_PARAM);
});

test(`redirects to the ${config.UPDATE_BENEFICIAL_OWNER_TYPE_URL + RELEVANT_PERIOD_QUERY_PARAM } page when the relevant_period=true and government entity button selected`, async () => {
appData = APPLICATION_DATA_UPDATE_NO_BO_OR_MO_TO_REVIEW;
appData[UpdateKey] = UPDATE_OBJECT_MOCK_RELEVANT_PERIOD_CHANGE;

const resp = await request(app)
.post(config.UPDATE_BENEFICIAL_OWNER_TYPE_URL)
.send({ [BeneficialOwnerTypeKey]: BeneficialOwnerTypeChoice.relevantPeriodGovernment });

expect(resp.status).toEqual(302);
expect(resp.header.location).toEqual(config.UPDATE_BENEFICIAL_OWNER_GOV_URL + RELEVANT_PERIOD_QUERY_PARAM);
});

test("Catch error when posting submit", async () => {
mockGetApplicationData.mockImplementationOnce(() => { throw new Error(MESSAGE_ERROR); });

Expand Down
11 changes: 2 additions & 9 deletions views/includes/page-templates/beneficial-owner-gov.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,9 @@
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
{% include "includes/list/errors.html" %}

<span class="govuk-caption-xl">Beneficial owner</span>
<h1 class="govuk-heading-xl govuk-!-margin-0">{{ title }}</h1>
<p class="govuk-caption-l govuk-!-margin-bottom-5 govuk-!-margin-top-5">You can add more later.</p>

{% if entity_number %}
{% include "includes/ceased-date-details-summary-new-bo.html" %}
{% endif %}


<form class="form" method="post">
{% include "includes/page-templates/relevant-period-common-code.html" %}
{% include "includes/csrf_token.html" %}
{% include "includes/inputs/fields/name-input.html" %}

Expand Down
18 changes: 1 addition & 17 deletions views/includes/page-templates/beneficial-owner-other.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,9 @@

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

{% include "includes/list/errors.html" %}
{% if relevant_period %}
{% include "includes/page-templates/important-banner.html" %}
{% endif %}
{% include "includes/page-templates/relevant-period-common-code.html" %}

<span class="govuk-caption-xl">Beneficial owner</span>
<h1 class="govuk-heading-xl govuk-!-margin-0">{{ title }}</h1>
<br>
{% if relevant_period %}
{{ govukInsetText({
text: "You need to enter information that is correct as at the date it ceased to be a registrable beneficial owner."
}) }}
{% else %}
<br> <p class="govuk-body">You can add more later.</p> <br>
{% if entity_number %}
{% include "includes/ceased-date-details-summary-new-bo.html" %}
{% endif %}
{% endif %}
<form class="form" method="post">
{% include "includes/csrf_token.html" %}
{% include "includes/inputs/fields/name-input.html" %}
Expand Down
15 changes: 15 additions & 0 deletions views/includes/page-templates/relevant-period-common-code.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% if relevant_period %}
{% include "includes/page-templates/important-banner.html" %}
{% endif %}
<span class="govuk-caption-xl">Beneficial owner</span>
<h1 class="govuk-heading-xl govuk-!-margin-0">{{ title }}</h1>
{% if relevant_period %}
{{ govukInsetText({
text: 'You need to enter information that is correct as at the date it ceased to be a registrable beneficial owner.'
}) }}
{% else %}
<br> <p class="govuk-body">You can add more later.</p> <br>
{% if entity_number %}
{% include "includes/ceased-date-details-summary-new-bo.html" %}
{% endif %}
{% endif %}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h4 class="govuk-heading-m">For the pre-registration period</h4>
text: "Other legal entity beneficial owner"
},
{
value: "governmentOrPublicOwner",
value: "relevantPeriodGovernment",
text: "Government or public authority beneficial owner"
}
]
Expand Down

0 comments on commit aecc1b6

Please sign in to comment.