Browse Source

Update component tests

CLDC-3740-Replace-you-didnt-answer-with-link
Manny Dinssa 4 weeks ago
parent
commit
2f7db2464f
  1. 20
      spec/components/check_answers_summary_list_card_component_spec.rb

20
spec/components/check_answers_summary_list_card_component_spec.rb

@ -29,8 +29,8 @@ RSpec.describe CheckAnswersSummaryListCardComponent, type: :component do
let(:bulk_upload) { create(:bulk_upload) }
let(:log) { create(:lettings_log, :in_progress, creation_method: "bulk upload", age2: 99, bulk_upload:) }
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 red prompt link for required question" do
expect(rendered).to have_link(log.form.get_question("age1_known", log).check_answer_prompt, href: "/lettings-logs/#{log.id}/lead-tenant-age?referrer=check_answers_new_answer", class: "app-red-link app-red-link---no-visited-state")
end
end
@ -46,24 +46,28 @@ RSpec.describe CheckAnswersSummaryListCardComponent, type: :component do
let(:log) { create(:lettings_log, :in_progress) }
it "displays normal copy with muted colour " do
expect(rendered).to have_selector("span", class: "app-!-colour-muted", text: "No answer provided")
expect(rendered).to have_link(log.form.get_question("sex1", log).check_answer_prompt, href: "/lettings-logs/#{log.id}/lead-tenant-gender-identity?referrer=check_answers_new_answer", class: "govuk-link govuk-link--no-visited-state")
end
end
context "when log was created via a bulk upload and has an unanswered optional question" do
let(:subsection_id) { "setup" }
let(:bulk_upload) { create(:bulk_upload) }
let(:log) { create(:lettings_log, :completed, creation_method: "bulk upload", tenancycode: nil, bulk_upload:) }
let(:log) { create(:lettings_log, :completed, creation_method: "bulk upload", needstype: nil, tenancycode: nil, bulk_upload:) }
it "displays tweaked copy in red" do
expect(rendered).to have_selector("span", class: "app-!-colour-muted", text: "No answer provided")
expect(rendered).not_to have_selector("span", class: "app-!-colour-red", text: "You still need to answer this question")
it "displays red prompt link for required question" do
expect(rendered).to have_no_link(log.form.get_question("needstype", log).check_answer_prompt, href: "/lettings-logs/#{log.id}/needs-type?referrer=check_answers_new_answer", class: "govuk-link govuk-link--no-visited-state")
expect(rendered).to have_link(log.form.get_question("needstype", log).check_answer_prompt, href: "/lettings-logs/#{log.id}/needs-type?referrer=check_answers_new_answer", class: "app-red-link app-red-link---no-visited-state")
end
it "displays regular link for optional question" do
expect(rendered).to have_link(log.form.get_question("tenancycode", log).check_answer_prompt, href: "/lettings-logs/#{log.id}/tenant-code?referrer=check_answers_new_answer", class: "govuk-link govuk-link--no-visited-state")
end
end
context "when before 23/24 collection" do
context "when given a set of questions" do
let(:log) { build(:lettings_log, :completed, age2: 99, startdate: Time.zone.local(2021, 5, 1), assigned_to: create(:user)) }
let(:log) { create(:lettings_log, :completed, :ignore_validation_errors, age2: 99, startdate: Time.zone.local(2021, 5, 1), assigned_to: create(:user)) }
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))

Loading…
Cancel
Save