Browse Source

CLDC-3562 Add scheme ID to the hint text (#2519)

* Add scheme ID to the hint text

* Fix flaky tests
pull/2522/head
kosiakkatrina 6 months ago committed by GitHub
parent
commit
6c03a6d203
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      app/helpers/question_view_helper.rb
  2. 30
      spec/features/form/accessible_autocomplete_spec.rb
  3. 2
      spec/models/sales_log_spec.rb

2
app/helpers/question_view_helper.rb

@ -34,7 +34,7 @@ module QuestionViewHelper
def answer_option_hint(resource)
return unless resource.instance_of?(Scheme)
[resource.primary_client_group, resource.secondary_client_group].compact.join(", ")
"(S#{resource.id})" + [resource.primary_client_group, resource.secondary_client_group].compact.join(", ")
end
def select_option_name(value)

30
spec/features/form/accessible_autocomplete_spec.rb

@ -55,6 +55,36 @@ RSpec.describe "Accessible Autocomplete" do
it "displays the placeholder text", js: true do
expect(find("#lettings-log-prevloc-field")["placeholder"]).to eq("Start typing to search")
end
context "and multiple schemes with same names", js: true do
let(:lettings_log) { FactoryBot.create(:lettings_log, :sh, assigned_to: user) }
let!(:schemes) { FactoryBot.create_list(:scheme, 2, owning_organisation_id: user.organisation_id, service_name: "Scheme", primary_client_group: "O", secondary_client_group: "O") }
before do
schemes.each do |scheme|
FactoryBot.create(:location, scheme:)
end
visit("/lettings-logs/#{lettings_log.id}/scheme")
end
it "allows selecting any scheme" do
find("#lettings-log-scheme-id-field").click.native.send_keys("s", "c", "h", :enter)
expect(find("#lettings-log-scheme-id-field").value).to match(/Scheme/)
click_button("Save and continue")
first_selected_scheme_id = lettings_log.reload.scheme_id
expect(schemes.map(&:id)).to include(first_selected_scheme_id)
visit("/lettings-logs/#{lettings_log.id}/scheme")
find("#lettings-log-scheme-id-field").click.native.send_keys("s", "c", "h", :down, :enter)
expect(find("#lettings-log-scheme-id-field").value).to match(/Scheme/)
click_button("Save and continue")
second_selected_scheme_id = lettings_log.reload.scheme_id
expect(schemes.map(&:id)).to include(lettings_log.reload.scheme_id)
expect(first_selected_scheme_id).not_to eq(second_selected_scheme_id)
end
end
end
context "when searching schemes" do

2
spec/models/sales_log_spec.rb

@ -173,7 +173,7 @@ RSpec.describe SalesLog, type: :model do
end
describe "#search_by" do
let!(:sales_log_to_search) { create(:sales_log, :completed) }
let!(:sales_log_to_search) { create(:sales_log, :completed, id: 193_285) }
it "allows searching using ID" do
result = described_class.search_by(sales_log_to_search.id.to_s)

Loading…
Cancel
Save