Skip to content

Commit

Permalink
Add WNP 131 (Fixes #15097) (#15176)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgibson authored Sep 18, 2024
1 parent c7961e8 commit bc4773b
Show file tree
Hide file tree
Showing 15 changed files with 556 additions and 0 deletions.
107 changes: 107 additions & 0 deletions bedrock/firefox/templates/firefox/whatsnew/whatsnew-fx131-eu.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
{#
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at https://mozilla.org/MPL/2.0/.
#}

{% from "macros-protocol.html" import split with context %}

{% extends "firefox/whatsnew/base.html" %}

{% block page_title %}{{ ftl('whatsnew-page-title-v2') }}{% endblock %}

{#- This will appear as <meta property="og:description"> which can be used for social share -#}
{% block page_og_desc %}{{ ftl('whatsnew-page-description') }}{% endblock %}

{% block body_id %}firefox-whatsnew{% endblock %}

{% block page_css %}
{{ css_bundle('protocol-split') }}
{{ css_bundle('firefox_whatsnew_131_eu') }}
{% endblock %}

{% block site_header %}{% endblock %}

{% if nimbus_variant == 'v4' %}
{% if LANG == 'de' %}
{% set main_title = 'Firefox blockt Tracker automatisch' %}
{% set main_tagline = 'Firefox schützt dich während du browst. Weißt du, wie viele Tracker er allein letzte Woche für dich geblockt hat?' %}
{% set main_cta = 'Zu meiner Schutzmaßnahmen-Übersicht' %}
{% elif LANG == 'fr' %}
{% set main_title = 'Firefox bloque les traqueurs par défaut' %}
{% set main_tagline = 'Firefox vous protège en arrière-plan pendant que vous naviguez. Savez-vous combien de traqueurs ont été bloqués rien que la semaine dernière ?' %}
{% set main_cta = 'Voir mon tableau de bord des protections' %}
{% else %}
{% set main_title = 'Firefox blocks trackers by default' %}
{% set main_tagline = 'Firefox protects you in the background while you browse. Do you know how many trackers were blocked just last week?' %}
{% set main_cta = 'See my protections dashboard' %}
{% endif %}
{% else %}
{% if LANG == 'de' %}
{% set main_title = 'Cookies bleiben da, wo sie hingehören' %}
{% set main_tagline = 'Wusstest du, dass Cookies dir von Seite zu Seite folgen? Unser vollständiger Cookie-Schutz hält sie davon ab, damit das, was du auf einer Website machst, auf dieser Website bleibt.' %}
{% set main_cta = 'Mehr erfahren' %}
{% elif LANG == 'fr' %}
{% set main_title = 'Gardez les cookies à leur place' %}
{% set main_tagline = 'Saviez-vous que les cookies vous suivaient de site en site ? Notre protection totale contre les cookies les contient, pour que ce que vous fassiez sur un site web reste sur ce site web.' %}
{% set main_cta = 'En savoir plus' %}
{% else %}
{% set main_title = 'Keep cookies in their place' %}
{% set main_tagline = 'Did you know cookies follow you from site to site? Our total cookie protection contains them, so what you do on one website stays on that website.' %}
{% set main_cta = 'Learn more' %}
{% endif %}
{% endif %}

{% block wnp_content %}
<section class="wnp-content-main">
{% call split(
block_class='mzp-l-split-center-on-sm-md',
image=resp_img(
url='img/firefox/whatsnew/whatsnew131-eu/main-image-500.png',
srcset={
'img/firefox/whatsnew/whatsnew131-eu/main-image-500.png': '500w',
'img/firefox/whatsnew/whatsnew131-eu/main-image-700.png': '700w',
'img/firefox/whatsnew/whatsnew131-eu/main-image-900.png': '900w',
'img/firefox/whatsnew/whatsnew131-eu/main-image-1100.png': '1100w',
},
sizes={
'(min-width: 1400px)': '550px',
'(min-width: 768px)': '50vw',
'default': '100vw'
},
optional_attributes={
'height': '500',
'width': '550',
'class': 'c-banner-media mzp-c-split-media-asset'
}
),
media_after=False
) %}

<h2 class="wnp-main-title">{{ main_title }}</h2>
<p class="wnp-main-tagline">{{ main_tagline }}</p>

{% if nimbus_variant == 'v3' %}
<a class="c-banner-button mzp-c-button mzp-t-product mzp-t-xl" href="https://support.mozilla.org/kb/introducing-total-cookie-protection-standard-mode?{{ utm_params }}" data-cta-type="button" data-cta-text="Learn more">
{{ main_cta }}
</a>
{% else %}
<a id="protections-dashboard" class="c-banner-button mzp-c-button mzp-t-product mzp-t-xl" href="https://support.mozilla.org/kb/enhanced-tracking-protection-firefox-desktop?{{ utm_params }}" data-cta-type="button" data-cta-text="See my protections dashboard">
{{ main_cta }}
</a>
{% endif %}
{% endcall %}
</section>

<section class="wnp-footer">
<p class="wnp-sign-off">{{ ftl('whatsnew-signoff') }}</p>
{% include "firefox/whatsnew/includes/mofo-donate-cta.html" %}
</section>
{% endblock %}

{% block js %}
{% if nimbus_variant == 'v4' %}
{{ js_bundle('firefox_whatsnew_131_protections_dashboard') }}
{% endif %}
{{ js_bundle('firefox_whatsnew_131') }}
{% endblock %}
47 changes: 47 additions & 0 deletions bedrock/firefox/templates/firefox/whatsnew/whatsnew-fx131-na.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{#
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at https://mozilla.org/MPL/2.0/.
#}

{% extends "firefox/whatsnew/base.html" %}

{% block page_title %}{{ ftl('whatsnew-page-title-v2') }}{% endblock %}

{#- This will appear as <meta property="og:description"> which can be used for social share -#}
{% block page_og_desc %}{{ ftl('whatsnew-page-description') }}{% endblock %}

{% block body_id %}firefox-whatsnew{% endblock %}

{% block page_css %}
{{ css_bundle('firefox_whatsnew_131_na') }}
{% endblock %}

{% block site_header %}{% endblock %}

{% block wnp_content %}
<section class="wnp-content-main">
<div class="mzp-l-content mzp-t-content-md">
<img class="wnp-main-image" src="{{ static('img/firefox/whatsnew/whatsnew131-na/main-image.svg') }}" width="552" height="248" alt="">

<h1 class="wnp-main-title">Hop around the web without <br>being followed</h1>

<p class="wnp-main-tagline">Firefox makes it hard for companies to track you, so you can <br>keep your browsing activity to yourself.</p>

<p class="wnp-main-cta">
<a class="mzp-c-button mzp-t-product" href="https://blog.mozilla.org/en/mozilla/firefox-rolls-out-total-cookie-protection-by-default-to-all-users-worldwide/?{{ utm_params }}" data-cta-text="Tell me more">
Tell me more
</a>
</p>
</div>
</section>

<section class="wnp-footer">
<p class="wnp-sign-off">{{ ftl('whatsnew-signoff') }}</p>
{% include "firefox/whatsnew/includes/mofo-donate-cta.html" %}
</section>
{% endblock %}

{% block js %}
{{ js_bundle('firefox_whatsnew_131') }}
{% endblock %}
175 changes: 175 additions & 0 deletions bedrock/firefox/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,181 @@ def test_fx_130_0_0_en_us_v1(self, render_mock):

# end 130.0 whatsnew tests

# begin 131.0 whatsnew tests

@override_settings(DEV=True)
def test_fx_131_0_0_en_us_no_experiment(self, render_mock):
"""Should use default WNP template for en-US when no experiment params are present"""
req = self.rf.get("/firefox/whatsnew/")
req.locale = "en-US"
self.view(req, version="131.0")
template = render_mock.call_args[0][1]
assert template == ["firefox/whatsnew/index.html"]

@override_settings(DEV=True)
def test_fx_131_0_0_en_us_v1(self, render_mock):
"""Should use default WNP template for en-US locale when branch=experiment-wnp-131-tabs and variant=v1"""
req = self.rf.get("/firefox/whatsnew/?branch=experiment-wnp-131-tabs&variant=v1")
req.locale = "en-US"
self.view(req, version="131.0")
template = render_mock.call_args[0][1]
assert template == ["firefox/whatsnew/index.html"]

@override_settings(DEV=True)
def test_fx_131_0_0_en_us_v2(self, render_mock):
"""Should use whatsnew-fx131-na.html template for en-US locale when branch=experiment-wnp-131-tabs and variant=v2"""
req = self.rf.get("/firefox/whatsnew/?branch=experiment-wnp-131-tabs&variant=v2")
req.locale = "en-US"
self.view(req, version="131.0")
template = render_mock.call_args[0][1]
assert template == ["firefox/whatsnew/whatsnew-fx131-na.html"]

@override_settings(DEV=True)
def test_fx_131_0_0_en_ca_no_experiment(self, render_mock):
"""Should use default WNP template for en-CA when no experiment params are present"""
req = self.rf.get("/firefox/whatsnew/")
req.locale = "en-US"
self.view(req, version="131.0")
template = render_mock.call_args[0][1]
assert template == ["firefox/whatsnew/index.html"]

@override_settings(DEV=True)
def test_fx_131_0_0_en_ca_v1(self, render_mock):
"""Should use default WNP template for en-CA locale when branch=experiment-wnp-131-tabs and variant=v1"""
req = self.rf.get("/firefox/whatsnew/?branch=experiment-wnp-131-tabs&variant=v1")
req.locale = "en-CA"
self.view(req, version="131.0")
template = render_mock.call_args[0][1]
assert template == ["firefox/whatsnew/index.html"]

@override_settings(DEV=True)
def test_fx_131_0_0_en_ca_v2(self, render_mock):
"""Should use whatsnew-fx131-na.html template for en-CA locale when branch=experiment-wnp-131-tabs and variant=v2"""
req = self.rf.get("/firefox/whatsnew/?branch=experiment-wnp-131-tabs&variant=v2")
req.locale = "en-CA"
self.view(req, version="131.0")
template = render_mock.call_args[0][1]
assert template == ["firefox/whatsnew/whatsnew-fx131-na.html"]

@override_settings(DEV=True)
def test_fx_131_0_0_en_gb_no_experiment(self, render_mock):
"""Should use default WNP template for en-GB when no experiment params are present"""
req = self.rf.get("/firefox/whatsnew/")
req.locale = "en-GB"
self.view(req, version="131.0")
template = render_mock.call_args[0][1]
assert template == ["firefox/whatsnew/index.html"]

@override_settings(DEV=True)
def test_fx_131_0_0_en_gb_v1(self, render_mock):
"""Should use default WNP template for en-GB locale when branch=experiment-wnp-131-tabs and variant=v1"""
req = self.rf.get("/firefox/whatsnew/?branch=experiment-wnp-131-tabs&variant=v1")
req.locale = "en-GB"
self.view(req, version="131.0")
template = render_mock.call_args[0][1]
assert template == ["firefox/whatsnew/index.html"]

@override_settings(DEV=True)
def test_fx_131_0_0_en_gb_v3(self, render_mock):
"""Should use whatsnew-fx131-eu.html template for en-GB locale when branch=experiment-wnp-131-tabs and variant=v3"""
req = self.rf.get("/firefox/whatsnew/?branch=experiment-wnp-131-tabs&variant=v3")
req.locale = "en-GB"
self.view(req, version="131.0")
template = render_mock.call_args[0][1]
assert template == ["firefox/whatsnew/whatsnew-fx131-eu.html"]

@override_settings(DEV=True)
def test_fx_131_0_0_en_gb_v4(self, render_mock):
"""Should use whatsnew-fx131-eu.html template for en-GB locale when branch=experiment-wnp-131-tabs and variant=v4"""
req = self.rf.get("/firefox/whatsnew/?branch=experiment-wnp-131-tabs&variant=v4")
req.locale = "en-GB"
self.view(req, version="131.0")
template = render_mock.call_args[0][1]
assert template == ["firefox/whatsnew/whatsnew-fx131-eu.html"]

@override_settings(DEV=True)
def test_fx_131_0_0_de_no_experiment(self, render_mock):
"""Should use default WNP template for de when no experiment params are present"""
req = self.rf.get("/firefox/whatsnew/")
req.locale = "de"
self.view(req, version="131.0")
template = render_mock.call_args[0][1]
assert template == ["firefox/whatsnew/index.html"]

@override_settings(DEV=True)
def test_fx_131_0_0_de_v1(self, render_mock):
"""Should use default WNP template for de locale when branch=experiment-wnp-131-tabs and variant=v1"""
req = self.rf.get("/firefox/whatsnew/?branch=experiment-wnp-131-tabs&variant=v1")
req.locale = "de"
self.view(req, version="131.0")
template = render_mock.call_args[0][1]
assert template == ["firefox/whatsnew/index.html"]

@override_settings(DEV=True)
def test_fx_131_0_0_de_v3(self, render_mock):
"""Should use whatsnew-fx131-eu.html template for de locale when branch=experiment-wnp-131-tabs and variant=v3"""
req = self.rf.get("/firefox/whatsnew/?branch=experiment-wnp-131-tabs&variant=v3")
req.locale = "de"
self.view(req, version="131.0")
template = render_mock.call_args[0][1]
assert template == ["firefox/whatsnew/whatsnew-fx131-eu.html"]

@override_settings(DEV=True)
def test_fx_131_0_0_de_v4(self, render_mock):
"""Should use whatsnew-fx131-eu.html template for de locale when branch=experiment-wnp-131-tabs and variant=v4"""
req = self.rf.get("/firefox/whatsnew/?branch=experiment-wnp-131-tabs&variant=v4")
req.locale = "de"
self.view(req, version="131.0")
template = render_mock.call_args[0][1]
assert template == ["firefox/whatsnew/whatsnew-fx131-eu.html"]

@override_settings(DEV=True)
def test_fx_131_0_0_fr_no_experiment(self, render_mock):
"""Should use default WNP template for fr when no experiment params are present"""
req = self.rf.get("/firefox/whatsnew/")
req.locale = "fr"
self.view(req, version="131.0")
template = render_mock.call_args[0][1]
assert template == ["firefox/whatsnew/index.html"]

@override_settings(DEV=True)
def test_fx_131_0_0_fr_v1(self, render_mock):
"""Should use default WNP template for de locale when branch=experiment-wnp-131-tabs and variant=v1"""
req = self.rf.get("/firefox/whatsnew/?branch=experiment-wnp-131-tabs&variant=v1")
req.locale = "fr"
self.view(req, version="131.0")
template = render_mock.call_args[0][1]
assert template == ["firefox/whatsnew/index.html"]

@override_settings(DEV=True)
def test_fx_131_0_0_fr_v3(self, render_mock):
"""Should use whatsnew-fx131-eu.html template for de locale when branch=experiment-wnp-131-tabs and variant=v3"""
req = self.rf.get("/firefox/whatsnew/?branch=experiment-wnp-131-tabs&variant=v3")
req.locale = "fr"
self.view(req, version="131.0")
template = render_mock.call_args[0][1]
assert template == ["firefox/whatsnew/whatsnew-fx131-eu.html"]

@override_settings(DEV=True)
def test_fx_131_0_0_fr_v4(self, render_mock):
"""Should use whatsnew-fx131-eu.html template for de locale when branch=experiment-wnp-131-tabs and variant=v4"""
req = self.rf.get("/firefox/whatsnew/?branch=experiment-wnp-131-tabs&variant=v4")
req.locale = "fr"
self.view(req, version="131.0")
template = render_mock.call_args[0][1]
assert template == ["firefox/whatsnew/whatsnew-fx131-eu.html"]

@override_settings(DEV=True)
def test_fx_131_0_0_other_locales(self, render_mock):
"""Should use default WNP template for locales that are not part of the experiment"""
req = self.rf.get("/firefox/whatsnew/")
req.locale = "es-ES"
self.view(req, version="131.0")
template = render_mock.call_args[0][1]
assert template == ["firefox/whatsnew/index.html"]

# begin 131.0 whatsnew tests


@patch("bedrock.firefox.views.l10n_utils.render", return_value=HttpResponse())
class TestFirstRun(TestCase):
Expand Down
23 changes: 23 additions & 0 deletions bedrock/firefox/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,8 @@ class WhatsnewView(L10nTemplateView):
"firefox/whatsnew/whatsnew-fx129-na.html": ["firefox/whatsnew/whatsnew"],
"firefox/whatsnew/whatsnew-fx129-eu.html": ["firefox/whatsnew/whatsnew"],
"firefox/whatsnew/whatsnew-fx130.html": ["firefox/whatsnew/whatsnew"],
"firefox/whatsnew/whatsnew-fx131-na.html": ["firefox/whatsnew/whatsnew"],
"firefox/whatsnew/whatsnew-fx131-eu.html": ["firefox/whatsnew/whatsnew"],
}

# specific templates that should not be rendered in
Expand All @@ -497,6 +499,9 @@ class WhatsnewView(L10nTemplateView):
# place expected ?v= values in this list
variations = ["1", "2", "3", "4"]

# Nimbus experiment variation expected values
nimbus_variations = ["v1", "v2", "v3", "v4"]

def get_context_data(self, **kwargs):
ctx = super().get_context_data(**kwargs)
version = self.kwargs.get("version") or ""
Expand All @@ -522,12 +527,18 @@ def get_context_data(self, **kwargs):
ctx["utm_params"] = f"utm_source={entrypoint}&utm_medium=referral&utm_campaign={campaign}&entrypoint={entrypoint}"

variant = self.request.GET.get("v", None)
nimbus_variant = self.request.GET.get("variant", None)

# ensure variant matches pre-defined value
if variant not in self.variations:
variant = None

# ensure nimbus_variant matches pre-defined value
if nimbus_variant not in self.nimbus_variations:
nimbus_variant = None

ctx["variant"] = variant
ctx["nimbus_variant"] = nimbus_variant

return ctx

Expand Down Expand Up @@ -579,6 +590,18 @@ def get_template_names(self):
template = "firefox/whatsnew/index.html"
else:
template = "firefox/whatsnew/index.html"
elif version.startswith("131."):
if nimbus_branch == "experiment-wnp-131-tabs":
if nimbus_variant == "v1":
template = "firefox/whatsnew/index.html"
elif locale in ["en-US", "en-CA"] and nimbus_variant == "v2":
template = "firefox/whatsnew/whatsnew-fx131-na.html"
elif locale in ["en-GB", "de", "fr"] and nimbus_variant in ["v3", "v4"]:
template = "firefox/whatsnew/whatsnew-fx131-eu.html"
else:
template = "firefox/whatsnew/index.html"
else:
template = "firefox/whatsnew/index.html"
elif version.startswith("130."):
if locale in ["en-US", "en-GB", "en-CA", "de", "fr", "es-ES", "it", "pl"]:
if nimbus_branch == "experiment-wnp-130-tabs":
Expand Down
Loading

0 comments on commit bc4773b

Please sign in to comment.