From 59732f5259548be7094d407e47e51772b61370cc Mon Sep 17 00:00:00 2001 From: J G <7750475+moarpheus@users.noreply.github.com> Date: Thu, 21 Jul 2022 15:34:24 +0100 Subject: [PATCH] Correct boldness in scheme search (#768) * fixed * fixed * fixed specs and no brackets --- app/frontend/modules/search.js | 2 +- app/models/scheme.rb | 2 +- spec/features/form/accessible_autocomplete_spec.rb | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) 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