Skip to content

Commit 0cc3e8a

Browse files
FLS-1410: Use standard error summary text as per GOV.UK guidelines. (#205)
* Use standard error summary text as per GOV.UK guidelines. * Fix unit tests with the error summary title change * Fix e2e test with the error summary title change
1 parent ecec1e0 commit 0cc3e8a

File tree

5 files changed

+35
-14
lines changed

5 files changed

+35
-14
lines changed

e2e-test/cypress/e2e/runner/completeAForm.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,5 @@ Feature: Complete a form
9393
Scenario: Error messages are displayed and can be resolved
9494
Given I navigate to the "report-a-terrorist" form
9595
When I continue
96-
Then I see the error "Do you have a link to the material? is required" for "Do you have a link to the material?"
96+
Then I see the error "Do you have a link to the material? is required" for component "Do you have a link to the material?"
9797

e2e-test/cypress/e2e/runner/dateValidation.feature

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ Feature: Date validation
77
When I navigate to the "date" form
88
When I enter the day "25" for "maxFiveDaysInFuture"
99
And I continue
10-
Then I see the error "Enter a date at most 5 days in the future must include a month" for "Enter a date at most 5 days in the future"
10+
Then I see the error "Enter a date at most 5 days in the future must include a month" for component "Enter a date at most 5 days in the future"
1111
When I enter the month "12" for "maxFiveDaysInFuture"
1212
And I continue
13-
Then I see the error "Enter a date at most 5 days in the future must include a year" for "Enter a date at most 5 days in the future"
13+
Then I see the error "Enter a date at most 5 days in the future must include a year" for component "Enter a date at most 5 days in the future"
1414
When I enter the year "2000" for "maxFiveDaysInFuture"
1515
And I continue
1616
Then I don't see "Enter a date at most 5 days in the future must include a year"
@@ -21,15 +21,15 @@ Feature: Date validation
2121
When I enter the month "30" for "maxFiveDaysInFuture"
2222
When I enter the year "1" for "maxFiveDaysInFuture"
2323
And I continue
24-
Then I see the date parts error "Day must be between 1 and 31"
25-
Then I see the date parts error "Month must be between 1 and 12"
26-
Then I see the date parts error "Year must be 1000 or higher"
24+
Then I see the date parts with error "Day must be between 1 and 31"
25+
Then I see the date parts with error "Month must be between 1 and 12"
26+
Then I see the date parts with error "Year must be 1000 or higher"
2727

2828

2929
Scenario: Errors appear for max days in future and max days in past
3030
When I navigate to the "date" form
3131
When I enter a date 30 days in the future for "maxFiveDaysInFuture"
3232
When I enter a date 30 days in the past for "maxFiveDaysInPast"
3333
And I continue
34-
Then I see the date parts with a partial error string "Enter a date at most 5 days in the future must be the same as or before" for "maxFiveDaysInFuture"
35-
Then I see the date parts with a partial error string "Enter a date at most 5 days in the past must be the same as or after" for "maxFiveDaysInPast"
34+
Then I see the date parts with a error string "Enter a date at most 5 days in the future must be the same as or before" for "maxFiveDaysInFuture"
35+
Then I see the date parts with a error string "Enter a date at most 5 days in the past must be the same as or after" for "maxFiveDaysInPast"

e2e-test/cypress/support/step_definitions/runner/i_see_the_error_string_for_string.js

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,29 @@
1-
import { When } from "@badeball/cypress-cucumber-preprocessor";
1+
import { When, Then } from "@badeball/cypress-cucumber-preprocessor";
22

33
When("I see the error {string} for {string} component", (error, fieldName) => {
4-
cy.findByText("Fix the following errors");
4+
cy.findByText("There is a problem");
5+
cy.findByRole("link", { name: error });
6+
});
7+
8+
When("I see the error {string} for component {string}", (error, fieldName) => {
9+
cy.findByText("There is a problem");
510
cy.findByRole("link", { name: error });
11+
cy.findByRole("group", { description: `Error: ${error}` });
12+
});
13+
14+
Then(
15+
"I see the date parts with a error string {string} for {string}",
16+
(error, fieldName) => {
17+
cy.findByText("There is a problem");
18+
cy.get(`#${fieldName}-error`).within(() => {
19+
cy.findByText(error, { exact: false });
20+
});
21+
}
22+
);
23+
24+
Then("I see the date parts with error {string}", (error) => {
25+
cy.findByText("There is a problem");
26+
cy.findByRole("link", { name: error, exact: false });
627
});
728

829
When("I see the error {string} for {string} component with problem title", (error, fieldName) => {

runner/src/server/plugins/engine/page-controllers/PageControllerBase.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ export class PageControllerBase {
457457
});
458458

459459
return {
460-
titleText: request.i18n.__('validation.title2'),
460+
titleText: request.i18n.__('validation.title1'),
461461
errorList: errorList.filter(
462462
({text}, index) =>
463463
index === errorList.findIndex((err) => err.text === text)
@@ -863,7 +863,7 @@ export class PageControllerBase {
863863
});
864864

865865
formResult.errors = Object.is(formResult.errors, null)
866-
? {titleText: request.i18n.__('validation.title2'),}
866+
? {titleText: request.i18n.__('validation.title1'),}
867867
: formResult.errors;
868868
formResult.errors.errorList = reformattedErrors;
869869
}
@@ -890,7 +890,7 @@ export class PageControllerBase {
890890
});
891891

892892
formResult.errors = Object.is(formResult.errors, null)
893-
? {titleText: request.i18n.__('validation.title2'),}
893+
? {titleText: request.i18n.__('validation.title1'),}
894894
: formResult.errors;
895895
formResult.errors.errorList = reformattedErrors;
896896
}

runner/test/cases/server/plugins/engine/page-controllers/PageControllerBase.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ suite("PageControllerBase", () => {
8181
auth: {isAuthenticated: true},
8282
};
8383
expect(page.getErrors(error, mockRequest)).to.equal({
84-
titleText: "Fix the following errors",
84+
titleText: "There is a problem",
8585
errorList: [
8686
{
8787
path: "approximate",

0 commit comments

Comments
 (0)