From b6baa0433d84753726997cb9fe91da7b687efdf0 Mon Sep 17 00:00:00 2001 From: Sangie Date: Thu, 2 Oct 2025 20:34:29 -0400 Subject: [PATCH 1/2] test 1976534 - moving pinned tabs --- SELECTOR_INFO.md | 7 ++ modules/data/context_menu.components.json | 6 ++ .../test_change_position_of_pinned_tabs.py | 74 +++++++++++++++++++ .../test_customize_themes_and_redirect.py | 11 +-- .../test_installed_theme_enabled.py | 8 +- 5 files changed, 99 insertions(+), 7 deletions(-) create mode 100644 tests/tabs/test_change_position_of_pinned_tabs.py diff --git a/SELECTOR_INFO.md b/SELECTOR_INFO.md index 9f9e744d2..d868aab99 100644 --- a/SELECTOR_INFO.md +++ b/SELECTOR_INFO.md @@ -1788,6 +1788,13 @@ Description: Open all bookmarks from the context menu option from a Toolbar book Location: Context menu - Toolbar Path to .json: modules/data/context_menu.components.json ``` +``` +Selector Name: context-menu-move-tab-to-start +Selector Data: menuitem[data-l10n-id='move-to-start'] +Description: Context menu option to move a tab to the start of the tab bar. +Location: Context menu - Tab +Path to .json: modules/data/context_menu.components.json +``` #### credit_card_fill ``` Selector Name: form-field diff --git a/modules/data/context_menu.components.json b/modules/data/context_menu.components.json index e8847b47d..e9afb106e 100644 --- a/modules/data/context_menu.components.json +++ b/modules/data/context_menu.components.json @@ -109,6 +109,12 @@ "groups": [] }, + "context-menu-move-tab-to-start": { + "selectorData": "menuitem[data-l10n-id='move-to-start']", + "strategy": "css", + "groups": [] + }, + "context-menu-open-link-in-tab": { "selectorData": "context-openlinkintab", "strategy": "id", diff --git a/tests/tabs/test_change_position_of_pinned_tabs.py b/tests/tabs/test_change_position_of_pinned_tabs.py new file mode 100644 index 000000000..99b030d03 --- /dev/null +++ b/tests/tabs/test_change_position_of_pinned_tabs.py @@ -0,0 +1,74 @@ +import logging + +import pytest +from selenium.webdriver import Firefox + +from modules.browser_object import ContextMenu, TabBar + + +@pytest.fixture() +def test_case(): + return "134723" + + +def test_change_position_of_pinned_tabs(driver: Firefox): + tabs = TabBar(driver) + tab_context_menu = ContextMenu(driver) + + tab_titles = [] + url_list = ["about:logo", "about:robots", "https://mozilla.org"] + + driver.get(url_list[0]) + tab_titles.append(driver.title) + + # Open 3 tabs + for i in range(1, len(url_list)): + tabs.new_tab_by_button() + driver.switch_to.window(driver.window_handles[-1]) + driver.get(url_list[i]) + tab_titles.append(driver.title) + + # Specific tabs we want to work with + robot_title = tab_titles[1] + mozilla_title = tab_titles[2] + + # Pin the 'Robots' tab by its title + driver.switch_to.window(driver.window_handles[0]) + robot_tab = tabs.get_tab(robot_title) + assert robot_tab is not None, "Robot tab should exist" + tabs.context_click(robot_tab) + tab_context_menu.click_and_hide_menu("context-menu-pin-tab") + pinned_tab_one = tabs.get_tab(robot_title) + assert pinned_tab_one is not None, "Pinned Robot tab should exist" + assert tabs.is_pinned(pinned_tab_one) + + # Pin the 'Mozilla' tab by its title + mozilla_tab = tabs.get_tab(mozilla_title) + assert mozilla_tab is not None, "Mozilla tab should exist" + tabs.context_click(mozilla_tab) + tab_context_menu.click_and_hide_menu("context-menu-pin-tab") + pinned_tab_two = tabs.get_tab(mozilla_title) + assert pinned_tab_two is not None, "Pinned Robot tab should exist" + assert tabs.is_pinned(pinned_tab_two) + + # Move second pinned tab to the left + tabs.context_click(pinned_tab_two) + tab_context_menu.click_and_hide_menu("context-menu-move-tab-to-start") + # Click-and-hide won't hide the parent popup + tabs.hide_popup("tabContextMenu") + + # Get the titles for each of the rearranged pinned tabs + driver.switch_to.window(driver.window_handles[0]) + new_pinned_tab_one_title = driver.title + logging.info("Tab title: %s", new_pinned_tab_one_title) + + driver.switch_to.window(driver.window_handles[1]) + new_pinned_tab_two_title = driver.title + logging.info("Tab title: %s", new_pinned_tab_two_title) + + assert "Mozilla" in new_pinned_tab_one_title, ( + "Mozilla should now be the first pinned tab" + ) + assert "Gort!" in new_pinned_tab_two_title, ( + "Robot should now be the second pinned tab" + ) diff --git a/tests/theme_and_toolbar/test_customize_themes_and_redirect.py b/tests/theme_and_toolbar/test_customize_themes_and_redirect.py index 4512faba6..a732c01ad 100644 --- a/tests/theme_and_toolbar/test_customize_themes_and_redirect.py +++ b/tests/theme_and_toolbar/test_customize_themes_and_redirect.py @@ -1,5 +1,6 @@ import pytest from selenium.webdriver import Firefox + from modules.browser_object import Navigation, PanelUi from modules.page_object import AboutAddons @@ -11,7 +12,7 @@ def test_case(): THEMES: dict[str, list[str]] = { "firefox-compact-dark_mozilla_org-heading": [ - "rgb(43, 42, 51)", # classic darker tone + "rgb(43, 42, 51)", # classic darker tone "rgb(143, 143, 148)", # focused dark "rgb(120, 119, 126)", # dark without focus ], @@ -82,7 +83,9 @@ def test_redirect_to_addons(driver: Firefox) -> None: @pytest.mark.parametrize("theme_name", list(THEMES.keys())) -def test_activate_theme_background_matches_expected(driver: Firefox, theme_name: str) -> None: +def test_activate_theme_background_matches_expected( + driver: Firefox, theme_name: str +) -> None: """ C118173: Ensure that activating each theme in about:addons applies the expected background color. Handles Developer Edition vs standard Firefox defaults. @@ -100,9 +103,7 @@ def test_activate_theme_background_matches_expected(driver: Firefox, theme_name: if theme_name == "firefox-compact-light_mozilla_org-heading": pytest.skip("Compact Light is default on Firefox, skipping.") - current_bg = abt_addons.activate_theme( - nav, theme_name, "", perform_assert=False - ) + current_bg = abt_addons.activate_theme(nav, theme_name, "", perform_assert=False) expected_list = THEMES[theme_name] assert any(colors_match(current_bg, exp) for exp in expected_list), ( diff --git a/tests/theme_and_toolbar/test_installed_theme_enabled.py b/tests/theme_and_toolbar/test_installed_theme_enabled.py index 3116b59df..ec39cc802 100644 --- a/tests/theme_and_toolbar/test_installed_theme_enabled.py +++ b/tests/theme_and_toolbar/test_installed_theme_enabled.py @@ -12,7 +12,9 @@ def test_case(): return "118174" -MAC_GHA: bool = environ.get("GITHUB_ACTIONS") == "true" and sys.platform.startswith("darwin") +MAC_GHA: bool = environ.get("GITHUB_ACTIONS") == "true" and sys.platform.startswith( + "darwin" +) AMO_HOST: str = "addons.mozilla.org" AMO_THEMES_PATH: str = "firefox/themes" @@ -44,7 +46,9 @@ def test_installed_theme_enabled(driver: Firefox) -> None: about_addons.choose_sidebar_option("theme") # Capture currently enabled theme title - starting_theme = about_addons.get_element("enabled-theme-title").get_attribute("innerText") + starting_theme = about_addons.get_element("enabled-theme-title").get_attribute( + "innerText" + ) # Go to AMO and install a recommended theme (POM encapsulates waits and flows) AmoThemes(driver).open().install_recommended_theme() From 19c4920f2abc9b6000f31365acce3f22ec377b53 Mon Sep 17 00:00:00 2001 From: Sangie Date: Thu, 2 Oct 2025 21:05:38 -0400 Subject: [PATCH 2/2] test 1976534 - passed locally --- tests/tabs/test_change_position_of_pinned_tabs.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/tabs/test_change_position_of_pinned_tabs.py b/tests/tabs/test_change_position_of_pinned_tabs.py index 99b030d03..315160dd8 100644 --- a/tests/tabs/test_change_position_of_pinned_tabs.py +++ b/tests/tabs/test_change_position_of_pinned_tabs.py @@ -5,6 +5,10 @@ from modules.browser_object import ContextMenu, TabBar +# --- Expected Title Constants --- +EXPECTED_MOZILLA_TITLE = "Mozilla" +EXPECTED_ROBOT_TITLE = "Gort!" + @pytest.fixture() def test_case(): @@ -66,9 +70,9 @@ def test_change_position_of_pinned_tabs(driver: Firefox): new_pinned_tab_two_title = driver.title logging.info("Tab title: %s", new_pinned_tab_two_title) - assert "Mozilla" in new_pinned_tab_one_title, ( + assert EXPECTED_MOZILLA_TITLE in new_pinned_tab_one_title, ( "Mozilla should now be the first pinned tab" ) - assert "Gort!" in new_pinned_tab_two_title, ( + assert EXPECTED_ROBOT_TITLE in new_pinned_tab_two_title, ( "Robot should now be the second pinned tab" )