Browse Source

Update a few feature tests

pull/2875/head
Kat 5 months ago
parent
commit
703c6461ff
  1. 8
      app/models/form_handler.rb
  2. 10
      spec/features/organisation_spec.rb
  3. 3
      spec/features/sales_log_spec.rb

8
app/models/form_handler.rb

@ -36,6 +36,10 @@ class FormHandler
forms["next_lettings"]
end
def archived_lettings_form
forms["archived_lettings"]
end
def current_sales_form
forms["current_sales"]
end
@ -44,6 +48,10 @@ class FormHandler
forms["previous_sales"]
end
def archived_sales_form
forms["archived_sales"]
end
def next_sales_form
forms["next_sales"]
end

10
spec/features/organisation_spec.rb

@ -132,6 +132,7 @@ RSpec.describe "User Features" do
let!(:other_general_needs_logs) { FactoryBot.create_list(:lettings_log, 4, assigned_to: user, needstype: 1) }
let!(:other_supported_housing_logs) { FactoryBot.create_list(:lettings_log, 4, assigned_to: user, needstype: 2) }
let(:number_of_lettings_logs) { LettingsLog.count }
let(:previous_year) { FormHandler.instance.previous_lettings_form.start_date.year }
before do
allow(FormHandler.instance).to receive(:in_crossover_period?).and_return(true)
@ -204,9 +205,9 @@ RSpec.describe "User Features" do
end
it "can filter lettings logs by year" do
check("years-2022-field")
check("years-#{previous_year}-field")
click_button("Apply filters")
expect(page).to have_current_path("/organisations/#{org_id}/lettings-logs?%5Byears%5D[]=&years[]=2022&%5Bstatus%5D[]=&%5Bneedstypes%5D[]=&assigned_to=all&user_text_search=&user=&owning_organisation_select=all&owning_organisation_text_search=&owning_organisation=&managing_organisation_select=all&managing_organisation_text_search=&managing_organisation=")
expect(page).to have_current_path("/organisations/#{org_id}/lettings-logs?%5Byears%5D[]=&years[]=#{previous_year}&%5Bstatus%5D[]=&%5Bneedstypes%5D[]=&assigned_to=all&user_text_search=&user=&owning_organisation_select=all&owning_organisation_text_search=&owning_organisation=&managing_organisation_select=all&managing_organisation_text_search=&managing_organisation=")
expect(page).not_to have_link first_log.id.to_s, href: "/lettings-logs/#{first_log.id}"
end
@ -226,6 +227,7 @@ RSpec.describe "User Features" do
context "when viewing sales logs for specific organisation" do
let(:first_log) { organisation.sales_logs.first }
let(:number_of_sales_logs) { SalesLog.count }
let(:previous_year) { FormHandler.instance.previous_sales_form.start_date.year }
before do
allow(FormHandler.instance).to receive(:in_crossover_period?).and_return(true)
@ -254,9 +256,9 @@ RSpec.describe "User Features" do
organisation.sales_logs.map(&:id).each do |sales_log_id|
expect(page).to have_link sales_log_id.to_s, href: "/sales-logs/#{sales_log_id}"
end
check("years-2022-field")
check("years-#{previous_year}-field")
click_button("Apply filters")
expect(page).to have_current_path("/organisations/#{org_id}/sales-logs?%5Byears%5D[]=&years[]=2022&%5Bstatus%5D[]=&assigned_to=all&user_text_search=&user=&owning_organisation_select=all&owning_organisation_text_search=&owning_organisation=&managing_organisation_select=all&managing_organisation_text_search=&managing_organisation=")
expect(page).to have_current_path("/organisations/#{org_id}/sales-logs?%5Byears%5D[]=&years[]=#{previous_year}&%5Bstatus%5D[]=&assigned_to=all&user_text_search=&user=&owning_organisation_select=all&owning_organisation_text_search=&owning_organisation=&managing_organisation_select=all&managing_organisation_text_search=&managing_organisation=")
expect(page).not_to have_link first_log.id.to_s, href: "/sales-logs/#{first_log.id}"
end
end

3
spec/features/sales_log_spec.rb

@ -142,6 +142,7 @@ RSpec.describe "Sales Log Features" do
context "when downloading logs" do
let(:user) { create(:user, :support) }
let(:other_user) { create(:user, organisation: user.organisation) }
let(:current_year) { FormHandler.instance.current_sales_form.start_date.year }
context "when I am signed in" do
before do
@ -191,7 +192,7 @@ RSpec.describe "Sales Log Features" do
context "when one year filter is selected" do
before do
check("2024 to 2025")
check("#{current_year} to #{current_year + 1}")
click_button("Apply filters")
end

Loading…
Cancel
Save