1
- from platform import system
2
-
3
1
import pytest
4
2
from selenium .webdriver import Firefox
5
3
@@ -20,6 +18,20 @@ def test_case():
20
18
alpenglow_map = {"light" : "rgba(255, 255, 255, 0.76)" , "dark" : "rgba(40, 29, 78, 0.96)" }
21
19
22
20
21
+ def colors_match (a , b ):
22
+ """Determine if two colors are close enough to be considered matches"""
23
+ tolerance = 0.14
24
+ a_colorstring = a .split ("(" )[1 ][:- 1 ]
25
+ b_colorstring = b .split ("(" )[1 ][:- 1 ]
26
+ a_colors = [float (n ) for n in a_colorstring .split ("," )]
27
+ b_colors = [float (n ) for n in b_colorstring .split ("," )]
28
+ for i in range (len (a_colors )):
29
+ diff = abs ((a_colors [i ] / b_colors [i ]) - 1.0 )
30
+ if diff > tolerance :
31
+ return False
32
+ return True
33
+
34
+
23
35
@pytest .mark .ci
24
36
def test_redirect_to_addons (driver : Firefox ):
25
37
"""
@@ -34,7 +46,6 @@ def test_redirect_to_addons(driver: Firefox):
34
46
assert driver .current_url == "about:addons"
35
47
36
48
37
- @pytest .mark .skipif (system ().lower ().startswith ("win" ), reason = "Bug 1974109" )
38
49
@pytest .mark .parametrize ("theme_name" , list (themes .keys ()))
39
50
def test_open_addons (driver : Firefox , theme_name : str ):
40
51
"""
@@ -56,10 +67,12 @@ def test_open_addons(driver: Firefox, theme_name: str):
56
67
# Already default on Firefox standard; skip activation/assertion
57
68
pytest .skip ("Compact Light is default on Firefox, skipping." )
58
69
59
- abt_addons .activate_theme (nav , theme_name , themes [theme_name ])
70
+ current_bg = abt_addons .activate_theme (
71
+ nav , theme_name , themes [theme_name ], perform_assert = False
72
+ )
73
+ assert colors_match (current_bg , themes [theme_name ])
60
74
61
75
62
- @pytest .mark .skipif (system ().lower ().startswith ("win" ), reason = "Bug 1974109" )
63
76
def test_alpenglow_theme (driver : Firefox ):
64
77
"""
65
78
C118173, specifically for alpenglow theme because color can be two values for dark or light mode
@@ -72,4 +85,7 @@ def test_alpenglow_theme(driver: Firefox):
72
85
nav , "firefox-alpenglow_mozilla_org-heading" , "" , perform_assert = False
73
86
)
74
87
75
- assert current_bg == alpenglow_map ["light" ] or current_bg == alpenglow_map ["dark" ]
88
+ # assert current_bg == alpenglow_map["light"] or current_bg == alpenglow_map["dark"]
89
+ assert colors_match (current_bg , alpenglow_map ["light" ]) or colors_match (
90
+ current_bg , alpenglow_map ["dark" ]
91
+ )
0 commit comments