Browse Source

feat: add tests for sales and lettings behaviour separately

pull/1509/head
natdeanlewissoftwire 3 years ago
parent
commit
beac7764da
  1. 2
      app/views/logs/edit.html.erb
  2. 51
      spec/helpers/tasklist_helper_spec.rb

2
app/views/logs/edit.html.erb

@ -11,7 +11,7 @@
</h1>
<% if @log.status == "in_progress" %>
<p class="govuk-body govuk-!-margin-bottom-7"><%= get_subsections_count(@log, :completed) %> of <%= get_subsections_count(@log, :all) %> subsections completed.</p>
<p class="govuk-body govuk-!-margin-bottom-7"><%= get_subsections_count(@log, :completed) %> of <%= get_subsections_count(@log) %> subsections completed.</p>
<p class="govuk-body govuk-!-margin-bottom-2">
<% next_incomplete_section = get_next_incomplete_section(@log) %>
</p>

51
spec/helpers/tasklist_helper_spec.rb

@ -27,26 +27,30 @@ RSpec.describe TasklistHelper do
end
describe "get sections count" do
let(:fake_2021_2022_form) { Form.new("spec/fixtures/forms/2021_2022.json") }
let(:real_2021_2022_form) { Form.new("config/forms/2021_2022.json") }
before do
allow(FormHandler.instance).to receive(:get_form).and_return(fake_2021_2022_form)
allow(FormHandler.instance).to receive(:get_form).and_return(real_2021_2022_form)
end
it "returns the total of sections if no status is given" do
expect(get_subsections_count(empty_lettings_log)).to eq(8)
context "with an empty lettings log" do
it "returns the total displayed subsections count if no status is given" do
expect(get_subsections_count(empty_lettings_log)).to eq(7)
end
it "returns 0 sections for completed sections if no sections are completed" do
expect(get_subsections_count(empty_lettings_log, :completed)).to eq(0)
end
end
it "returns the number of not started sections" do
expect(get_subsections_count(empty_lettings_log, :not_started)).to eq(8)
context "with a partially complete lettings log" do
it "returns the total displayed subsections count if no status is given" do
expect(get_subsections_count(lettings_log)).to eq(7)
end
it "returns the number of sections in progress" do
expect(get_subsections_count(lettings_log, :in_progress)).to eq(2)
it "returns the completed sections count" do
expect(get_subsections_count(lettings_log, :completed)).to eq(1)
end
end
it "returns 0 for invalid state" do
@ -77,6 +81,37 @@ RSpec.describe TasklistHelper do
end
end
describe "with sales" do
let(:empty_sales_log) { create(:sales_log, owning_organisation: nil) }
let(:completed_sales_log) { build(:sales_log, :completed) }
describe "get sections count" do
context "with an empty sales log" do
it "returns the total displayed subsections count if no status is given (includes all 3 sale information subsections)" do
expect(get_subsections_count(empty_sales_log)).to eq(9)
end
it "returns 0 sections for completed sections if no sections are completed" do
expect(get_subsections_count(empty_sales_log, :completed)).to eq(0)
end
end
context "with a completed sales log" do
it "returns the total displayed subsections count if no status is given (includes only the 1 relevant sale information subsection)" do
expect(get_subsections_count(completed_sales_log)).to eq(7)
end
it "returns the completed sections count" do
expect(get_subsections_count(completed_sales_log, :completed)).to eq(7)
end
end
it "returns 0 for invalid state" do
expect(get_subsections_count(completed_sales_log, :fake)).to eq(0)
end
end
end
describe "#review_log_text" do
context "with sales log" do
context "when collection_period_open? == true" do

Loading…
Cancel
Save