diff --git a/spec/requests/case_logs_controller_spec.rb b/spec/requests/case_logs_controller_spec.rb index 278ded97a..c2f2ed7da 100644 --- a/spec/requests/case_logs_controller_spec.rb +++ b/spec/requests/case_logs_controller_spec.rb @@ -322,10 +322,11 @@ RSpec.describe CaseLogsController, type: :request do context "when using a search query" do let(:logs) { FactoryBot.create_list(:case_log, 3, :completed, owning_organisation: user.organisation) } let(:log_to_search) { FactoryBot.create(:case_log, :completed, owning_organisation: user.organisation) } + let(:log_total_count) { CaseLog.where(owning_organisation: user.organisation).count } it "has search results in the title" do get "/logs?search=#{log_to_search.id}", headers: headers, params: {} - expect(page).to have_content("Logs (search results for ‘#{log_to_search.id}’) - Submit social housing and sales data (CORE) - GOV.UK") + expect(page).to have_title("Your organisation (1 log matching ‘#{log_to_search.id}’ of #{log_total_count} total logs) - Submit social housing lettings and sales data (CORE) - GOV.UK") end it "shows case logs matching the id" do @@ -374,16 +375,18 @@ RSpec.describe CaseLogsController, type: :request do end context "when there are more than 1 page of search results" do - let(:logs) { FactoryBot.create_list(:case_log, 30, :completed, owning_organisation: user.organisation, postcode_full: "XX1 1YY") } + let(:postcode) { "XX11YY" } + let(:logs) { FactoryBot.create_list(:case_log, 30, :completed, owning_organisation: user.organisation, postcode_full: postcode) } + let(:log_total_count) { CaseLog.where(owning_organisation: user.organisation).count } it "has title with pagination details for page 1" do get "/logs?search=#{logs[0].postcode_full}", headers: headers, params: {} - expect(page).to have_content("Logs (search results for ‘#{logs[0].postcode_full}’, page 1 of 2) - Submit social housing and sales data (CORE) - GOV.UK") + expect(page).to have_title("Your organisation (#{logs.count} logs matching ‘#{postcode}’ of #{log_total_count} total logs) (page 1 of 2) - Submit social housing lettings and sales data (CORE) - GOV.UK") end it "has title with pagination details for page 2" do get "/logs?search=#{logs[0].postcode_full}&page=2", headers: headers, params: {} - expect(page).to have_content("Logs (search results for ‘#{logs[0].postcode_full}’, page 2 of 2) - Submit social housing and sales data (CORE) - GOV.UK") + expect(page).to have_title("Your organisation (#{logs.count} logs matching ‘#{postcode}’ of #{log_total_count} total logs) (page 2 of 2) - Submit social housing lettings and sales data (CORE) - GOV.UK") end end @@ -539,7 +542,7 @@ RSpec.describe CaseLogsController, type: :request do end it "has pagination in the title" do - expect(page).to have_title("Logs (page 1 of 2) - Submit social housing and sales data (CORE) - GOV.UK") + expect(page).to have_title("Your organisation (Logs) (page 1 of 2) - Submit social housing lettings and sales data (CORE) - GOV.UK") end end @@ -564,7 +567,7 @@ RSpec.describe CaseLogsController, type: :request do end it "has pagination in the title" do - expect(page).to have_title("Logs (page 2 of 2) - Submit social housing and sales data (CORE) - GOV.UK") + expect(page).to have_title("Your organisation (Logs) (page 2 of 2) - Submit social housing lettings and sales data (CORE) - GOV.UK") end end end diff --git a/spec/requests/organisations_controller_spec.rb b/spec/requests/organisations_controller_spec.rb index a02be9ba2..2d231359c 100644 --- a/spec/requests/organisations_controller_spec.rb +++ b/spec/requests/organisations_controller_spec.rb @@ -467,12 +467,12 @@ RSpec.describe OrganisationsController, type: :request do it "has title with pagination details for page 1" do get "/organisations/#{organisation.id}/logs?search=#{logs[0].postcode_full}", headers: headers, params: {} - expect(page).to have_content("Your organisation (#{logs.count} logs matching ‘#{postcode}’ of #{log_total_count} total logs) (page 1 of 2) - Submit social housing lettings and sales data (CORE) - GOV.UK") + expect(page).to have_title("Your organisation (#{logs.count} logs matching ‘#{postcode}’ of #{log_total_count} total logs) (page 1 of 2) - Submit social housing lettings and sales data (CORE) - GOV.UK") end it "has title with pagination details for page 2" do get "/organisations/#{organisation.id}/logs?search=#{logs[0].postcode_full}&page=2", headers: headers, params: {} - expect(page).to have_content("Your organisation (#{logs.count} logs matching ‘#{postcode}’ of #{log_total_count} total logs) (page 2 of 2) - Submit social housing lettings and sales data (CORE) - GOV.UK") + expect(page).to have_title("Your organisation (#{logs.count} logs matching ‘#{postcode}’ of #{log_total_count} total logs) (page 2 of 2) - Submit social housing lettings and sales data (CORE) - GOV.UK") end end