diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 257ee4cc9..2a0a0bec3 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,9 +1,13 @@ - <% if @case_log.errors.present? %> + <% if @resource.present? && @resource.errors.present? %> <%= browser_title("Error: #{yield(:title)}") %> - <% elsif %> + <% elsif @user.present? && @user.errors.present? %> + <%= browser_title("Error: #{yield(:title)}") %> + <% elsif @case_log.present? && @case_log.errors.present?%> + <%= browser_title("Error: #{yield(:title)}") %> + <% else %> <%= browser_title(yield(:title)) %> <% end %> <%= csrf_meta_tags %> diff --git a/spec/features/form/validations_spec.rb b/spec/features/form/validations_spec.rb index 5f39d92d7..9f7a1c415 100644 --- a/spec/features/form/validations_spec.rb +++ b/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("#case-log-age1-error") expect(page).to have_selector("#case-log-age1-field-error") + expect(page).to have_title('Error') end 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("#case-log-age1-error") expect(page).to have_selector("#case-log-age1-field-error") + expect(page).to have_title('Error') end end end diff --git a/spec/features/user_spec.rb b/spec/features/user_spec.rb index 9f2eaf9b2..25bfa6d85 100644 --- a/spec/features/user_spec.rb +++ b/spec/features/user_spec.rb @@ -34,6 +34,7 @@ RSpec.describe "User Features" do click_button("Send email") expect(page).to have_selector("#error-summary-title") expect(page).to have_selector("#user-email-field-error") + expect(page).to have_title('Error') end 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") expect(page).to have_selector("#error-summary-title") expect(page).to have_selector("#user-email-field-error") + expect(page).to have_title('Error') end 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") 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_title('Error') end 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("#user-email-field-error") expect(page).to have_selector("#user-password-field-error") + expect(page).to have_title('Error') end 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("#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_title('Error') end end @@ -180,6 +185,7 @@ RSpec.describe "User Features" do expect(page).to have_selector("#error-summary-title") expect(page).to have_selector("#user-email-field-error") expect(page).to have_content(/Enter an email address/) + expect(page).to have_title('Error') end 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("#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_title('Error') end end end