Browse Source

Spex for error title added

pull/145/head
Matthew Phelan 3 years ago
parent
commit
04b4ca6e69
  1. 8
      app/views/layouts/application.html.erb
  2. 2
      spec/features/form/validations_spec.rb
  3. 7
      spec/features/user_spec.rb

8
app/views/layouts/application.html.erb

@ -1,9 +1,13 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en" class="govuk-template"> <html lang="en" class="govuk-template">
<head> <head>
<% if @case_log.errors.present? %> <% if @resource.present? && @resource.errors.present? %>
<title><%= browser_title("Error: #{yield(:title)}") %></title> <title><%= browser_title("Error: #{yield(:title)}") %></title>
<% elsif %> <% elsif @user.present? && @user.errors.present? %>
<title><%= browser_title("Error: #{yield(:title)}") %></title>
<% elsif @case_log.present? && @case_log.errors.present?%>
<title><%= browser_title("Error: #{yield(:title)}") %></title>
<% else %>
<title><%= browser_title(yield(:title)) %></title> <title><%= browser_title(yield(:title)) %></title>
<% end %> <% end %>
<%= csrf_meta_tags %> <%= csrf_meta_tags %>

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