Skip to content

Commit e7f5d44

Browse files
authored
Sangie/ Moving pinned tabs (#822)
* test 1976534 - moving pinned tabs * test 1976534 - passed locally
1 parent eb94d77 commit e7f5d44

File tree

5 files changed

+103
-7
lines changed

5 files changed

+103
-7
lines changed

SELECTOR_INFO.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1788,6 +1788,13 @@ Description: Open all bookmarks from the context menu option from a Toolbar book
17881788
Location: Context menu - Toolbar
17891789
Path to .json: modules/data/context_menu.components.json
17901790
```
1791+
```
1792+
Selector Name: context-menu-move-tab-to-start
1793+
Selector Data: menuitem[data-l10n-id='move-to-start']
1794+
Description: Context menu option to move a tab to the start of the tab bar.
1795+
Location: Context menu - Tab
1796+
Path to .json: modules/data/context_menu.components.json
1797+
```
17911798
#### credit_card_fill
17921799
```
17931800
Selector Name: form-field

modules/data/context_menu.components.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@
109109
"groups": []
110110
},
111111

112+
"context-menu-move-tab-to-start": {
113+
"selectorData": "menuitem[data-l10n-id='move-to-start']",
114+
"strategy": "css",
115+
"groups": []
116+
},
117+
112118
"context-menu-open-link-in-tab": {
113119
"selectorData": "context-openlinkintab",
114120
"strategy": "id",
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import logging
2+
3+
import pytest
4+
from selenium.webdriver import Firefox
5+
6+
from modules.browser_object import ContextMenu, TabBar
7+
8+
# --- Expected Title Constants ---
9+
EXPECTED_MOZILLA_TITLE = "Mozilla"
10+
EXPECTED_ROBOT_TITLE = "Gort!"
11+
12+
13+
@pytest.fixture()
14+
def test_case():
15+
return "134723"
16+
17+
18+
def test_change_position_of_pinned_tabs(driver: Firefox):
19+
tabs = TabBar(driver)
20+
tab_context_menu = ContextMenu(driver)
21+
22+
tab_titles = []
23+
url_list = ["about:logo", "about:robots", "https://mozilla.org"]
24+
25+
driver.get(url_list[0])
26+
tab_titles.append(driver.title)
27+
28+
# Open 3 tabs
29+
for i in range(1, len(url_list)):
30+
tabs.new_tab_by_button()
31+
driver.switch_to.window(driver.window_handles[-1])
32+
driver.get(url_list[i])
33+
tab_titles.append(driver.title)
34+
35+
# Specific tabs we want to work with
36+
robot_title = tab_titles[1]
37+
mozilla_title = tab_titles[2]
38+
39+
# Pin the 'Robots' tab by its title
40+
driver.switch_to.window(driver.window_handles[0])
41+
robot_tab = tabs.get_tab(robot_title)
42+
assert robot_tab is not None, "Robot tab should exist"
43+
tabs.context_click(robot_tab)
44+
tab_context_menu.click_and_hide_menu("context-menu-pin-tab")
45+
pinned_tab_one = tabs.get_tab(robot_title)
46+
assert pinned_tab_one is not None, "Pinned Robot tab should exist"
47+
assert tabs.is_pinned(pinned_tab_one)
48+
49+
# Pin the 'Mozilla' tab by its title
50+
mozilla_tab = tabs.get_tab(mozilla_title)
51+
assert mozilla_tab is not None, "Mozilla tab should exist"
52+
tabs.context_click(mozilla_tab)
53+
tab_context_menu.click_and_hide_menu("context-menu-pin-tab")
54+
pinned_tab_two = tabs.get_tab(mozilla_title)
55+
assert pinned_tab_two is not None, "Pinned Robot tab should exist"
56+
assert tabs.is_pinned(pinned_tab_two)
57+
58+
# Move second pinned tab to the left
59+
tabs.context_click(pinned_tab_two)
60+
tab_context_menu.click_and_hide_menu("context-menu-move-tab-to-start")
61+
# Click-and-hide won't hide the parent popup
62+
tabs.hide_popup("tabContextMenu")
63+
64+
# Get the titles for each of the rearranged pinned tabs
65+
driver.switch_to.window(driver.window_handles[0])
66+
new_pinned_tab_one_title = driver.title
67+
logging.info("Tab title: %s", new_pinned_tab_one_title)
68+
69+
driver.switch_to.window(driver.window_handles[1])
70+
new_pinned_tab_two_title = driver.title
71+
logging.info("Tab title: %s", new_pinned_tab_two_title)
72+
73+
assert EXPECTED_MOZILLA_TITLE in new_pinned_tab_one_title, (
74+
"Mozilla should now be the first pinned tab"
75+
)
76+
assert EXPECTED_ROBOT_TITLE in new_pinned_tab_two_title, (
77+
"Robot should now be the second pinned tab"
78+
)

tests/theme_and_toolbar/test_customize_themes_and_redirect.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import pytest
22
from selenium.webdriver import Firefox
3+
34
from modules.browser_object import Navigation, PanelUi
45
from modules.page_object import AboutAddons
56

@@ -11,7 +12,7 @@ def test_case():
1112

1213
THEMES: dict[str, list[str]] = {
1314
"firefox-compact-dark_mozilla_org-heading": [
14-
"rgb(43, 42, 51)", # classic darker tone
15+
"rgb(43, 42, 51)", # classic darker tone
1516
"rgb(143, 143, 148)", # focused dark
1617
"rgb(120, 119, 126)", # dark without focus
1718
],
@@ -82,7 +83,9 @@ def test_redirect_to_addons(driver: Firefox) -> None:
8283

8384

8485
@pytest.mark.parametrize("theme_name", list(THEMES.keys()))
85-
def test_activate_theme_background_matches_expected(driver: Firefox, theme_name: str) -> None:
86+
def test_activate_theme_background_matches_expected(
87+
driver: Firefox, theme_name: str
88+
) -> None:
8689
"""
8790
C118173: Ensure that activating each theme in about:addons applies the expected background color.
8891
Handles Developer Edition vs standard Firefox defaults.
@@ -100,9 +103,7 @@ def test_activate_theme_background_matches_expected(driver: Firefox, theme_name:
100103
if theme_name == "firefox-compact-light_mozilla_org-heading":
101104
pytest.skip("Compact Light is default on Firefox, skipping.")
102105

103-
current_bg = abt_addons.activate_theme(
104-
nav, theme_name, "", perform_assert=False
105-
)
106+
current_bg = abt_addons.activate_theme(nav, theme_name, "", perform_assert=False)
106107

107108
expected_list = THEMES[theme_name]
108109
assert any(colors_match(current_bg, exp) for exp in expected_list), (

tests/theme_and_toolbar/test_installed_theme_enabled.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ def test_case():
1212
return "118174"
1313

1414

15-
MAC_GHA: bool = environ.get("GITHUB_ACTIONS") == "true" and sys.platform.startswith("darwin")
15+
MAC_GHA: bool = environ.get("GITHUB_ACTIONS") == "true" and sys.platform.startswith(
16+
"darwin"
17+
)
1618

1719
AMO_HOST: str = "addons.mozilla.org"
1820
AMO_THEMES_PATH: str = "firefox/themes"
@@ -44,7 +46,9 @@ def test_installed_theme_enabled(driver: Firefox) -> None:
4446
about_addons.choose_sidebar_option("theme")
4547

4648
# Capture currently enabled theme title
47-
starting_theme = about_addons.get_element("enabled-theme-title").get_attribute("innerText")
49+
starting_theme = about_addons.get_element("enabled-theme-title").get_attribute(
50+
"innerText"
51+
)
4852

4953
# Go to AMO and install a recommended theme (POM encapsulates waits and flows)
5054
AmoThemes(driver).open().install_recommended_theme()

0 commit comments

Comments
 (0)