Skip to content

Commit

Permalink
update multiselect error message (#3438)
Browse files Browse the repository at this point in the history
  • Loading branch information
thanhz authored Nov 2, 2023
1 parent 28def34 commit 0fa3e1b
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion app/controllers/util/FormField.scala
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ case class DateField(
}

object FormField {
val dropdownOptionNotSelectedError = "Search for and select at least one %s"
val dropdownOptionNotSelectedError = "Select at least one %s"
val invalidDropdownOptionSelectedError = "Option '%s' was not an option provided to the user."
val emptyValueError = "The %s must contain a %s"
val wholeNumberError = "The %s must be a whole number, like %s"
Expand Down
2 changes: 1 addition & 1 deletion test/controllers/AddAdditionalMetadataControllerSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ class AddAdditionalMetadataControllerSpec extends FrontEndTestHelper {
)
addAdditionalMetadataPageAsString should include(""" <p class="govuk-error-message" id="error-FoiExemptionCode">
| <span class="govuk-visually-hidden">Error:</span>
| Search for and select at least one FOI exemption code(s)
| Select at least one FOI exemption code
| </p>""".stripMargin)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class AdditionalMetadataSummaryControllerSpec extends FrontEndTestHelper {
("Is the title closed?", "Yes"),
("Closure Period", "4 years"),
("Closure Start Date", "01/12/1990"),
("FOI exemption code(s)", "1, 2 "),
("FOI exemption code", "1, 2 "),
("Alternative Title2", "An alternative title ")
)

Expand Down
2 changes: 1 addition & 1 deletion test/controllers/util/DynamicFormUtilsSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class DynamicFormUtilsSpec extends AnyFlatSpec with MockitoSugar with BeforeAndA
val validatedForm = dynamicFormUtils.convertSubmittedValuesToFormFields(dynamicFormUtils.formAnswersWithValidInputNames)
validatedForm.foreach {
case multiSelectField: MultiSelectField =>
multiSelectField.fieldErrors should equal(List(s"Search for and select at least one ${multiSelectField.fieldName}"))
multiSelectField.fieldErrors should equal(List(s"Select at least one ${multiSelectField.fieldName}"))
case _ =>
}
}
Expand Down
8 changes: 4 additions & 4 deletions test/controllers/util/FormFieldSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ class FormFieldSpec extends AnyWordSpec with MockitoSugar with BeforeAndAfterEac

"validate should return an error when the given value is empty" in {

DropdownField.validate(None, dropdownField) shouldBe Some("Search for and select at least one name")
DropdownField.validate(None, dropdownField) shouldBe Some("Select at least one name")
}

"validate should return an error when the given value is not a valid option" in {
Expand All @@ -258,7 +258,7 @@ class FormFieldSpec extends AnyWordSpec with MockitoSugar with BeforeAndAfterEac
}

"updateError should set an error message as per the given error code" in {
DropdownField.updateError(dropdownField, EMPTY_VALUE_ERROR).fieldErrors shouldBe List("Search for and select at least one name")
DropdownField.updateError(dropdownField, EMPTY_VALUE_ERROR).fieldErrors shouldBe List("Select at least one name")
DropdownField
.updateError(dropdownField.copy(selectedOption = InputNameAndValue("Test", "Test").some), UNDEFINED_VALUE_ERROR)
.fieldErrors shouldBe List("Option 'Test' was not an option provided to the user.")
Expand Down Expand Up @@ -295,7 +295,7 @@ class FormFieldSpec extends AnyWordSpec with MockitoSugar with BeforeAndAfterEac

"validate should return an error when the given value is empty" in {

MultiSelectField.validate(Nil, multiSelectField) shouldBe Some("Search for and select at least one name")
MultiSelectField.validate(Nil, multiSelectField) shouldBe Some("Select at least one name")
}

"validate should return an error when the given value is not a valid option" in {
Expand All @@ -304,7 +304,7 @@ class FormFieldSpec extends AnyWordSpec with MockitoSugar with BeforeAndAfterEac
}

"updateError should set an error message as per the given error code" in {
MultiSelectField.updateError(multiSelectField, EMPTY_VALUE_ERROR).fieldErrors shouldBe List("Search for and select at least one name")
MultiSelectField.updateError(multiSelectField, EMPTY_VALUE_ERROR).fieldErrors shouldBe List("Select at least one name")
MultiSelectField
.updateError(multiSelectField.copy(selectedOption = List(InputNameAndValue("Test", "Test")).some), UNDEFINED_VALUE_ERROR)
.fieldErrors shouldBe List("Option 'Test' was not an option provided to the user.")
Expand Down
2 changes: 1 addition & 1 deletion test/testUtils/CheckFormPageElements.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class CheckFormPageElements() {
| Number of years the record is closed from the closure start date
| </div>""",
""" <label class="govuk-label govuk-label--m" for="inputmultiselect-FoiExemptionCode">
| FOI exemption code(s)
| FOI exemption code
| </label>""",
""" <div id="inputmultiselect-FoiExemptionCode-hint" class="govuk-hint">
| Add one or more exemption code to this closure. Here is a <a target="_blank" href="https://www.legislation.gov.uk/ukpga/2000/36/contents">full list of FOI codes and their designated exemptions</a>
Expand Down
4 changes: 2 additions & 2 deletions test/testUtils/DefaultMockFormOptions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,15 @@ object DefaultMockFormOptions {
label = "mock code1",
value = "mock code1",
fieldType = "inputmultiselect",
errorMessage = "Search for and select at least one FOI exemption code(s)"
errorMessage = "Select at least one FOI exemption code"
),
MockInputOption(
name = "inputmultiselect-FoiExemptionCode",
id = "inputmultiselect-FoiExemptionCode-1",
label = "mock code2",
value = "mock code2",
fieldType = "inputmultiselect",
errorMessage = "Search for and select at least one FOI exemption code(s)"
errorMessage = "Select at least one FOI exemption code"
),
MockInputOption(
name = "inputradio-TitleClosed",
Expand Down
2 changes: 1 addition & 1 deletion test/testUtils/FrontEndTestHelper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ trait FrontEndTestHelper extends PlaySpec with MockitoSugar with Injecting with
),
Text
),
dp.DisplayProperties.Attributes("Name", Some("FOI exemption code(s)"), Text),
dp.DisplayProperties.Attributes("Name", Some("FOI exemption code"), Text),
dp.DisplayProperties.Attributes("Guidance", Some("Search by typing an FOI Exemption code"), Text),
dp.DisplayProperties.Attributes("Editable", Some("true"), Boolean),
dp.DisplayProperties.Attributes("Group", Some("2"), Text),
Expand Down

0 comments on commit 0fa3e1b

Please sign in to comment.