diff --git a/spec/components/check_answers_summary_list_card_component_spec.rb b/spec/components/check_answers_summary_list_card_component_spec.rb index f9b8f6667..41bf32e28 100644 --- a/spec/components/check_answers_summary_list_card_component_spec.rb +++ b/spec/components/check_answers_summary_list_card_component_spec.rb @@ -5,44 +5,63 @@ RSpec.describe CheckAnswersSummaryListCardComponent, type: :component do let(:rendered) { render_inline(component) } - context "when given a set of questions" do - let(:user) { build(:user) } - let(:log) { build(:lettings_log, :completed, age2: 99, startdate: Time.zone.local(2021, 5, 1)) } - let(:subsection_id) { "household_characteristics" } - let(:subsection) { log.form.get_subsection(subsection_id) } - let(:questions) { subsection.applicable_questions(log) } - - it "renders a summary list card for the answers to those questions" do - expect(rendered).to have_content(questions.first.answer_label(log)) - end + context "when before 23/24 collection" do + context "when given a set of questions" do + let(:user) { build(:user) } + let(:log) { build(:lettings_log, :completed, age2: 99, startdate: Time.zone.local(2021, 5, 1)) } + let(:subsection_id) { "household_characteristics" } + let(:subsection) { log.form.get_subsection(subsection_id) } + let(:questions) { subsection.applicable_questions(log) } - it "applicable questions doesn't return questions that are hidden in check answers" do - expect(component.applicable_questions.map(&:id).include?("retirement_value_check")).to eq(false) - end + it "renders a summary list card without question numbers for the answers to those questions" do + expect(rendered).to have_content(questions.first.answer_label(log)) + expect(rendered).to have_content("Lead tenant’s age") + expect(rendered).not_to have_content("Q32 - Lead tenant’s age") + end - it "has the correct answer label for a question" do - sex1_question = questions[2] - expect(component.get_answer_label(sex1_question)).to eq("Female") - end + it "applicable questions doesn't return questions that are hidden in check answers" do + expect(component.applicable_questions.map(&:id).include?("retirement_value_check")).to eq(false) + end + + it "has the correct answer label for a question" do + sex1_question = questions[2] + expect(component.get_answer_label(sex1_question)).to eq("Female") + end - context "when log was created via a bulk upload and has an unanswered question" do - subject(:component) { described_class.new(questions:, log:, user:) } + context "when log was created via a bulk upload and has an unanswered question" do + subject(:component) { described_class.new(questions:, log:, user:) } - let(:bulk_upload) { build(:bulk_upload, :lettings) } - let(:log) { build(:lettings_log, :in_progress, bulk_upload:, age2: 99, startdate: Time.zone.local(2021, 5, 1)) } + let(:bulk_upload) { build(:bulk_upload, :lettings) } + let(:log) { build(:lettings_log, :in_progress, bulk_upload:, age2: 99, startdate: Time.zone.local(2021, 5, 1)) } - it "displays tweaked copy in red" do - expect(rendered).to have_selector("span", class: "app-!-colour-red", text: "You still need to answer this question") + it "displays tweaked copy in red" do + expect(rendered).to have_selector("span", class: "app-!-colour-red", text: "You still need to answer this question") + end end - end - context "when log was not created via a bulk upload and has an unanswered question" do - subject(:component) { described_class.new(questions:, log:, user:) } + context "when log was not created via a bulk upload and has an unanswered question" do + subject(:component) { described_class.new(questions:, log:, user:) } + + let(:log) { build(:lettings_log, :in_progress, age2: 99, startdate: Time.zone.local(2021, 5, 1)) } + + it "displays normal copy with muted colour " do + expect(rendered).to have_selector("span", class: "app-!-colour-muted", text: "You didn’t answer this question") + end + end + end + end - let(:log) { build(:lettings_log, :in_progress, age2: 99, startdate: Time.zone.local(2021, 5, 1)) } + context "when in 23/24 collection" do + context "when given a set of questions" do + let(:user) { build(:user) } + let(:log) { build(:lettings_log, :completed, age2: 99, startdate: Time.zone.local(2023, 5, 1)) } + let(:subsection_id) { "household_characteristics" } + let(:subsection) { log.form.get_subsection(subsection_id) } + let(:questions) { subsection.applicable_questions(log) } - it "displays normal copy with muted colour " do - expect(rendered).to have_selector("span", class: "app-!-colour-muted", text: "You didn’t answer this question") + it "renders a summary list card includinq question numbers for the answers to those questions" do + expect(rendered).to have_content(questions.first.answer_label(log)) + expect(rendered).to have_content("Q32 - Lead tenant’s age") end end end