From 1255a8842368e3dda74198de21ace93e08955128 Mon Sep 17 00:00:00 2001 From: Jessica Jones Date: Wed, 21 Aug 2024 14:46:04 +0100 Subject: [PATCH 1/4] Prepare locale file for popular task data Popular tasks are currently present on business and benefits pages only. As part of our AB test, we will be adding 3 popular tasks to all level 2 browse pages. This commit preps the file for the incoming data. govuk-docker-run rake translation:add_missing has not been run - so the keys are missing from other locale files. This is intentional. Browse pages are not currently translated, and there is no intention of implementing translations. This AB test code is temporary and will be removed in a few weeks. Adding empty keys will just make the diff harder to review and reverting the code more time consuming. --- config/locales/en/browse.yml | 226 ++++++++++++++++++++++++++++ spec/lib/locales_validation_spec.rb | 1 + 2 files changed, 227 insertions(+) diff --git a/config/locales/en/browse.yml b/config/locales/en/browse.yml index 47fe074ec..a1b631aa0 100644 --- a/config/locales/en/browse.yml +++ b/config/locales/en/browse.yml @@ -2,6 +2,21 @@ en: browse: popular_links: + abroad: + variant_a: + - title: + url: + - title: + url: + - title: + url: + variant_b: + - title: + url: + - title: + url: + - title: + url: benefits: control: - title: Check benefits and financial support you can get @@ -9,9 +24,32 @@ en: variant_a: - title: url: + - title: + url: + - title: + url: variant_b: - title: url: + - title: + url: + - title: + url: + births-deaths-marriages: + variant_a: + - title: + url: + - title: + url: + - title: + url: + variant_b: + - title: + url: + - title: + url: + - title: + url: business: control: - title: "HMRC online services: sign in or set up an account" @@ -23,9 +61,197 @@ en: variant_a: - title: url: + - title: + url: + - title: + url: + variant_b: + - title: + url: + - title: + url: + - title: + url: + childcare-parenting: + variant_a: + - title: + url: + - title: + url: + - title: + url: + variant_b: + - title: + url: + - title: + url: + - title: + url: + citizenship: + variant_a: + - title: + url: + - title: + url: + - title: + url: + variant_b: + - title: + url: + - title: + url: + - title: + url: + disabilities: + variant_a: + - title: + url: + - title: + url: + - title: + url: + variant_b: + - title: + url: + - title: + url: + - title: + url: + driving: + variant_a: + - title: + url: + - title: + url: + - title: + url: + variant_b: + - title: + url: + - title: + url: + - title: + url: + education: + variant_a: + - title: + url: + - title: + url: + - title: + url: + variant_b: + - title: + url: + - title: + url: + - title: + url: + employing-people: + variant_a: + - title: + url: + - title: + url: + - title: + url: + variant_b: + - title: + url: + - title: + url: + - title: + url: + environment-countryside: + variant_a: + - title: + url: + - title: + url: + - title: + url: + variant_b: + - title: + url: + - title: + url: + - title: + url: + housing-local-services: + variant_a: + - title: + url: + - title: + url: + - title: + url: + variant_b: + - title: + url: + - title: + url: + - title: + url: + justice: + variant_a: + - title: + url: + - title: + url: + - title: + url: variant_b: - title: url: + - title: + url: + - title: + url: + tax: + variant_a: + - title: + url: + - title: + url: + - title: + url: + variant_b: + - title: + url: + - title: + url: + - title: + url: + visas-immigration: + variant_a: + - title: + url: + - title: + url: + - title: + url: + variant_b: + - title: + url: + - title: + url: + - title: + url: + working: + variant_a: + - title: + url: + - title: + url: + - title: + url: + variant_b: + - title: + url: + - title: + url: + - title: + url: all_categories: All categories popular_tasks: Popular tasks topics: Topics diff --git a/spec/lib/locales_validation_spec.rb b/spec/lib/locales_validation_spec.rb index 12527f8d0..dbdb21c99 100755 --- a/spec/lib/locales_validation_spec.rb +++ b/spec/lib/locales_validation_spec.rb @@ -5,6 +5,7 @@ roles.heading organisations.type organisations.works_with_statement + browse.popular_links ] checker = RailsTranslationManager::LocaleChecker.new("config/locales/*/*.yml", skip_validation) expect(checker.validate_locales).to be_truthy From ccfaf7163995f67ac5cbb51aec92cb87bd91b2b7 Mon Sep 17 00:00:00 2001 From: Jessica Jones Date: Wed, 21 Aug 2024 17:49:45 +0100 Subject: [PATCH 2/4] Add variant A links --- app/helpers/browse_helper.rb | 2 +- config/locales/en/browse.yml | 192 +++++++++++----------- spec/features/mainstream_browsing_spec.rb | 74 ++------- 3 files changed, 114 insertions(+), 154 deletions(-) diff --git a/app/helpers/browse_helper.rb b/app/helpers/browse_helper.rb index 444af21f6..8a0c1d259 100644 --- a/app/helpers/browse_helper.rb +++ b/app/helpers/browse_helper.rb @@ -4,7 +4,7 @@ def variant_a_popular_links?(slug) end def variant_a_popular_links(slug) - I18n.t("#{slug}.control", scope: "browse.popular_links") + I18n.t("#{slug}.variant_a", scope: "browse.popular_links") end def variant_b_popular_links?(slug) diff --git a/config/locales/en/browse.yml b/config/locales/en/browse.yml index a1b631aa0..fd4e4e677 100644 --- a/config/locales/en/browse.yml +++ b/config/locales/en/browse.yml @@ -4,12 +4,12 @@ en: popular_links: abroad: variant_a: - - title: - url: - - title: - url: - - title: - url: + - title: Get access to your eVisa + url: /get-access-evisa + - title: Track your passport application + url: /track-passport-application + - title: Online immigration status (eVisa) + url: /guidance/online-immigration-status-evisa variant_b: - title: url: @@ -22,12 +22,12 @@ en: - title: Check benefits and financial support you can get url: /check-benefits-financial-support variant_a: - - title: - url: - - title: - url: - - title: - url: + - title: Universal Credit + url: /universal-credit + - title: Sign in to your Universal Credit account + url: /sign-in-universal-credit + - title: Child Benefit + url: /child-benefit variant_b: - title: url: @@ -37,12 +37,12 @@ en: url: births-deaths-marriages: variant_a: - - title: - url: - - title: - url: - - title: - url: + - title: Order a birth, death, marriage or civil partnership certificate + url: /order-copy-birth-death-marriage-certificate + - title: Research your family history using the General Register Office + url: /research-family-history + - title: Search probate records for documents and wills (England and Wales) + url: /search-will-probate variant_b: - title: url: @@ -59,12 +59,12 @@ en: - title: "Pay employers' PAYE" url: /pay-paye-tax variant_a: - - title: - url: - - title: - url: - - title: - url: + - title: Searching the Companies House register + url: /guidance/search-the-companies-house-register + - title: Get information about a company + url: /get-information-about-a-company + - title: What a sole trader is + url: /become-sole-trader variant_b: - title: url: @@ -74,12 +74,12 @@ en: url: childcare-parenting: variant_a: - - title: - url: - - title: - url: - - title: - url: + - title: Sign in to your childcare account + url: /sign-in-childcare-account + - title: Child Benefit + url: /child-benefit + - title: Child Benefit when your child turns 16 + url: /child-benefit-16-19 variant_b: - title: url: @@ -89,12 +89,12 @@ en: url: citizenship: variant_a: - - title: - url: - - title: - url: - - title: - url: + - title: "View and prove your immigration status: get a share code" + url: /view-prove-immigration-status + - title: Get access to your eVisa + url: /get-access-evisa + - title: Apply to the EU Settlement Scheme (settled and pre-settled status) + url: /settled-status-eu-citizens-families variant_b: - title: url: @@ -104,12 +104,12 @@ en: url: disabilities: variant_a: - - title: - url: - - title: - url: - - title: - url: + - title: Apply for or renew a Blue Badge + url: /apply-blue-badge + - title: Disability Living Allowance (DLA) for children + url: /disability-living-allowance-children + - title: Personal Independence Payment (PIP) + url: /pip variant_b: - title: url: @@ -119,12 +119,12 @@ en: url: driving: variant_a: - - title: - url: - - title: - url: - - title: - url: + - title: Apply for your first provisional driving licence + url: /apply-first-provisional-driving-licence + - title: Change the address on your driving licence + url: /change-address-driving-licence + - title: Book and manage driving and riding tests for your pupils + url: /book-pupil-driving-test variant_b: - title: url: @@ -134,12 +134,12 @@ en: url: education: variant_a: - - title: - url: - - title: - url: - - title: - url: + - title: Student visa + url: /student-visa + - title: Free courses for jobs + url: /guidance/free-courses-for-jobs + - title: Child Benefit when your child turns 16 + url: /child-benefit-16-19 variant_b: - title: url: @@ -149,12 +149,12 @@ en: url: employing-people: variant_a: - - title: - url: - - title: - url: - - title: - url: + - title: Find a job + url: /find-a-job + - title: Find an apprenticeship + url: /apply-apprenticeship + - title: Prove your right to work to an employer + url: /prove-right-to-work variant_b: - title: url: @@ -164,12 +164,12 @@ en: url: environment-countryside: variant_a: - - title: - url: - - title: - url: - - title: - url: + - title: "Hedgerow management rules: cutting and trimming" + url: /guidance/hedgerow-management-rules-cutting-and-trimming + - title: Find out your rubbish collection day + url: /rubbish-collection-day + - title: Report a pothole + url: /report-pothole variant_b: - title: url: @@ -179,12 +179,12 @@ en: url: housing-local-services: variant_a: - - title: - url: - - title: - url: - - title: - url: + - title: Search for land and property information + url: /search-property-information-land-registry + - title: Housing Benefit + url: /housing-benefit + - title: Tell HMRC when you change your address + url: /tell-hmrc-change-address variant_b: - title: url: @@ -194,12 +194,12 @@ en: url: justice: variant_a: - - title: - url: - - title: - url: - - title: - url: + - title: Request a basic DBS check + url: /request-copy-criminal-record + - title: "DBS checks: detailed guidance" + url: /government/collections/dbs-checking-service-guidance--2 + - title: Find a job + url: /find-a-job variant_b: - title: url: @@ -209,12 +209,12 @@ en: url: tax: variant_a: - - title: - url: - - title: - url: - - title: - url: + - title: Tax your vehicle + url: /vehicle-tax + - title: Check how to claim a tax refund + url: /claim-tax-refund + - title: "Personal tax account: sign in or set up" + url: /personal-tax-account variant_b: - title: url: @@ -224,12 +224,12 @@ en: url: visas-immigration: variant_a: - - title: - url: - - title: - url: - - title: - url: + - title: Get access to your eVisa + url: /get-access-evisa + - title: Online immigration status (eVisa) + url: /guidance/online-immigration-status-evisa + - title: "View and prove your immigration status: get a share code" + url: /view-prove-immigration-status variant_b: - title: url: @@ -239,12 +239,12 @@ en: url: working: variant_a: - - title: - url: - - title: - url: - - title: - url: + - title: Find an apprenticeship + url: /apply-apprenticeship + - title: Prove your right to work to an employer + url: /prove-right-to-work + - title: "View and prove your immigration status: get a share code" + url: /view-prove-immigration-status variant_b: - title: url: diff --git a/spec/features/mainstream_browsing_spec.rb b/spec/features/mainstream_browsing_spec.rb index 92522c2a3..653762054 100644 --- a/spec/features/mainstream_browsing_spec.rb +++ b/spec/features/mainstream_browsing_spec.rb @@ -33,74 +33,34 @@ context "when AB testing popular tasks" do include GovukAbTesting::RspecHelpers + content_item = GovukSchemas::Example.find("mainstream_browse_page", example_name: "top_level_page") + browse_slugs = I18n.t("browse.popular_links").keys + before do GovukAbTesting.configure do |config| config.acceptance_test_framework = :capybara end end - context "when visiting /browse/benefits" do - before do - stub_content_store_has_item( - "/browse/benefits", - base_path: "/browse/benefits", - title: "Benefits", - ) - end - - scenario "variant A" do - with_variant PopularTasks: "A" do - visit "/browse/benefits" - expect(page).to have_link("Check benefits and financial support you can get") - end - end - - scenario "variant B" do - with_variant PopularTasks: "B" do - visit "/browse/benefits" - expect(page).to have_link("Check benefits and financial support you can get") - end - end - - scenario "control variant" do - visit "/browse/benefits" - expect(page).to have_link("Check benefits and financial support you can get") - end - end - - context "when visiting /browse/business" do - before do - stub_content_store_has_item( - "/browse/business", - base_path: "/browse/business", - title: "Business", - ) - end + browse_slugs.each do |browse_slug| + browse_path = "/browse/#{browse_slug}" - scenario "variant A" do - with_variant PopularTasks: "A" do - visit "/browse/business" - expect(page).to have_link("HMRC online services: sign in or set up an account") - expect(page).to have_link("Self Assessment tax returns") - expect(page).to have_link("Pay employers' PAYE") + context "when visiting #{browse_path}" do + before do + content_item["base_path"] = browse_path + stub_content_store_has_item(browse_path, content_item) end - end - scenario "variant B" do - with_variant PopularTasks: "B" do - visit "/browse/business" - expect(page).to have_link("HMRC online services: sign in or set up an account") - expect(page).to have_link("Self Assessment tax returns") - expect(page).to have_link("Pay employers' PAYE") + scenario "variant A" do + with_variant PopularTasks: "A" do + visit browse_path + links = I18n.t("browse.popular_links.#{browse_slug}.variant_a") + links.each do |link| + expect(page).to have_link(link["title"]) + end + end end end - - scenario "control variant" do - visit "/browse/business" - expect(page).to have_link("HMRC online services: sign in or set up an account") - expect(page).to have_link("Self Assessment tax returns") - expect(page).to have_link("Pay employers' PAYE") - end end end end From ec83e875d2502f0a24d9ad790be4af0a7d1f34a3 Mon Sep 17 00:00:00 2001 From: Jessica Jones Date: Wed, 21 Aug 2024 19:08:03 +0100 Subject: [PATCH 3/4] Add variant B links --- app/helpers/browse_helper.rb | 2 +- config/locales/en/browse.yml | 192 +++++++++++----------- spec/features/mainstream_browsing_spec.rb | 10 ++ 3 files changed, 107 insertions(+), 97 deletions(-) diff --git a/app/helpers/browse_helper.rb b/app/helpers/browse_helper.rb index 8a0c1d259..5231e1fb6 100644 --- a/app/helpers/browse_helper.rb +++ b/app/helpers/browse_helper.rb @@ -12,7 +12,7 @@ def variant_b_popular_links?(slug) end def variant_b_popular_links(slug) - I18n.t("#{slug}.control", scope: "browse.popular_links") + I18n.t("#{slug}.variant_b", scope: "browse.popular_links") end def control_popular_links?(slug) diff --git a/config/locales/en/browse.yml b/config/locales/en/browse.yml index fd4e4e677..9ece82f2a 100644 --- a/config/locales/en/browse.yml +++ b/config/locales/en/browse.yml @@ -11,12 +11,12 @@ en: - title: Online immigration status (eVisa) url: /guidance/online-immigration-status-evisa variant_b: - - title: - url: - - title: - url: - - title: - url: + - title: Apply online for a UK passport + url: /apply-renew-passport + - title: Foreign travel advice + url: /foreign-travel-advice + - title: Get a passport urgently + url: /get-a-passport-urgently benefits: control: - title: Check benefits and financial support you can get @@ -29,12 +29,12 @@ en: - title: Child Benefit url: /child-benefit variant_b: - - title: - url: - - title: - url: - - title: - url: + - title: Sign in to your Universal Credit account + url: /sign-in-universal-credit + - title: Sign in to your childcare account + url: /sign-in-childcare-account + - title: Universal Credit + url: /universal-credit births-deaths-marriages: variant_a: - title: Order a birth, death, marriage or civil partnership certificate @@ -44,12 +44,12 @@ en: - title: Search probate records for documents and wills (England and Wales) url: /search-will-probate variant_b: - - title: - url: - - title: - url: - - title: - url: + - title: "Get Tax-Free Childcare: step by step" + url: /get-tax-free-childcare + - title: Tax-Free Childcare + url: /tax-free-childcare + - title: Child Benefit when your child turns 16 + url: /child-benefit-16-19 business: control: - title: "HMRC online services: sign in or set up an account" @@ -66,12 +66,12 @@ en: - title: What a sole trader is url: /become-sole-trader variant_b: - - title: - url: - - title: - url: - - title: - url: + - title: Get information about a company + url: /get-information-about-a-company + - title: Find an energy certificate + url: /find-energy-certificate + - title: "Trade Tariff: look up commodity codes, duty and VAT rates" + url: /trade-tariff childcare-parenting: variant_a: - title: Sign in to your childcare account @@ -81,12 +81,12 @@ en: - title: Child Benefit when your child turns 16 url: /child-benefit-16-19 variant_b: - - title: - url: - - title: - url: - - title: - url: + - title: Sign in to your childcare account + url: /sign-in-childcare-account + - title: "Get Tax-Free Childcare: step by step" + url: /get-tax-free-childcare + - title: Tax-Free Childcare + url: /tax-free-childcare citizenship: variant_a: - title: "View and prove your immigration status: get a share code" @@ -96,12 +96,12 @@ en: - title: Apply to the EU Settlement Scheme (settled and pre-settled status) url: /settled-status-eu-citizens-families variant_b: - - title: - url: - - title: - url: - - title: - url: + - title: "View and prove your immigration status: get a share code" + url: /view-prove-immigration-status + - title: Prove your right to work to an employer + url: /prove-right-to-work + - title: Register to vote + url: /register-to-vote disabilities: variant_a: - title: Apply for or renew a Blue Badge @@ -111,12 +111,12 @@ en: - title: Personal Independence Payment (PIP) url: /pip variant_b: - - title: - url: - - title: - url: - - title: - url: + - title: Universal Credit + url: /universal-credit + - title: Benefits calculators + url: /benefits-calculators + - title: Apply for or renew a Blue Badge + url: /apply-blue-badge driving: variant_a: - title: Apply for your first provisional driving licence @@ -126,12 +126,12 @@ en: - title: Book and manage driving and riding tests for your pupils url: /book-pupil-driving-test variant_b: - - title: - url: - - title: - url: - - title: - url: + - title: Check the MOT history of a vehicle + url: /check-mot-history + - title: Tax your vehicle + url: /vehicle-tax + - title: Check if a vehicle is taxed + url: /check-vehicle-tax education: variant_a: - title: Student visa @@ -141,12 +141,12 @@ en: - title: Child Benefit when your child turns 16 url: /child-benefit-16-19 variant_b: - - title: - url: - - title: - url: - - title: - url: + - title: Student finance login + url: /student-finance-register-login + - title: Manage your student loan balance + url: /sign-in-to-manage-your-student-loan-balance + - title: Find an apprenticeship + url: /apply-apprenticeship employing-people: variant_a: - title: Find a job @@ -156,12 +156,12 @@ en: - title: Prove your right to work to an employer url: /prove-right-to-work variant_b: - - title: - url: - - title: - url: - - title: - url: + - title: UK bank holidays + url: /bank-holidays + - title: "Check a job applicant's right to work: use their share code" + url: /view-right-to-work + - title: DBS Update Service + url: /dbs-update-service environment-countryside: variant_a: - title: "Hedgerow management rules: cutting and trimming" @@ -171,12 +171,12 @@ en: - title: Report a pothole url: /report-pothole variant_b: - - title: - url: - - title: - url: - - title: - url: + - title: Buy a rod fishing licence + url: /fishing-licences + - title: Find out your rubbish collection day + url: /rubbish-collection-day + - title: Check the long term flood risk for an area in England + url: /check-long-term-flood-risk housing-local-services: variant_a: - title: Search for land and property information @@ -186,12 +186,12 @@ en: - title: Tell HMRC when you change your address url: /tell-hmrc-change-address variant_b: - - title: - url: - - title: - url: - - title: - url: + - title: Find an energy certificate + url: /find-energy-certificate + - title: Find your local council + url: /find-local-council + - title: Check your Council Tax band + url: /council-tax-bands justice: variant_a: - title: Request a basic DBS check @@ -201,12 +201,12 @@ en: - title: Find a job url: /find-a-job variant_b: - - title: - url: - - title: - url: - - title: - url: + - title: Send money to someone in prison + url: /send-prisoner-money + - title: Visit someone in prison + url: /prison-visits + - title: Report benefit fraud + url: /report-benefit-fraud tax: variant_a: - title: Tax your vehicle @@ -216,12 +216,12 @@ en: - title: "Personal tax account: sign in or set up" url: /personal-tax-account variant_b: - - title: - url: - - title: - url: - - title: - url: + - title: "Personal tax account: sign in or set up" + url: /personal-tax-account + - title: Estimate your Income Tax for the current year + url: /estimate-income-tax + - title: Check how to register for Self Assessment + url: /register-for-self-assessment visas-immigration: variant_a: - title: Get access to your eVisa @@ -231,12 +231,12 @@ en: - title: "View and prove your immigration status: get a share code" url: /view-prove-immigration-status variant_b: - - title: - url: - - title: - url: - - title: - url: + - title: "View and prove your immigration status: get a share code" + url: /view-prove-immigration-status + - title: Get access to your eVisa + url: /get-access-evisa + - title: Prove your right to work to an employer + url: /prove-right-to-work working: variant_a: - title: Find an apprenticeship @@ -246,12 +246,12 @@ en: - title: "View and prove your immigration status: get a share code" url: /view-prove-immigration-status variant_b: - - title: - url: - - title: - url: - - title: - url: + - title: Universal Credit + url: /universal-credit + - title: Prove your right to work to an employer + url: /prove-right-to-work + - title: Check your State Pension forecast + url: /check-state-pension all_categories: All categories popular_tasks: Popular tasks topics: Topics diff --git a/spec/features/mainstream_browsing_spec.rb b/spec/features/mainstream_browsing_spec.rb index 653762054..9569f477d 100644 --- a/spec/features/mainstream_browsing_spec.rb +++ b/spec/features/mainstream_browsing_spec.rb @@ -60,6 +60,16 @@ end end end + + scenario "variant B" do + with_variant PopularTasks: "B" do + visit browse_path + links = I18n.t("browse.popular_links.#{browse_slug}.variant_b") + links.each do |link| + expect(page).to have_link(link["title"]) + end + end + end end end end From 452215aac283c063d45b1e3afce3374bb7a2064f Mon Sep 17 00:00:00 2001 From: Jessica Jones Date: Wed, 21 Aug 2024 20:24:25 +0100 Subject: [PATCH 4/4] Simplify control data code, and add tests For variants A and B, all browse pages will contain popular links. For variants C and Z ie the control state, only business and benefits will contain popular links. The other 14 will default to hiding popular tasks entirely - as this is the default behaviour currently live on GOV.UK This commit adds specs to highlight this, and simplifies the existing code. There is no behavioural change. --- app/helpers/browse_helper.rb | 42 ++++---------- spec/features/mainstream_browsing_spec.rb | 68 +++++++++++++++++++++++ 2 files changed, 80 insertions(+), 30 deletions(-) diff --git a/app/helpers/browse_helper.rb b/app/helpers/browse_helper.rb index 5231e1fb6..3b750515e 100644 --- a/app/helpers/browse_helper.rb +++ b/app/helpers/browse_helper.rb @@ -1,50 +1,32 @@ module BrowseHelper - def variant_a_popular_links?(slug) - I18n.exists?("#{slug}.variant_a", scope: "browse.popular_links") - end - - def variant_a_popular_links(slug) - I18n.t("#{slug}.variant_a", scope: "browse.popular_links") - end - - def variant_b_popular_links?(slug) - I18n.exists?("#{slug}.variant_b", scope: "browse.popular_links") - end - - def variant_b_popular_links(slug) - I18n.t("#{slug}.variant_b", scope: "browse.popular_links") + def display_popular_links_for_slug?(slug) + popular_links_data(slug).present? end - def control_popular_links?(slug) + def control_key_is_present?(slug) I18n.exists?("#{slug}.control", scope: "browse.popular_links") end - def control_popular_links(slug) - I18n.t("#{slug}.control", scope: "browse.popular_links") - end - - def display_popular_links_for_slug?(slug) - if popular_tasks_variant_a_page? - variant_a_popular_links?(slug) - elsif popular_tasks_variant_b_page? - variant_b_popular_links?(slug) + def control_data(slug) + if control_key_is_present?(slug) + I18n.t("browse.popular_links.#{slug}.control") else - control_popular_links?(slug) + [] end end - def variant_popular_links_for_slug(slug) + def popular_links_data(slug) if popular_tasks_variant_a_page? - variant_a_popular_links(slug) + I18n.t("browse.popular_links.#{slug}.variant_a") elsif popular_tasks_variant_b_page? - variant_b_popular_links(slug) + I18n.t("browse.popular_links.#{slug}.variant_b") else - control_popular_links(slug) + control_data(slug) end end def popular_links_for_slug(slug) - links = variant_popular_links_for_slug(slug) + links = popular_links_data(slug) count = links.length links.map.with_index(1) do |link, index| { diff --git a/spec/features/mainstream_browsing_spec.rb b/spec/features/mainstream_browsing_spec.rb index 9569f477d..9f815f888 100644 --- a/spec/features/mainstream_browsing_spec.rb +++ b/spec/features/mainstream_browsing_spec.rb @@ -42,6 +42,74 @@ end end + context "Control variants" do + scenario "when visiting business and benefits i.e. pages that originally had popular tasks" do + with_variant PopularTasks: "C" do + content_item["base_path"] = "/browse/business" + stub_content_store_has_item("/browse/business", content_item) + visit "/browse/business" + expect(page).to have_content("Popular tasks") + + links = I18n.t("browse.popular_links.business.control") + links.each do |link| + expect(page).to have_link(link["title"]) + end + + content_item["base_path"] = "/browse/benefits" + stub_content_store_has_item("/browse/benefits", content_item) + visit "/browse/benefits" + expect(page).to have_content("Popular tasks") + + links = I18n.t("browse.popular_links.benefits.control") + links.each do |link| + expect(page).to have_link(link["title"]) + end + end + + with_variant PopularTasks: "Z" do + content_item["base_path"] = "/browse/business" + stub_content_store_has_item("/browse/business", content_item) + visit "/browse/business" + expect(page).to have_content("Popular tasks") + + links = I18n.t("browse.popular_links.business.control") + links.each do |link| + expect(page).to have_link(link["title"]) + end + + content_item["base_path"] = "/browse/benefits" + stub_content_store_has_item("/browse/benefits", content_item) + visit "/browse/benefits" + expect(page).to have_content("Popular tasks") + + links = I18n.t("browse.popular_links.benefits.control") + links.each do |link| + expect(page).to have_link(link["title"]) + end + end + end + + scenario "when visiting pages that originally had no popular tasks" do + slugs_with_no_popular_tasks_originally = browse_slugs - %i[benefits business] + + slugs_with_no_popular_tasks_originally.each do |browse_slug| + browse_path = "/browse/#{browse_slug}" + content_item["base_path"] = browse_path + stub_content_store_has_item(browse_path, content_item) + + with_variant PopularTasks: "C" do + visit browse_path + expect(page).not_to have_content("Popular tasks") + end + + with_variant PopularTasks: "Z" do + visit browse_path + expect(page).not_to have_content("Popular tasks") + end + end + end + end + browse_slugs.each do |browse_slug| browse_path = "/browse/#{browse_slug}"