From 3c0e6f68766c3a0ea425a8dcf095725d1a96b83f Mon Sep 17 00:00:00 2001 From: Yetrina Battad Date: Fri, 15 Sep 2023 16:05:40 +1000 Subject: [PATCH] feat: add button to return to search from request --- app/views/request/success.html.erb | 3 +++ spec/features/requests_spec.rb | 32 ++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/app/views/request/success.html.erb b/app/views/request/success.html.erb index 8add8541..926b6e18 100644 --- a/app/views/request/success.html.erb +++ b/app/views/request/success.html.erb @@ -17,6 +17,9 @@
    + <% if current_search_session %> +
  • <%= link_back_to_catalog class: 'btn btn-outline-secondary btn-sm back-to-results arrow-before' %>
  • + <% end %>
  • <%= link_to t("requesting.btn_back_to_item"), :back, class: "btn btn-outline-secondary btn-sm arrow-before" %>
diff --git a/spec/features/requests_spec.rb b/spec/features/requests_spec.rb index 64d9f60c..a14dedb1 100644 --- a/spec/features/requests_spec.rb +++ b/spec/features/requests_spec.rb @@ -248,6 +248,38 @@ expect(page).to have_link(I18n.t("requesting.btn_back_to_item"), href: "javascript:history.back()") end + context "when a catalogue search has been performed" do + let(:current_search) { Search.create(query_params: {q: ""}) } + + before do + allow_any_instance_of(RequestController).to receive(:current_search_session).and_return(current_search) + end + + it "renders the 'Back to search' button" do + visit solr_document_request_success_path( + solr_document_id: solr_document_id, + instance: instance_id, + holdings: holdings_id, + item: item_id + ) + + expect(page).to have_link(I18n.t("blacklight.back_to_search", href: "/catalog")) + end + end + + context "when a catalogue search has not been performed" do + it "does not render the 'Back to search' button" do + visit solr_document_request_success_path( + solr_document_id: solr_document_id, + instance: instance_id, + holdings: holdings_id, + item: item_id + ) + + expect(page).not_to have_link(I18n.t("blacklight.back_to_search")) + end + end + context "when user has reached their request limit" do it "renders the request limit error" do WebMock.stub_request(:get, /catservices.test\/catalogue-services\/folio\/user\/(.*)\/requestLimitReached/)