Browse Source

Test type ahead functionality

pull/181/head
baarkerlounger 4 years ago
parent
commit
66be0c742d
  1. 27
      spec/features/form/accessible_autocomplete_spec.rb
  2. 4
      spec/features/form/check_answers_page_spec.rb
  3. 17
      spec/fixtures/forms/2021_2022.json
  4. 2
      spec/models/form_handler_spec.rb

27
spec/features/form/accessible_autocomplete_spec.rb

@ -0,0 +1,27 @@
require "rails_helper"
require_relative "helpers"
require_relative "../../request_helper"
RSpec.describe "Accessible Automcomplete" do
include Helpers
let(:user) { FactoryBot.create(:user) }
let(:case_log) do
FactoryBot.create(
:case_log,
:in_progress,
owning_organisation: user.organisation,
managing_organisation: user.organisation,
)
end
before do
RequestHelper.stub_http_requests
sign_in user
end
it "allows type ahead filtering", js: true do
visit("/logs/#{case_log.id}/accessible-select")
find("#case-log-la-field").click.native.send_keys("T", "h", "a", "n", :down, :enter)
expect(find("#case-log-la-field").value).to eq("Thanet")
end
end

4
spec/features/form/check_answers_page_spec.rb

@ -76,13 +76,13 @@ RSpec.describe "Form Check Answers Page" do
it "should have a change link for answered questions" do it "should have a change link for answered questions" do
visit("/logs/#{empty_case_log.id}/household-needs/check-answers") visit("/logs/#{empty_case_log.id}/household-needs/check-answers")
assert_selector "a", text: /Answer\z/, count: 4 assert_selector "a", text: /Answer\z/, count: 5
assert_selector "a", text: "Change", count: 0 assert_selector "a", text: "Change", count: 0
visit("/logs/#{empty_case_log.id}/accessibility-requirements") visit("/logs/#{empty_case_log.id}/accessibility-requirements")
check("case-log-accessibility-requirements-housingneeds-c-field") check("case-log-accessibility-requirements-housingneeds-c-field")
click_button("Save and continue") click_button("Save and continue")
visit("/logs/#{empty_case_log.id}/household-needs/check-answers") visit("/logs/#{empty_case_log.id}/household-needs/check-answers")
assert_selector "a", text: /Answer\z/, count: 3 assert_selector "a", text: /Answer\z/, count: 4
assert_selector "a", text: "Change", count: 1 assert_selector "a", text: "Change", count: 1
expect(page).to have_link("Change", href: "/logs/#{empty_case_log.id}/accessibility-requirements") expect(page).to have_link("Change", href: "/logs/#{empty_case_log.id}/accessibility-requirements")
end end

17
spec/fixtures/forms/2021_2022.json vendored

@ -185,6 +185,23 @@
} }
} }
}, },
"accessible_select": {
"questions": {
"la": {
"header": "Select options",
"hint_text": "Type ahead to filter the options",
"type": "select",
"check_answer_label": "Accessible Select",
"answer_options": {
"0": "Adur",
"1": "Lewisham",
"2": "Oxford",
"3": "Thanet",
"4": "York"
}
}
}
},
"condition_effects": { "condition_effects": {
"questions": { "questions": {
"condition_effects": { "condition_effects": {

2
spec/models/form_handler_spec.rb

@ -16,7 +16,7 @@ RSpec.describe FormHandler do
form_handler = FormHandler.instance form_handler = FormHandler.instance
form = form_handler.get_form(test_form_name) form = form_handler.get_form(test_form_name)
expect(form).to be_a(Form) expect(form).to be_a(Form)
expect(form.pages.count).to eq(27) expect(form.pages.count).to eq(28)
end end
end end

Loading…
Cancel
Save