diff --git a/app/frontend/modules/search.js b/app/frontend/modules/search.js index 5e22c0cf5..02d776b19 100644 --- a/app/frontend/modules/search.js +++ b/app/frontend/modules/search.js @@ -110,7 +110,7 @@ export const sort = (query, options) => { export const suggestion = (value, options) => { const option = options.find((o) => o.name === value) if (option) { - const html = option.append ? `${value} ${option.append}` : `${value}` + const html = option.append ? `${value} ${option.append}` : `${value}` return option.hint ? `${html}
${option.hint}
` : html } else { return 'No results found' diff --git a/app/models/scheme.rb b/app/models/scheme.rb index 86baec352..901481966 100644 --- a/app/models/scheme.rb +++ b/app/models/scheme.rb @@ -164,7 +164,7 @@ class Scheme < ApplicationRecord end def appended_text - "(#{locations.count { |location| location.startdate.blank? || location.startdate <= Time.zone.today }} locations)" + "#{locations.count { |location| location.startdate.blank? || location.startdate <= Time.zone.today }} locations" end def hint diff --git a/spec/features/form/accessible_autocomplete_spec.rb b/spec/features/form/accessible_autocomplete_spec.rb index e948056b4..1a9536d58 100644 --- a/spec/features/form/accessible_autocomplete_spec.rb +++ b/spec/features/form/accessible_autocomplete_spec.rb @@ -76,7 +76,8 @@ RSpec.describe "Accessible Automcomplete" do it "displays appended text next to the options", js: true do find("#case-log-scheme-id-field").click.native.send_keys("w", "6", :down, :enter) - expect(find(".autocomplete__option__append", visible: :hidden, text: /(2 locations)/)).to be_present + expect(find(".autocomplete__option__append", visible: :hidden, text: scheme.service_name)).to be_present + expect(find("span", visible: :hidden, text: "2 locations")).to be_present end it "displays hint text under the options", js: true do