Skip to content

Commit

Permalink
Merge pull request #4476 from alphagov/remove-autocomp-ab
Browse files Browse the repository at this point in the history
Homepage: Finish search autocomplete AB test
  • Loading branch information
kevindew authored Dec 11, 2024
2 parents 044b49d + 999e2fb commit 06d0019
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 51 deletions.
28 changes: 0 additions & 28 deletions app/controllers/concerns/search_autocomplete_ab_testable.rb

This file was deleted.

7 changes: 5 additions & 2 deletions app/controllers/homepage_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
class HomepageController < ContentItemsController
include Cacheable
include SearchAutocompleteAbTestable

slimmer_template "gem_layout_homepage"

Expand All @@ -11,7 +10,7 @@ def index
private

def search_component
if show_search_autocomplete_test?
if show_search_autocomplete?
"search_with_autocomplete"
else
"search"
Expand All @@ -22,4 +21,8 @@ def search_component
def publication_class
HomepagePresenter
end

def show_search_autocomplete?
true unless ENV["GOVUK_DISABLE_SEARCH_AUTOCOMPLETE"]
end
end
1 change: 0 additions & 1 deletion app/views/homepage/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<% content_for :extra_headers do %>
<link rel="canonical" href="<%= Frontend.govuk_website_root + root_path %>">
<meta name="description" content="<%= t("homepage.index.meta_description_new") %>">
<%= search_autocomplete_ab_test_variant.analytics_meta_tag.html_safe %>
<% end %>
<% content_for :title, t("homepage.index.intro_title.text") %>
<% content_for :body_classes, "homepage" %><%# The `homepage` body class is required for emergency banner. %>
Expand Down
35 changes: 15 additions & 20 deletions spec/system/homepage_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
RSpec.describe "Homepage" do
include GovukAbTesting::RspecHelpers

before { stub_content_store_has_item("/", schema: "special_route", links: {}) }

it "renders the homepage" do
Expand All @@ -12,29 +10,26 @@
expect(page).not_to have_css(".homepage-inverse-header__title")
end

context "search autocomplete AB test" do
it "does not render the search autocomplete on the A variant" do
with_variant(SearchAutocomplete: "A") do
visit "/"

expect(page).not_to have_css(".gem-c-search-with-autocomplete")
end
end

it "renders the search autocomplete on the B variant with the correct source URL" do
with_variant(SearchAutocomplete: "B") do
visit "/"
describe "search autocomplete" do
context "when autocomplete is enabled" do
it "renders the search with autocomplete component with the correct source URL" do
ClimateControl.modify GOVUK_DISABLE_SEARCH_AUTOCOMPLETE: nil do
visit "/"

expect(page).to have_css(".gem-c-search-with-autocomplete")
expect(page).to have_css("[data-source-url='http://www.dev.gov.uk/api/search/autocomplete.json']")
expect(page).to have_css(".gem-c-search-with-autocomplete")
expect(page).to have_css("[data-source-url='http://www.dev.gov.uk/api/search/autocomplete.json']")
end
end
end

it "does not render the search autocomplete on the Z variant" do
with_variant(SearchAutocomplete: "Z") do
visit "/"
context "when autocomplete is disabled" do
it "does not render the search with autocomplete component" do
ClimateControl.modify GOVUK_DISABLE_SEARCH_AUTOCOMPLETE: "1" do
visit "/"

expect(page).not_to have_css(".gem-c-search-with-autocomplete")
expect(page).to_not have_css(".gem-c-search-with-autocomplete")
expect(page).to have_css(".gem-c-search")
end
end
end
end
Expand Down

0 comments on commit 06d0019

Please sign in to comment.