From 88dcdb326f89d46942ed30de5222490a9fe2dba4 Mon Sep 17 00:00:00 2001 From: Matthew Phelan Date: Mon, 20 Sep 2021 14:24:52 +0100 Subject: [PATCH] back link tests added --- app/views/form/questions/tenant_code.html.erb | 6 +----- spec/features/case_log_spec.rb | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/views/form/questions/tenant_code.html.erb b/app/views/form/questions/tenant_code.html.erb index 9cc6e9cdb..eebb74aaa 100644 --- a/app/views/form/questions/tenant_code.html.erb +++ b/app/views/form/questions/tenant_code.html.erb @@ -1,9 +1,5 @@ -<% previous_question = Form.previous_question("tenant_code") %> -<%= govuk_back_link href: "/case_logs/#{case_log_id}/#{previous_question}" do %> - Back -<% end %> - <%= turbo_frame_tag "case_log_form", target: "_top" do %> + <%= render GovukComponent::BackLinkComponent.new(href: "/case_logs/#{case_log_id}", text: 'Back') do %><% end %> <%= form_with action: '/case_logs', method: "next_question", builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %> <%= f.govuk_text_field :tenant_code, hint: { text: "More detail" }, diff --git a/spec/features/case_log_spec.rb b/spec/features/case_log_spec.rb index 8e6e16e2b..7b24baa74 100644 --- a/spec/features/case_log_spec.rb +++ b/spec/features/case_log_spec.rb @@ -39,4 +39,18 @@ RSpec.describe "Test Features" do end end end + + describe "Back link directs correctly" do + it "go back to tasklist page from tenant code" do + visit("/case_logs/#{id}/tenant_code") + click_link(text: 'Back') + expect(page).to have_content("Tasklist for log #{id}") + end + + it "go back to tenant code page from tenant age page" do + visit("/case_logs/#{id}/tenant_age") + click_link(text: 'Back') + expect(page).to have_field("tenant-code-field") + end + end end