Skip to content

Commit

Permalink
Add extra hardcoded list of add-ons available in Firefox for Android …
Browse files Browse the repository at this point in the history
…release (#21514)

* Add extra hardcoded list of add-ons available in Firefox for Android release

This is not the full general availability yet but just a sneak peek.
  • Loading branch information
diox committed Nov 28, 2023
1 parent 4005602 commit cd17974
Show file tree
Hide file tree
Showing 6 changed files with 207 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/olympia/addons/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1587,7 +1587,7 @@ def can_be_compatible_with_all_fenix_versions(self):
self.promoted
and self.promoted.group.can_be_compatible_with_all_fenix_versions
and amo.ANDROID in self.promoted.approved_applications
)
) or self.guid in amo.FENIX_GENERAL_AVAILABILITY_SNEAK_PEEK

def has_author(self, user):
"""True if ``user`` is an author of the add-on."""
Expand Down
11 changes: 11 additions & 0 deletions src/olympia/addons/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1864,6 +1864,17 @@ def test_can_be_compatible_with_all_fenix_versions_property(self):
addon.promoted.update(application_id=amo.ANDROID.id)
assert addon.can_be_compatible_with_all_fenix_versions

def test_can_be_compatible_with_all_fenix_versions_property_sneak_peek(self):
addon = addon_factory()
assert not addon.can_be_compatible_with_all_fenix_versions

for guid in amo.FENIX_GENERAL_AVAILABILITY_SNEAK_PEEK:
addon.update(guid=guid)
assert addon.can_be_compatible_with_all_fenix_versions

addon.update(guid='@whatever')
assert not addon.can_be_compatible_with_all_fenix_versions


class TestAddonUser(TestCase):
def test_delete(self):
Expand Down
36 changes: 36 additions & 0 deletions src/olympia/constants/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,42 @@
# to be lowered back to 120.0 later.
MIN_VERSION_FENIX_GENERAL_AVAILABILITY = '121.0a1'

# The minimum version of Fenix where a select group of extensions are available
# on top of the recommended ones. Will be dropped once we have full general
# availability.
MIN_VERSION_FENIX_GENERAL_AVAILABILITY_SNEAK_PEEK = '120.0'
FENIX_GENERAL_AVAILABILITY_SNEAK_PEEK = (
'android_scroll_bottom@davero.addons.mozilla.org',
'android_scroll_top@davero.addons.mozilla.org',
'admin@fastaddons.com_AutoHighlight',
'batterdarkerdocs@threethan.github.io',
'black-menu-for-wikipedia@carlosjeurissen.com',
'{c3c10168-4186-445c-9c5b-63f12b8e2c87}',
'deArrow@ajay.app',
'firefox-production@exactnote.com',
'formhistory@yahoo.com',
'ink-for-google@carlosjeurissen.com',
'jid1-TMndP6cdKgxLcQ@jetpack',
'{cb2b337b-99d7-4b86-aa04-84a6f5c3e218}',
'offline-qr-code@rugk.github.io',
'{9063c2e9-e07c-4c2c-9646-cfe7ca8d0498}',
'{60B7679C-BED9-11E5-998D-8526BB8E7F8B}',
'addon@rao-text-to-speech.com',
'{2b38afa0-3422-4988-95e4-43f59d2c8e7b}',
'reopen-in-private@apps.jeurissen.co',
'{c29f5416-192d-42ab-9da0-b4a82418752b}',
's3@translator',
'simple_gesture@utb.dip.jp',
'sitedelta-watch@schierla.de',
'tetrio-plus@example.com',
'user-agent-switcher@ninetailed.ninja',
'unchecker@ad5001.eu',
'view-page-source@apps.jeurissen.co',
'avi6106@gmail.com',
'{1e41b6c3-1ae3-41eb-89fc-f5c5eb5c1301}',
'{034d548e-9728-4e5a-9133-8ea588e47200}',
)

ADDON_GUID_PATTERN = re.compile(
# Match {uuid} or something@host.tld ("something" being optional)
# guids. Copied from mozilla-central XPIProvider.jsm.
Expand Down
45 changes: 45 additions & 0 deletions src/olympia/devhub/tests/test_forms.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import random
import shutil
import tempfile
from datetime import datetime, timedelta
Expand Down Expand Up @@ -515,6 +516,50 @@ def test_fenix_range_not_disabled_for_recommended_android_extensions(self):
)
assert formset.is_valid()

