|
|
|
@ -13,6 +13,15 @@ RSpec.describe "Form Navigation" do
|
|
|
|
|
created_by: user, |
|
|
|
|
) |
|
|
|
|
end |
|
|
|
|
let(:empty_case_log) do |
|
|
|
|
FactoryBot.create( |
|
|
|
|
:case_log, |
|
|
|
|
owning_organisation: user.organisation, |
|
|
|
|
managing_organisation: user.organisation, |
|
|
|
|
created_by: user, |
|
|
|
|
) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
let(:id) { case_log.id } |
|
|
|
|
let(:question_answers) do |
|
|
|
|
{ |
|
|
|
@ -47,11 +56,23 @@ RSpec.describe "Form Navigation" do
|
|
|
|
|
pages = question_answers.map { |_key, val| val[:path] } |
|
|
|
|
pages[0..-2].each_with_index do |val, index| |
|
|
|
|
visit("/logs/#{id}/#{val}") |
|
|
|
|
click_button("Save and continue") |
|
|
|
|
click_link("Skip for now") |
|
|
|
|
expect(page).to have_current_path("/logs/#{id}/#{pages[index + 1]}") |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "a question page has a Skip for now link that lets you move on to the next question without inputting anything" do |
|
|
|
|
visit("logs/#{empty_case_log.id}/tenant-code-test") |
|
|
|
|
click_link(text: "Skip for now") |
|
|
|
|
expect(page).to have_current_path("/logs/#{empty_case_log.id}/person-1-age") |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "routes to check answers when skipping on the last page in the form" do |
|
|
|
|
visit("logs/#{empty_case_log.id}/propcode") |
|
|
|
|
click_link(text: "Skip for now") |
|
|
|
|
expect(page).to have_current_path("/logs/#{empty_case_log.id}/household-characteristics/check-answers") |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe "Back link directs correctly", js: true do |
|
|
|
|
it "go back to tasklist page from tenant code" do |
|
|
|
|
visit("/logs/#{id}") |
|
|
|
@ -89,4 +110,57 @@ RSpec.describe "Form Navigation" do
|
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe "Editing a log" do |
|
|
|
|
it "a question page has a link allowing you to cancel your input and return to the check answers page" do |
|
|
|
|
visit("logs/#{id}/tenant-code-test?referrer=check_answers") |
|
|
|
|
click_link(text: "Cancel") |
|
|
|
|
expect(page).to have_current_path("/logs/#{id}/setup/check-answers") |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when clicking save and continue on a mandatory question with no input" do |
|
|
|
|
let(:id) { empty_case_log.id } |
|
|
|
|
|
|
|
|
|
it "shows a validation error on radio questions" do |
|
|
|
|
visit("/logs/#{id}/renewal") |
|
|
|
|
click_button("Save and continue") |
|
|
|
|
expect(page).to have_selector("#error-summary-title") |
|
|
|
|
expect(page).to have_selector("#case-log-renewal-error") |
|
|
|
|
expect(page).to have_title("Error") |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "shows a validation error on date questions" do |
|
|
|
|
visit("/logs/#{id}/tenancy-start-date") |
|
|
|
|
click_button("Save and continue") |
|
|
|
|
expect(page).to have_selector("#error-summary-title") |
|
|
|
|
expect(page).to have_selector("#case-log-startdate-error") |
|
|
|
|
expect(page).to have_title("Error") |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when the page has a main and conditional question" do |
|
|
|
|
context "when the conditional question is required but not answered" do |
|
|
|
|
it "shows a validation error for the conditional question" do |
|
|
|
|
visit("/logs/#{id}/armed-forces") |
|
|
|
|
choose("case-log-armedforces-1-field", allow_label_click: true) |
|
|
|
|
click_button("Save and continue") |
|
|
|
|
expect(page).to have_selector("#error-summary-title") |
|
|
|
|
expect(page).to have_selector("#case-log-leftreg-error") |
|
|
|
|
expect(page).to have_title("Error") |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when clicking save and continue on an optional question with no input" do |
|
|
|
|
let(:id) { empty_case_log.id } |
|
|
|
|
|
|
|
|
|
it "does not show a validation error" do |
|
|
|
|
visit("/logs/#{id}/tenant-code") |
|
|
|
|
click_button("Save and continue") |
|
|
|
|
expect(page).not_to have_selector("#error-summary-title") |
|
|
|
|
expect(page).not_to have_title("Error") |
|
|
|
|
expect(page).to have_current_path("/logs/#{id}/property-reference") |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|