Skip to content

Commit

Permalink
Include </li> tag to make replacement safer
Browse files Browse the repository at this point in the history
We don't want to do the replacement in the B variant if the list item on
the page has any text after the link to the HMRC app.

For example, if the list item was

- in the HRMC app which is really good

We would not want the replacement to be

- in the HMRC app - watch a video about finding your UTR number in the app _which is really good_
  • Loading branch information
richardTowers committed Oct 6, 2023
1 parent ff0870c commit 25e5436
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/controllers/content_items_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def show
# situation. This is not a sustainable way of doing AB tests in the
# future.
@content_item.body.sub!(
/<li>\s*in\ the\s+<a\ href="[^"]*"><abbr\ title="[^"]+">HMRC<\/abbr>\s+app<\/a>/,
/<li>\s*in\ the\s+<a\ href="[^"]*"><abbr\ title="[^"]+">HMRC<\/abbr>\s+app<\/a>\s*<\/li>/,
'<li>in the <a href="https://www.gov.uk/guidance/download-the-hmrc-app"><abbr title="HM Revenue and Customs">HMRC</abbr> app</a> - watch a <a href="https://www.youtube.com/watch?v=LXw9ily9rTo">video about finding your UTR number in the app</a>',
)
end
Expand Down
2 changes: 1 addition & 1 deletion test/controllers/content_items_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ class ContentItemsControllerTest < ActionController::TestCase
test "AB test replaces content on the find-utr-number page" do
content_item = content_store_has_schema_example("answer", "answer")
content_item["base_path"] = "/find-utr-number"
content_item["details"]["body"] = '<li>in the <a href=""><abbr title="HM Revenue and Customs">HMRC</abbr> app</a>'
content_item["details"]["body"] = "<li>in the <a href=\"\"><abbr title=\"HM Revenue and Customs\">HMRC</abbr> app</a>\n</li>"
content_item["locale"] = "en"

stub_content_store_has_item(content_item["base_path"], content_item)
Expand Down

0 comments on commit 25e5436

Please sign in to comment.