Browse Source

Update summary cards to use govuk frontend component

pull/1794/head
Kat 3 years ago
parent
commit
f84dd7fc1e
  1. 10
      app/components/bulk_upload_error_row_component.html.erb
  2. 8
      app/components/check_answers_summary_list_card_component.html.erb
  3. 4
      app/views/form/_interruption_screen_question.html.erb
  4. 8
      app/views/form/review.html.erb
  5. 6
      spec/features/form/check_answers_page_lettings_logs_spec.rb
  6. 30
      spec/features/form/check_answers_page_sales_logs_spec.rb
  7. 2
      spec/views/bulk_upload_lettings_results/show.html.erb_spec.rb
  8. 2
      spec/views/bulk_upload_lettings_results/summary.html.erb_spec.rb
  9. 2
      spec/views/bulk_upload_sales_results/show.html.erb_spec.rb
  10. 2
      spec/views/bulk_upload_sales_results/summary.html.erb_spec.rb

10
app/components/bulk_upload_error_row_component.html.erb

@ -1,13 +1,13 @@
<div class="x-govuk-summary-card govuk-!-margin-bottom-6"> <div class="govuk-summary-card govuk-!-margin-bottom-6">
<div class="x-govuk-summary-card__header"> <div class="govuk-summary-card__title-wrapper">
<% if lettings? %> <% if lettings? %>
<h3 class="x-govuk-summary-card__title"><strong>Row <%= row %></strong> <%= tenant_code_html %> <%= property_ref_html %></h3> <h3 class="govuk-summary-card__title"><strong>Row <%= row %></strong> <%= tenant_code_html %> <%= property_ref_html %></h3>
<% else %> <% else %>
<h3 class="x-govuk-summary-card__title"><strong>Row <%= row %></strong> <%= purchaser_code_html %></h3> <h3 class="govuk-summary-card__title"><strong>Row <%= row %></strong> <%= purchaser_code_html %></h3>
<% end %> <% end %>
</div> </div>
<div class="x-govuk-summary-card__body"> <div class="govuk-summary-card__content">
<%= govuk_table do |table| %> <%= govuk_table do |table| %>
<% table.head do |head| %> <% table.head do |head| %>
<% head.row do |row| %> <% head.row do |row| %>

8
app/components/check_answers_summary_list_card_component.html.erb

@ -1,12 +1,12 @@
<% if applicable_questions.first %> <% if applicable_questions.first %>
<div class="x-govuk-summary-card govuk-!-margin-bottom-6"> <div class="govuk-summary-card govuk-!-margin-bottom-6">
<% if applicable_questions.first.check_answers_card_number != 0 && applicable_questions.first.check_answers_card_number.present? %> <% if applicable_questions.first.check_answers_card_number != 0 && applicable_questions.first.check_answers_card_number.present? %>
<div class="x-govuk-summary-card__header"> <div class="govuk-summary-card__title-wrapper">
<h3 class="x-govuk-summary-card__title"><%= check_answers_card_title(applicable_questions.first) %></h3> <h3 class="govuk-summary-card__title"><%= check_answers_card_title(applicable_questions.first) %></h3>
</div> </div>
<% end %> <% end %>
<div class="x-govuk-summary-card__body"> <div class="govuk-summary-card__content">
<%= govuk_summary_list do |summary_list| %> <%= govuk_summary_list do |summary_list| %>
<% applicable_questions.each do |question| %> <% applicable_questions.each do |question| %>
<% summary_list.row do |row| %> <% summary_list.row do |row| %>

4
app/views/form/_interruption_screen_question.html.erb

