Browse Source

Correct boldness in scheme search (#768)

* fixed

* fixed

* fixed specs and no brackets
pull/772/head
J G 2 years ago committed by GitHub
parent
commit
59732f5259
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/frontend/modules/search.js
  2. 2
      app/models/scheme.rb
  3. 3
      spec/features/form/accessible_autocomplete_spec.rb

2
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 ? `<span>${value}</span> <span class="autocomplete__option__append">${option.append}</span>` : `<span>${value}</span>`
const html = option.append ? `<span class="autocomplete__option__append">${value}</span> <span>${option.append}</span>` : `<span>${value}</span>`
return option.hint ? `${html}<div class="autocomplete__option__hint">${option.hint}</div>` : html
} else {
return '<span>No results found</span>'

2
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

3
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

Loading…
Cancel
Save