Skip to content

Commit 93d8297

Browse files
committed
vs/Part1-Refactoring
1 parent 1971f95 commit 93d8297

File tree

1 file changed

+36
-27
lines changed

1 file changed

+36
-27
lines changed

tests/address_bar_and_search/test_google_search_counts_us.py

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,39 +10,48 @@
1010
from modules.util import Utilities
1111

1212

13+
# Constants
14+
SEARCH_TERM = "festival"
15+
SEARCH_PROVIDER_PATH = '$..SEARCH_COUNTS.["google-b-1-d.urlbar"].sum'
16+
SEARCH_TAG_PATH = '$..["browser.search.content.urlbar"].["google:tagged:firefox-b-1-d"]'
17+
WAIT_AFTER_SEARCH = 5
18+
WAIT_TELEMETRY_LOAD = 2
19+
20+
# Conditional skip for GitHub Actions on macOS
21+
MAC_GHA = environ.get("GITHUB_ACTIONS") == "true" and sys.platform.startswith("darwin")
22+
23+
1324
@pytest.fixture()
1425
def test_case():
1526
return "1365026"
1627

1728

18-
MAC_GHA = environ.get("GITHUB_ACTIONS") == "true" and sys.platform.startswith("darwin")
19-
20-
21-
@pytest.mark.skipif(MAC_GHA, reason="Test unstable in MacOS Github Actions")
29+
@pytest.mark.skipif(MAC_GHA, reason="Test unstable in macOS GitHub Actions")
2230
def test_google_search_counts_us(driver: Firefox):
2331
"""
24-
C1365026, Test Google Search counts - urlbar US
32+
C1365026: Verify Google search counts in telemetry from the URL bar (US region).
2533
"""
26-
# instantiate objects
34+
2735
nav = Navigation(driver)
28-
nav.search("festival")
29-
sleep(5)
30-
u = Utilities()
31-
32-
# Click on Raw JSON, switch tab and click on Raw Data
33-
about_telemetry = AboutTelemetry(driver).open()
34-
sleep(2)
35-
about_telemetry.get_element("category-raw").click()
36-
about_telemetry.switch_to_new_tab()
37-
about_telemetry.get_element("rawdata-tab").click()
38-
39-
# Verify pings are recorded
40-
json_data = u.decode_url(driver)
41-
assert u.assert_json_value(
42-
json_data, '$..SEARCH_COUNTS.["google-b-1-d.urlbar"].sum', 1
43-
)
44-
assert u.assert_json_value(
45-
json_data,
46-
'$..["browser.search.content.urlbar"].["google:tagged:firefox-b-1-d"]',
47-
1,
48-
)
36+
nav.search(SEARCH_TERM)
37+
sleep(WAIT_AFTER_SEARCH)
38+
39+
utils = Utilities()
40+
41+
# === Open about:telemetry and navigate to raw JSON ===
42+
telemetry = AboutTelemetry(driver).open()
43+
sleep(WAIT_TELEMETRY_LOAD)
44+
telemetry.get_element("category-raw").click()
45+
telemetry.switch_to_new_tab()
46+
telemetry.get_element("rawdata-tab").click()
47+
48+
# === Decode telemetry and validate search provider data ===
49+
json_data = utils.decode_url(driver)
50+
51+
assert utils.assert_json_value(
52+
json_data, SEARCH_PROVIDER_PATH, 1
53+
), f"Expected 1 Google search in path: {SEARCH_PROVIDER_PATH}"
54+
55+
assert utils.assert_json_value(
56+
json_data, SEARCH_TAG_PATH, 1
57+
), f"Expected 1 tagged Google search in path: {SEARCH_TAG_PATH}"

0 commit comments

Comments
 (0)