From 547ed99bd98f007ec17aef2ebf48edb65d90b232 Mon Sep 17 00:00:00 2001 From: Jessica Jones Date: Fri, 22 Dec 2023 22:33:34 +0000 Subject: [PATCH] Fix skipped tests I think there were a couple of issues: using the incorrect fixture, and needing to add the placeholder string to the parts key --- .../content_items_controller_test.rb | 42 ++++++++++++------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/test/controllers/content_items_controller_test.rb b/test/controllers/content_items_controller_test.rb index 4f83985978..6c3535adbf 100644 --- a/test/controllers/content_items_controller_test.rb +++ b/test/controllers/content_items_controller_test.rb @@ -370,7 +370,6 @@ class ContentItemsControllerTest < ActionController::TestCase content_item["details"]["body"] = "{{ab_test_sa_video_stop_self_employed}}" stub_content_store_has_item(content_item["base_path"], content_item) - request.headers["HTTP_GOVUK_ABTEST_SAVIDEOSTOPSELFEMPLOYED"] = nil get :show, params: { path: path_for(content_item) } @@ -500,10 +499,15 @@ class ContentItemsControllerTest < ActionController::TestCase end test "AB test replaces content on the pay-weekly-monthly page with default" do - skip("Needs fixing") - content_item = content_store_has_schema_example("answer", "answer") - content_item["base_path"] = "/pay-self-assessment-tax-bill/pay-weekly-monthly" - content_item["details"]["body"] = "{{ab_test_sa_video_pay_bill}}" + # skip("Needs fixing") + content_item = govuk_content_schema_example("guide", "guide") + content_item["base_path"] = "/pay-self-assessment-tax-bill" + content_item["details"]["parts"] = [] + parts = { + "body" => "{{ab_test_sa_video_pay_bill}}", + "slug" => "pay-weekly-monthly", + } + content_item["details"]["parts"] << parts stub_content_store_has_item(content_item["base_path"], content_item) @@ -516,10 +520,15 @@ class ContentItemsControllerTest < ActionController::TestCase end test "AB test replaces content on the pay-weekly-monthly page with Variant A" do - skip("Needs fixing") - content_item = content_store_has_schema_example("answer", "answer") - content_item["base_path"] = "/pay-self-assessment-tax-bill/pay-weekly-monthly" - content_item["details"]["body"] = "{{ab_test_sa_video_pay_bill}}" + # skip("Needs fixing") + content_item = govuk_content_schema_example("guide", "guide") + content_item["base_path"] = "/pay-self-assessment-tax-bill" + content_item["details"]["parts"] = [] + parts = { + "body" => "{{ab_test_sa_video_pay_bill}}", + "slug" => "pay-weekly-monthly", + } + content_item["details"]["parts"] << parts stub_content_store_has_item(content_item["base_path"], content_item) @@ -532,20 +541,23 @@ class ContentItemsControllerTest < ActionController::TestCase end test "AB test replaces content on the pay-weekly-monthly page with Variant B" do - skip("Needs fixing") - content_item = content_store_has_schema_example("guide", "guide") + # skip("Needs fixing") + content_item = govuk_content_schema_example("guide", "guide") content_item["base_path"] = "/pay-self-assessment-tax-bill" - content_item["details"]["body"] = "{{ab_test_sa_video_pay_bill}}" - content_item["current_part_body"] = "{{ab_test_sa_video_pay_bill}}" + content_item["details"]["parts"] = [] + parts = { + "body" => "{{ab_test_sa_video_pay_bill}}", + "slug" => "pay-weekly-monthly", + } + content_item["details"]["parts"] << parts stub_content_store_has_item(content_item["base_path"], content_item) - request.headers["HTTP_GOVUK_ABTEST_SAVIDEOPAYBILL"] = "B" get :show, params: { path: path_for(content_item) } assert_response :success assert_no_match "{{ab_test_sa_video_pay_bill}}", response.body - assert_includes I18n.t("ab_tests.sa_video_pay_bill.B").to_s, response.body + assert_match I18n.t("ab_tests.sa_video_pay_bill.B").to_s, response.body end def path_for(content_item, locale = nil)