From 403c47f8ca1d675e4fc2048894d9a431acf2196c Mon Sep 17 00:00:00 2001 From: Carolyn Cole Date: Wed, 8 Nov 2023 15:24:16 -0500 Subject: [PATCH] Adding a test for the advanced search and json dls being on with the algortihm swapping This shows that the other two features take presidence Co-authored-by: James R. Griffin III --- spec/requests/request_spec.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/spec/requests/request_spec.rb b/spec/requests/request_spec.rb index e0494c89f..a20890e57 100644 --- a/spec/requests/request_spec.rb +++ b/spec/requests/request_spec.rb @@ -566,5 +566,20 @@ expect(json["data"][0]["attributes"]["title"]).to eq "Reconstructing the Vitruvian Scorpio: An Engineering Analysis of Roman Field Artillery" end end + + context "advanced search and jsonld are enabled" do + before do + allow(Flipflop).to receive(:json_query_dsl?).and_return(true) + allow(Flipflop).to receive(:view_components_advanced_search?).and_return(true) + end + + # TODO: what should this really do? Should the advanced search and jsonld get turned off when an algorithm is swapped + # Should we see if we can combine the search handlers by adding a query parameter, or make a combined handler that has both? + it "retuns the jsonld result not the engineering result" do + get "/catalog.json?utf8=%E2%9C%93&clause%5B0%5D%5Bfield%5D=all_fields&clause%5B0%5D%5Bquery%5D=roman&clause%5B1%5D%5Bop%5D=must&clause%5B1%5D%5Bfield%5D=author&clause%5B1%5D%5Bquery%5D=&clause%5B2%5D%5Bop%5D=must&clause%5B2%5D%5Bfield%5D=title&clause%5B2%5D%5Bquery%5D=&range%5Bpub_date_start_sort%5D%5Bbegin%5D=&range%5Bpub_date_start_sort%5D%5Bend%5D=&sort=score+desc%2C+pub_date_start_sort+desc%2C+title_sort+asc&commit=Search&search_algorithm=engineering" + json = JSON.parse(response.body) + expect(json["data"][0]["attributes"]["title"]).to eq "Ogonek : roman / ." + end + end end end