From 7148f1978e12c8f462a31dc05fa4ba4b5bbd9d4b Mon Sep 17 00:00:00 2001 From: Mateusz Grotek Date: Fri, 14 Feb 2025 17:00:19 +0000 Subject: [PATCH] Revert "Add AB test for Contents list" This reverts commit 731b245641645e25cd932d89a1f76889c83279d5. --- app/controllers/content_items_controller.rb | 10 --- app/helpers/contents_list_ab_testable.rb | 61 ------------------- app/views/content_items/guide.html.erb | 4 +- .../content_items_controller_test.rb | 42 ------------- 4 files changed, 2 insertions(+), 115 deletions(-) delete mode 100644 app/helpers/contents_list_ab_testable.rb diff --git a/app/controllers/content_items_controller.rb b/app/controllers/content_items_controller.rb index ae1eebd5f..28092357a 100644 --- a/app/controllers/content_items_controller.rb +++ b/app/controllers/content_items_controller.rb @@ -1,7 +1,6 @@ require "slimmer/headers" class ContentItemsController < ApplicationController - include ContentsListAbTestable include GovukPersonalisation::ControllerConcern include Slimmer::Headers include Slimmer::Template @@ -16,9 +15,6 @@ class ContentItemsController < ApplicationController rescue_from PresenterBuilder::SpecialRouteReturned, with: :error_notfound rescue_from PresenterBuilder::GovernmentReturned, with: :error_notfound - helper_method :contents_list_variant - helper_method :step_by_step_page_under_test? - attr_accessor :content_item, :taxonomy_navigation content_security_policy do |p| @@ -36,10 +32,6 @@ def show elsif is_history_page? show_history_page else - if step_by_step_page_under_test? - set_contents_list_response_header - end - set_guide_draft_access_token if @content_item.is_a?(GuidePresenter) render_template end @@ -65,8 +57,6 @@ def service_sign_in_options private - helper_method :show_contents_list_ab_test? - def is_history_page? @content_item.document_type == "history" end diff --git a/app/helpers/contents_list_ab_testable.rb b/app/helpers/contents_list_ab_testable.rb deleted file mode 100644 index bf48befde..000000000 --- a/app/helpers/contents_list_ab_testable.rb +++ /dev/null @@ -1,61 +0,0 @@ -module ContentsListAbTestable - ALLOWED_VARIANTS = %w[A B Z].freeze - - AB_TEST_PAGES = [ - # Help paying for childcare - "/help-with-childcare-costs", - "/help-with-childcare-costs/free-childcare-and-education-for-3-to-4-year-olds", - "/help-with-childcare-costs/free-childcare-2-year-olds-claim-benefits", - "/help-with-childcare-costs/tax-credits", - "/help-with-childcare-costs/universal-credit", - "/help-with-childcare-costs/childcare-vouchers", - "/help-with-childcare-costs/support-while-you-study", - # What to do after someone dies - "/after-a-death", - "/after-a-death/when-a-death-is-reported-to-a-coroner", - "/after-a-death/death-abroad", - "/after-a-death/organisations-you-need-to-contact-and-tell-us-once", - "/after-a-death/report-without-tell-us-once", - "/after-a-death/arrange-the-funeral", - "/after-a-death/if-a-child-or-baby-dies", - "/after-a-death/bereavement-help-and-support", - # Become a sole trader - "/become-sole-trader", - "/become-sole-trader/choose-your-business-name", - "/become-sole-trader/register-sole-trader", - # Set up a private limited company - "/limited-company-formation", - "/limited-company-formation/choose-company-name", - "/limited-company-formation/company-address", - "/limited-company-formation/appoint-directors-and-company-secretaries", - "/limited-company-formation/shareholders", - "/limited-company-formation/memorandum-and-articles-of-association", - "/limited-company-formation/register-your-company", - "/limited-company-formation/add-corporation-tax-services-to-business-tax-account", - ].freeze - - def contents_list_test - @contents_list_test ||= GovukAbTesting::AbTest.new( - "ContentsList", - allowed_variants: ALLOWED_VARIANTS, - control_variant: "Z", - ) - end - - def contents_list_variant - contents_list_test.requested_variant(request.headers) - end - - def set_contents_list_response_header - contents_list_variant.configure_response(response) - end - - def show_contents_list_ab_test? - var_b = contents_list_variant.variant?("B") - step_by_step_page_under_test? && var_b - end - - def step_by_step_page_under_test? - AB_TEST_PAGES.include? request.path - end -end diff --git a/app/views/content_items/guide.html.erb b/app/views/content_items/guide.html.erb index 62ab020d8..4c9230a74 100644 --- a/app/views/content_items/guide.html.erb +++ b/app/views/content_items/guide.html.erb @@ -5,7 +5,7 @@ canonical_url: @content_item.canonical_url, body: @content_item.has_parts? ? @content_item.current_part_body : nil ) %> - <%= contents_list_variant.analytics_meta_tag.html_safe if step_by_step_page_under_test? %> + <%= @requested_variant.analytics_meta_tag.html_safe if @requested_variant.present? %> <% end %> @@ -25,7 +25,7 @@ font_size: "xl", margin_bottom: 8 } %> - <% if show_contents_list_ab_test? || @content_item.show_guide_navigation? %> + <% if @content_item.show_guide_navigation? %> <%= render "govuk_publishing_components/components/skip_link", { text: t("guide.skip_contents"), href: "#guide-contents" diff --git a/test/controllers/content_items_controller_test.rb b/test/controllers/content_items_controller_test.rb index 7ae83455a..d7be54947 100644 --- a/test/controllers/content_items_controller_test.rb +++ b/test/controllers/content_items_controller_test.rb @@ -368,48 +368,6 @@ class ContentItemsControllerTest < ActionController::TestCase assert_equal "true", @response.headers[Slimmer::Headers::REMOVE_SEARCH_HEADER] end - test "Contents List AB test variant A" do - content_item = content_store_has_schema_example("guide", "guide-with-step-navs") - content_item["base_path"] = "/help-with-childcare-costs/support-while-you-study" - content_item["details"]["hide_chapter_navigation"] = true - - stub_content_store_has_item(content_item["base_path"], content_item) - - with_variant ContentsList: "A" do - get :show, params: { path: "help-with-childcare-costs/support-while-you-study" } - assert_response :success - assert_not response.body.include?("contents-list") - end - end - - test "Contents List AB test variant B" do - content_item = content_store_has_schema_example("guide", "guide-with-step-navs") - content_item["base_path"] = "/help-with-childcare-costs/support-while-you-study" - content_item["details"]["hide_chapter_navigation"] = true - - stub_content_store_has_item(content_item["base_path"], content_item) - - with_variant ContentsList: "B" do - get :show, params: { path: "help-with-childcare-costs/support-while-you-study" } - assert_response :success - assert response.body.include?("contents-list") - end - end - - test "Contents List AB test variant Z" do - content_item = content_store_has_schema_example("guide", "guide-with-step-navs") - content_item["base_path"] = "/help-with-childcare-costs/support-while-you-study" - content_item["details"]["hide_chapter_navigation"] = true - - stub_content_store_has_item(content_item["base_path"], content_item) - - with_variant ContentsList: "Z" do - get :show, params: { path: "help-with-childcare-costs/support-while-you-study" } - assert_response :success - assert_not response.body.include?("contents-list") - end - end - def path_for(content_item, locale = nil) base_path = content_item["base_path"].sub(/^\//, "") base_path.gsub!(/\.#{locale}$/, "") if locale