def test_fenix_range_not_disabled_for_sneak_peek_android_extensions(self):
self.addon = Addon.objects.get(id=3615)
self.addon.update(guid=random.choice(amo.FENIX_GENERAL_AVAILABILITY_SNEAK_PEEK))
version = self.addon.current_version
ApplicationsVersions.objects.create(
version=version,
application=amo.ANDROID.id,
min=AppVersion.objects.get(application=amo.ANDROID.id, version='48.0'),
max=AppVersion.objects.get(application=amo.ANDROID.id, version='*'),
)
data = None
formset = forms.CompatFormSet(
data, queryset=version.apps.all(), form_kwargs={'version': version}
)
content = formset.render()
doc = pq(content)
assert doc('#id_form-1-application')[0].attrib['value'] == str(amo.ANDROID.id)
assert len(doc('#id_form-1-min option')) == 13
assert len(doc('#id_form-1-max option')) == 16
assert [x.text for x in doc('#id_form-1-min option[disabled=disabled]')] == []
assert [x.text for x in doc('#id_form-1-max option[disabled=disabled]')] == []
data = {
'form-TOTAL_FORMS': 2,
'form-INITIAL_FORMS': 1,
'form-MIN_NUM_FORMS': 0,
'form-MAX_NUM_FORMS': 1000,
'form-0-min': version.apps.all()[0].min.pk,
'form-0-max': version.apps.all()[0].max.pk,
'form-0-application': amo.FIREFOX.id,
'form-0-id': version.apps.all()[0].pk,
'form-1-min': AppVersion.objects.filter(application=amo.ANDROID.id).get(
version='48.0'
),
'form-1-max': AppVersion.objects.filter(application=amo.ANDROID.id).get(
version='121.0a1'
),
'form-1-application': amo.ANDROID.id,
'form-1-id': '',
}
formset = forms.CompatFormSet(
data, queryset=version.apps.all(), form_kwargs={'version': version}
)
assert formset.is_valid()


class TestPreviewForm(TestCase):
fixtures = ['base/addon_3615']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,33 @@
class Command(BaseCommand):
"""
Force current version of add-ons in the specified csv to be compatible with
Firefox for Android <MIN_VERSION_FENIX_GENERAL_AVAILABILITY> and higher.
Firefox for Android <MIN_VERSION_FENIX_GENERAL_AVAILABILITY> and higher,
or <MIN_VERSION_FENIX_GENERAL_AVAILABILITY_SNEAK_PEEK> and higher if using
--sneak-peek.
Should not affect compatibility of add-ons recommended/line for Android.
"""

help = (
'Force add-ons to be compatible with Firefox for Android '
f'{amo.MIN_VERSION_FENIX_GENERAL_AVAILABILITY} and higher'
f'{amo.MIN_VERSION_FENIX_GENERAL_AVAILABILITY} and higher '
f'or {amo.MIN_VERSION_FENIX_GENERAL_AVAILABILITY_SNEAK_PEEK} if using '
'--sneak-peek.'
)

def add_arguments(self, parser):
parser.add_argument(
'CSVFILE',
help='Path to CSV file containing add-on ids.',
)
parser.add_argument(
'--sneak-peek',
action='store_true',
help=(
'Sneak peek mode - makes specified add-ons available in '
f'{amo.MIN_VERSION_FENIX_GENERAL_AVAILABILITY_SNEAK_PEEK} instead.'
),
)

def read_csv(self, path):
with open(path) as file_:
Expand All @@ -44,10 +56,16 @@ def read_csv(self, path):
]

