Skip to content
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

Change date validation error message #3520

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/assets/javascripts/live_search.js
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@
var errorMessageElement = document.createElement('span')
errorMessageElement.setAttribute('id', 'error-' + type)
errorMessageElement.setAttribute('class', 'gem-c-error-message govuk-error-message')
errorMessageElement.innerHTML = '<span class="govuk-visually-hidden">Error:</span> Enter a real date'
errorMessageElement.innerHTML = '<span class="govuk-visually-hidden">Error:</span> Enter a date'

var errorMessages = $input.parentNode.querySelectorAll('.gem-c-error-message')
if (errorMessages.length === 0) {
Expand Down
2 changes: 1 addition & 1 deletion app/validators/date_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ def invalid_date?(user_input)
end

def error_message
"Enter a real date"
"Enter a date"
end
end
2 changes: 1 addition & 1 deletion features/all_content_finder.feature
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Feature: All content finder ("site search")
And I enter "-1" for "Year" under "Updated before"
And I apply the filters
Then the filter panel is open by default
And I can see an error message "Enter a real date"
And I can see an error message "Enter a date"

Scenario: Spelling suggestion
When I search all content for "drving"
Expand Down
2 changes: 1 addition & 1 deletion spec/javascripts/live_search_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ describe('liveSearch', function () {
'For example, 2005 or 21/11/2014' +
'</div>' +
'<span id="error-to" class="gem-c-error-message govuk-error-message">' +
'<span class="govuk-visually-hidden">Error:</span> Enter a real date</span>' +
'<span class="govuk-visually-hidden">Error:</span> Enter a date</span>' +
'<input name="public_timestamp[to]" value="" class="gem-c-input govuk-input govuk-input--error" id="public_timestamp[to]" ' +
'type="text" aria-describedby="hint-3626790f error-to" aria-controls="js-search-results-info">' +
'</div></div>')
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/search/query_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -362,13 +362,13 @@ def result_item(id, title, score:, popularity:, updated:)
it "stores an error for bad 'to date'" do
query = described_class.new(content_item, invalid_to_date_params)
expect(query.valid?).to be false
expect(query.errors.messages).to eq(to_date: ["Enter a real date"])
expect(query.errors.messages).to eq(to_date: ["Enter a date"])
end

it "stores an error for bad 'from date'" do
query = described_class.new(content_item, invalid_from_date_params)
expect(query.valid?).to be false
expect(query.errors.messages).to eq(from_date: ["Enter a real date"])
expect(query.errors.messages).to eq(from_date: ["Enter a date"])
end
end
end
Expand Down
Loading