Browse Source

Merge pull request #145 from communitiesuk/CLDC-764/PageTitlesErrorPrefix

Titles prefixed with error
pull/149/head^2
Matthew J. Phelan 3 years ago committed by GitHub
parent
commit
5e875a23fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      app/helpers/application_helper.rb
  2. 2
      spec/features/form/validations_spec.rb
  3. 7
      spec/features/user_spec.rb

16
app/helpers/application_helper.rb

@ -1,5 +1,21 @@
module ApplicationHelper module ApplicationHelper
def browser_title(title) def browser_title(title)
if user_log_errors || case_log_errors || resource_errors
["Error", title, t("service_name"), "GOV.UK"].select(&:present?).join(" - ")
else
[title, t("service_name"), "GOV.UK"].select(&:present?).join(" - ") [title, t("service_name"), "GOV.UK"].select(&:present?).join(" - ")
end end
end end
def user_log_errors
@user.present? && @user.errors.present?
end
def case_log_errors
@case_log.present? && @case_log.errors.present?
end
def resource_errors
@resource.present? && @resource.errors.present?
end
end

2
spec/features/form/validations_spec.rb

@ -33,6 +33,7 @@ RSpec.describe "validations" do
expect(page).to have_selector("#error-summary-title") expect(page).to have_selector("#error-summary-title")
expect(page).to have_selector("#case-log-age1-error") expect(page).to have_selector("#case-log-age1-error")
expect(page).to have_selector("#case-log-age1-field-error") expect(page).to have_selector("#case-log-age1-field-error")
expect(page).to have_title('Error')
end end
it " of greater than 120 it shows validation" do it " of greater than 120 it shows validation" do
@ -41,6 +42,7 @@ RSpec.describe "validations" do
expect(page).to have_selector("#error-summary-title") expect(page).to have_selector("#error-summary-title")
expect(page).to have_selector("#case-log-age1-error") expect(page).to have_selector("#case-log-age1-error")
expect(page).to have_selector("#case-log-age1-field-error") expect(page).to have_selector("#case-log-age1-field-error")
expect(page).to have_title('Error')
end end
end end
end end

7
spec/features/user_spec.rb

@ -34,6 +34,7 @@ RSpec.describe "User Features" do
click_button("Send email") click_button("Send email")
expect(page).to have_selector("#error-summary-title") expect(page).to have_selector("#error-summary-title")
expect(page).to have_selector("#user-email-field-error") expect(page).to have_selector("#user-email-field-error")
expect(page).to have_title('Error')
end end
it " is shown an error message if they submit an invalid email address" do it " is shown an error message if they submit an invalid email address" do
@ -42,6 +43,7 @@ RSpec.describe "User Features" do
click_button("Send email") click_button("Send email")
expect(page).to have_selector("#error-summary-title") expect(page).to have_selector("#error-summary-title")
expect(page).to have_selector("#user-email-field-error") expect(page).to have_selector("#user-email-field-error")
expect(page).to have_title('Error')
end end
it " is redirected to check your email page after submitting an email on the reset password page" do it " is redirected to check your email page after submitting an email on the reset password page" do
@ -109,6 +111,7 @@ RSpec.describe "User Features" do
click_button("Sign in") click_button("Sign in")
expect(page).to have_selector("#error-summary-title") expect(page).to have_selector("#error-summary-title")
expect(page).to have_no_css(".govuk-notification-banner.govuk-notification-banner--success") expect(page).to have_no_css(".govuk-notification-banner.govuk-notification-banner--success")
expect(page).to have_title('Error')
end end
it "show specific field error messages if a field was omitted" do it "show specific field error messages if a field was omitted" do
@ -117,6 +120,7 @@ RSpec.describe "User Features" do
expect(page).to have_selector("#error-summary-title") expect(page).to have_selector("#error-summary-title")
expect(page).to have_selector("#user-email-field-error") expect(page).to have_selector("#user-email-field-error")
expect(page).to have_selector("#user-password-field-error") expect(page).to have_selector("#user-password-field-error")
expect(page).to have_title('Error')
end end
it "show specific field error messages if an invalid email address is entered" do it "show specific field error messages if an invalid email address is entered" do
@ -126,6 +130,7 @@ RSpec.describe "User Features" do
expect(page).to have_selector("#error-summary-title") expect(page).to have_selector("#error-summary-title")
expect(page).to have_selector("#user-email-field-error") expect(page).to have_selector("#user-email-field-error")
expect(page).to have_content(/Enter an email address in the correct format, like name@example.com/) expect(page).to have_content(/Enter an email address in the correct format, like name@example.com/)
expect(page).to have_title('Error')
end end
end end
@ -180,6 +185,7 @@ RSpec.describe "User Features" do
expect(page).to have_selector("#error-summary-title") expect(page).to have_selector("#error-summary-title")
expect(page).to have_selector("#user-email-field-error") expect(page).to have_selector("#user-email-field-error")
expect(page).to have_content(/Enter an email address/) expect(page).to have_content(/Enter an email address/)
expect(page).to have_title('Error')
end end
it "validates email" do it "validates email" do
@ -190,6 +196,7 @@ RSpec.describe "User Features" do
expect(page).to have_selector("#error-summary-title") expect(page).to have_selector("#error-summary-title")
expect(page).to have_selector("#user-email-field-error") expect(page).to have_selector("#user-email-field-error")
expect(page).to have_content(/Enter an email address in the correct format, like name@example.com/) expect(page).to have_content(/Enter an email address in the correct format, like name@example.com/)
expect(page).to have_title('Error')
end end
end end
end end

Loading…
Cancel
Save