def handle(self, *args, **kwargs):
sneak_peek_mode = kwargs.get('sneak_peek')
target_min_version = (
amo.MIN_VERSION_FENIX_GENERAL_AVAILABILITY_SNEAK_PEEK
if sneak_peek_mode
else amo.MIN_VERSION_FENIX_GENERAL_AVAILABILITY
)
addon_ids = self.read_csv(kwargs['CSVFILE'])
min_version_fenix = AppVersion.objects.get(
application=amo.ANDROID.id,
version=amo.MIN_VERSION_FENIX_GENERAL_AVAILABILITY,
version=target_min_version,
)
max_version_fenix = AppVersion.objects.get(
application=amo.ANDROID.id, version=amo.DEFAULT_WEBEXT_MAX_VERSION
Expand All @@ -62,7 +80,7 @@ def handle(self, *args, **kwargs):
count = 0
skipped = 0
for addon in addons:
if addon.can_be_compatible_with_all_fenix_versions:
if not sneak_peek_mode and addon.can_be_compatible_with_all_fenix_versions:
log.info(
'Skipping add-on id %d because it can be compatible with Fenix.',
addon.pk,
Expand All @@ -81,7 +99,8 @@ def handle(self, *args, **kwargs):
)
count += 1
log.info(
'Done forcing Android compatibility on %d add-ons (%d skipped)',
'Done forcing Android compatibility to %s on %d add-ons (%d skipped)',
target_min_version,
count,
skipped,
)
91 changes: 90 additions & 1 deletion src/olympia/versions/tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def test_full(self):
[
['addon_id'],
*[[str(addon.pk)] for addon in addons_to_modify],
*[[str(addon.pk) for addon in addons_to_ignore_promoted]],
*[[str(addon.pk)] for addon in addons_to_ignore_promoted],
]
)

Expand Down Expand Up @@ -134,6 +134,95 @@ def test_full(self):
del addon.current_version._compatible_apps
assert amo.ANDROID not in addon.current_version.compatible_apps

def test_sneak_peek(self):
addons_to_modify = [
addon_factory(
name='Not yet compatible with Android',
guid=amo.FENIX_GENERAL_AVAILABILITY_SNEAK_PEEK[0],
),
addon_factory(
name='Already compatible with Android with strict_compatibility',
version_kw={
'application': amo.ANDROID.id,
'min_app_version': '48.0',
'max_app_version': '68.*',
},
file_kw={'strict_compatibility': True},
guid=amo.FENIX_GENERAL_AVAILABILITY_SNEAK_PEEK[1],
),
addon_factory(
name='Already compatible with Android',
version_kw={
'application': amo.ANDROID.id,
'min_app_version': '120.0',
'max_app_version': '*',
},
guid=amo.FENIX_GENERAL_AVAILABILITY_SNEAK_PEEK[2],
),
]
# <Addon>.can_be_compatible_with_all_fenix_versions returns True for
# the sneak peek add-ons, so in this mode, we also alter promoted
# add-ons compatibility, it's the caller responsability not to include
# any if they don't want to override compatibility on add-ons already
# available in release.
addons_to_modify_promoted = [
addon_factory(
name='Recommended for Android',
version_kw={
'application': amo.ANDROID.id,
'min_app_version': '48.0',
'max_app_version': '*',
},
promoted=RECOMMENDED,
guid=amo.FENIX_GENERAL_AVAILABILITY_SNEAK_PEEK[3],
),
addon_factory(
name='Line for all',
version_kw={
'application': amo.ANDROID.id,
'min_app_version': '48.0',
'max_app_version': '*',
},
promoted=LINE,
guid=amo.FENIX_GENERAL_AVAILABILITY_SNEAK_PEEK[4],
),
]
addons_to_ignore_not_in_csv = [
addon_factory(
name='Not in csv', guid=amo.FENIX_GENERAL_AVAILABILITY_SNEAK_PEEK[5]
)
]
csv_path = self._create_csv(
[
['addon_id'],
*[[str(addon.pk)] for addon in addons_to_modify],
*[[str(addon.pk)] for addon in addons_to_modify_promoted],
]
)

call_command('force_min_android_compatibility', csv_path, '--sneak-peek')

for addon in addons_to_modify + addons_to_modify_promoted:
if hasattr(addon.current_version, '_compatible_apps'):
del addon.current_version._compatible_apps
assert amo.ANDROID in addon.current_version.compatible_apps
assert (
addon.current_version.compatible_apps[amo.ANDROID].min.version
== amo.MIN_VERSION_FENIX_GENERAL_AVAILABILITY_SNEAK_PEEK
== '120.0'
)
assert addon.current_version.compatible_apps[amo.ANDROID].max.version == '*'
assert (
addon.current_version.compatible_apps[amo.ANDROID].originated_from
== amo.APPVERSIONS_ORIGINATED_FROM_MIGRATION
)
assert not addon.current_version.file.reload().strict_compatibility

for addon in addons_to_ignore_not_in_csv:
if hasattr(addon.current_version, '_compatible_apps'):
del addon.current_version._compatible_apps
assert amo.ANDROID not in addon.current_version.compatible_apps


class TestForceMaxAndroidCompatibility(TestCase):
def setUp(self):
Expand Down

0 comments on commit cd17974

Please sign in to comment.