@ -3,8 +3,8 @@
<h1 class="govuk-heading-m"> <h1 class="govuk-heading-m">
Make sure these answers are correct: Make sure these answers are correct:
</h1> </h1>
<div class="x-govuk-summary-card govuk-!-margin-bottom-6"> <div class="govuk-summary-card govuk-!-margin-bottom-6">
<div class="x-govuk-summary-card__body"> <div class="govuk-summary-card__content">
<%= render partial: "form/check_answers_summary_list", locals: { <%= render partial: "form/check_answers_summary_list", locals: {
lettings_log:, lettings_log:,

8
app/views/form/review.html.erb

@ -14,11 +14,11 @@
<h2 class="govuk-heading-m"><%= section.label %></h2> <h2 class="govuk-heading-m"><%= section.label %></h2>
<% section.subsections.map do |subsection| %> <% section.subsections.map do |subsection| %>
<% if total_applicable_questions(subsection, @log, current_user).any? %> <% if total_applicable_questions(subsection, @log, current_user).any? %>
<div class="x-govuk-summary-card govuk-!-margin-bottom-6"> <div class="govuk-summary-card govuk-!-margin-bottom-6">
<div class="x-govuk-summary-card__header"> <div class="govuk-summary-card__title-wrapper">
<h3 class="x-govuk-summary-card__title"><%= subsection.label %></h3> <h3 class="govuk-summary-card__title"><%= subsection.label %></h3>
</div> </div>
<div class="x-govuk-summary-card__body"> <div class="govuk-summary-card__content">
<%= render partial: "form/check_answers_summary_list", locals: { subsection:, questions: total_applicable_questions(subsection, @log, current_user), referrer: "check_answers" } %> <%= render partial: "form/check_answers_summary_list", locals: { subsection:, questions: total_applicable_questions(subsection, @log, current_user), referrer: "check_answers" } %>
</div> </div>
</div> </div>

6
spec/features/form/check_answers_page_lettings_logs_spec.rb

@ -148,14 +148,14 @@ RSpec.describe "Lettings Log Check Answers Page" do
it "does not group questions into summary cards if the questions in the subsection don't have a check_answers_card_number attribute" do it "does not group questions into summary cards if the questions in the subsection don't have a check_answers_card_number attribute" do
visit("/lettings-logs/#{completed_lettings_log.id}/household-needs/check-answers") visit("/lettings-logs/#{completed_lettings_log.id}/household-needs/check-answers")
assert_selector ".x-govuk-summary-card__title", count: 0 assert_selector ".govuk-summary-card__title", count: 0
end end
context "when the user is checking their answers for the household characteristics subsection" do context "when the user is checking their answers for the household characteristics subsection" do
it "they see a separate summary card for each member of the household" do it "they see a separate summary card for each member of the household" do
visit("/lettings-logs/#{completed_lettings_log.id}/#{subsection}/check-answers") visit("/lettings-logs/#{completed_lettings_log.id}/#{subsection}/check-answers")
assert_selector ".x-govuk-summary-card__title", text: "Lead tenant", count: 1 assert_selector ".govuk-summary-card__title", text: "Lead tenant", count: 1
assert_selector ".x-govuk-summary-card__title", text: "Person 2", count: 1 assert_selector ".govuk-summary-card__title", text: "Person 2", count: 1
end end
end end

30
spec/features/form/check_answers_page_sales_logs_spec.rb

@ -36,33 +36,33 @@ RSpec.describe "Sales Log Check Answers Page" do
it "does not group questions into summary cards if the questions in the subsection don't have a check_answers_card_number attribute" do it "does not group questions into summary cards if the questions in the subsection don't have a check_answers_card_number attribute" do
visit("/sales-logs/#{completed_sales_log_joint_purchase.id}/household-needs/check-answers") visit("/sales-logs/#{completed_sales_log_joint_purchase.id}/household-needs/check-answers")
assert_selector ".x-govuk-summary-card__title", count: 0 assert_selector ".govuk-summary-card__title", count: 0
end end
context "when the user is checking their answers for the household characteristics subsection" do context "when the user is checking their answers for the household characteristics subsection" do
context "and the log is for a joint purchase" do context "and the log is for a joint purchase" do
it "they see a separate summary card for each member of the household" do it "they see a separate summary card for each member of the household" do
visit("/sales-logs/#{completed_sales_log_joint_purchase.id}/#{subsection}/check-answers") visit("/sales-logs/#{completed_sales_log_joint_purchase.id}/#{subsection}/check-answers")
assert_selector ".x-govuk-summary-card__title", text: "Buyer 1", count: 1 assert_selector ".govuk-summary-card__title", text: "Buyer 1", count: 1
assert_selector ".x-govuk-summary-card__title", text: "Buyer 2", count: 1 assert_selector ".govuk-summary-card__title", text: "Buyer 2", count: 1
assert_selector ".x-govuk-summary-card__title", text: "Person 1", count: 0 assert_selector ".govuk-summary-card__title", text: "Person 1", count: 0
assert_selector ".x-govuk-summary-card__title", text: "Person 2", count: 0 assert_selector ".govuk-summary-card__title", text: "Person 2", count: 0
assert_selector ".x-govuk-summary-card__title", text: "Person 3", count: 1 assert_selector ".govuk-summary-card__title", text: "Person 3", count: 1
assert_selector ".x-govuk-summary-card__title", text: "Person 4", count: 1 assert_selector ".govuk-summary-card__title", text: "Person 4", count: 1
assert_selector ".x-govuk-summary-card__title", text: "Person 5", count: 1 assert_selector ".govuk-summary-card__title", text: "Person 5", count: 1
end end
end end
context "and the log is for a non-joint purchase" do context "and the log is for a non-joint purchase" do
it "they see a separate summary card for each member of the household" do it "they see a separate summary card for each member of the household" do
visit("/sales-logs/#{completed_sales_log_non_joint_purchase.id}/#{subsection}/check-answers") visit("/sales-logs/#{completed_sales_log_non_joint_purchase.id}/#{subsection}/check-answers")
assert_selector ".x-govuk-summary-card__title", text: "Buyer 1", count: 1 assert_selector ".govuk-summary-card__title", text: "Buyer 1", count: 1
assert_selector ".x-govuk-summary-card__title", text: "Buyer 2", count: 0 assert_selector ".govuk-summary-card__title", text: "Buyer 2", count: 0
assert_selector ".x-govuk-summary-card__title", text: "Person 1", count: 0 assert_selector ".govuk-summary-card__title", text: "Person 1", count: 0
assert_selector ".x-govuk-summary-card__title", text: "Person 2", count: 1 assert_selector ".govuk-summary-card__title", text: "Person 2", count: 1
assert_selector ".x-govuk-summary-card__title", text: "Person 3", count: 1 assert_selector ".govuk-summary-card__title", text: "Person 3", count: 1
assert_selector ".x-govuk-summary-card__title", text: "Person 4", count: 1 assert_selector ".govuk-summary-card__title", text: "Person 4", count: 1
assert_selector ".x-govuk-summary-card__title", text: "Person 5", count: 1 assert_selector ".govuk-summary-card__title", text: "Person 5", count: 1
end end
end end
end end

2
spec/views/bulk_upload_lettings_results/show.html.erb_spec.rb

@ -16,7 +16,7 @@ RSpec.describe "bulk_upload_lettings_results/show.html.erb" do
fragment = Capybara::Node::Simple.new(rendered) fragment = Capybara::Node::Simple.new(rendered)
expect(fragment.find_css(".x-govuk-summary-card__title strong").map(&:inner_text)).to eql(["Row 10", "Row 14"]) expect(fragment.find_css(".govuk-summary-card__title strong").map(&:inner_text)).to eql(["Row 10", "Row 14"])
end end
end end

2
spec/views/bulk_upload_lettings_results/summary.html.erb_spec.rb

@ -16,7 +16,7 @@ RSpec.describe "bulk_upload_lettings_results/summary.html.erb" do
fragment = Capybara::Node::Simple.new(rendered) fragment = Capybara::Node::Simple.new(rendered)
expect(fragment.find_css(".x-govuk-summary-card__title strong").map(&:inner_text)).to eql(["Row 10", "Row 14"]) expect(fragment.find_css(".govuk-summary-card__title strong").map(&:inner_text)).to eql(["Row 10", "Row 14"])
end end
end end

2
spec/views/bulk_upload_sales_results/show.html.erb_spec.rb

@ -16,7 +16,7 @@ RSpec.describe "bulk_upload_sales_results/show.html.erb" do
fragment = Capybara::Node::Simple.new(rendered) fragment = Capybara::Node::Simple.new(rendered)
expect(fragment.find_css(".x-govuk-summary-card__title strong").map(&:inner_text)).to eql(["Row 10", "Row 14"]) expect(fragment.find_css(".govuk-summary-card__title strong").map(&:inner_text)).to eql(["Row 10", "Row 14"])
end end
end end

2
spec/views/bulk_upload_sales_results/summary.html.erb_spec.rb

@ -16,7 +16,7 @@ RSpec.describe "bulk_upload_sales_results/summary.html.erb" do
fragment = Capybara::Node::Simple.new(rendered) fragment = Capybara::Node::Simple.new(rendered)
expect(fragment.find_css(".x-govuk-summary-card__title strong").map(&:inner_text)).to eql(["Row 10", "Row 14"]) expect(fragment.find_css(".govuk-summary-card__title strong").map(&:inner_text)).to eql(["Row 10", "Row 14"])
end end
end end

Loading…
Cancel
Save