Skip to content

Commit

Permalink
Fix error messages on pscType view
Browse files Browse the repository at this point in the history
- add CSRF token to pscType view
- add int test for error message content
  • Loading branch information
hepsimo committed Nov 4, 2024
1 parent e50890a commit 69ad541
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
10 changes: 4 additions & 6 deletions src/views/router_views/psc_type/psc_type.njk
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
{% block main_content %}

<form action="" method="post">
{% include "includes/csrf_token.njk" %}
<div class="govuk-form-group{{ ' govuk-form-group--error' if errors.pscType is not undefined }}">
{{ govukRadios({
{{ govukRadios({
idPrefix: "pscType",
name: "pscType",
value: pscType,
Expand All @@ -21,9 +22,7 @@
classes: "govuk-fieldset__legend--l"
}
},
errorMessage: {
text: "{{ errors.pscType.inline }}"
},
errorMessage: errors.pscType.inline if errors.pscType,
items: [
{
value: "individual",
Expand Down Expand Up @@ -67,5 +66,4 @@
}}
</form>

{% endblock %}

{% endblock %}
3 changes: 2 additions & 1 deletion test/routers/pscType.int.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,10 @@ describe("PscType router/handler integration tests", () => {
.query({ companyNumber: COMPANY_NUMBER, lang: "en", pscType: undefined })
.expect(HttpStatusCode.Ok);

// FIXME: check error content! (How?)
const $ = cheerio.load(posted.text);

expect($("div.govuk-form-group--error")).toBeDefined();
expect($("a[href='#err-id-pscType']").text()).toBe("Select if you're providing verification details for a PSC or RLE");
}
);
});
Expand Down

0 comments on commit 69ad541

Please sign in to comment.