Browse Source

Add scheme ID to the hint text

pull/2519/head
Kat 2 years ago committed by kosiakkatrina
parent
commit
94933f9ae1
  1. 2
      app/helpers/question_view_helper.rb
  2. 30
      spec/features/form/accessible_autocomplete_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

Loading…
Cancel
Save