Skip to content

Commit 5eae892

Browse files
Hani YacoubHani Yacoub
authored andcommitted
merge main
2 parents 70f30d1 + fe8c4ad commit 5eae892

18 files changed

+122
-53
lines changed

.github/workflows/smoke.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ env:
2323

2424
jobs:
2525
Smoke-Windows:
26+
if: ${{ inputs.job_to_run == 'Smoke-Windows' || github.event_name == 'pull_request' }}
2627
runs-on: windows-latest
2728
steps:
2829
- name: Create app token
@@ -116,6 +117,7 @@ jobs:
116117
name: artifacts-win
117118
path: artifacts-win
118119
Smoke-MacOS:
120+
if: ${{ inputs.job_to_run == 'Smoke-MacOS' || github.event_name == 'pull_request' }}
119121
runs-on: macos-latest
120122
steps:
121123
- name: Create app token
@@ -151,11 +153,11 @@ jobs:
151153
rm ./pyproject.toml;
152154
mv ./ci_pyproject.toml ./pyproject.toml;
153155
pipenv install;
154-
bash ./collect_executables.sh;
156+
echo app_name=$(bash ./collect_executables.sh | xargs -0 ./parse_executables.sh) >> "$GITHUB_OUTPUT"
155157
- name: Run Smoke Tests in MacOS
156158
if: steps.setup.conclusion == 'success'
157159
env:
158-
FX_EXECUTABLE: /Volumes/Firefox/Firefox.app/Contents/MacOS/firefox
160+
FX_EXECUTABLE: /Volumes/${{ steps.setup.outputs.app_name }}/${{ steps.setup.outputs.app_name }}.app/Contents/MacOS/firefox
159161
run: |
160162
/Volumes/Firefox/Firefox.app/Contents/MacOS/firefox --version
161163
pipenv run python choose_ci_set.py

SELECTOR_INFO.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2983,7 +2983,7 @@ Path to .json: modules/data/navigation.components.json
29832983
```
29842984
```
29852985
Selector Name: search-mode-switcher-option
2986-
Selector Data: toolbarbutton[label*='{title}']
2986+
Selector Data: menuitem[label*='{title}']
29872987
Description: Option by label in search mode list
29882988
Location: Search mode of awesomebar
29892989
Path to .json: modules/data/navigation.components.json
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import pytest
2+
from selenium.webdriver import Firefox
3+
4+
from modules.browser_object_autofill_popup import AutofillPopup
5+
from modules.page_object_autofill import AddressFill
6+
from modules.util import Utilities
7+
8+
9+
@pytest.fixture()
10+
def test_case():
11+
return "2888563"
12+
13+
14+
def test_demo_ad_autofill_address_fields(
15+
driver: Firefox,
16+
region: str,
17+
address_autofill: AddressFill,
18+
util: Utilities,
19+
autofill_popup: AutofillPopup,
20+
):
21+
"""
22+
C2888563 - Verify Autofill functionality when selecting an entry from the dropdown for address fields
23+
"""
24+
# Create fake data and fill it in
25+
address_autofill.open()
26+
address_autofill_data = util.fake_autofill_data(region)
27+
address_autofill.save_information_basic(address_autofill_data)
28+
29+
# Click the "Save" button
30+
autofill_popup.click_doorhanger_button("save")
31+
32+
# List of field labels to be autofilled and verified
33+
fields_to_test = [
34+
"street-address",
35+
"address-level2",
36+
"address-level1", # This will be skipped for DE/FR
37+
"postal-code",
38+
"country",
39+
]
40+
41+
# Loop through each field and perform the autofill test
42+
for field in fields_to_test:
43+
address_autofill.autofill_and_verify(
44+
autofill_popup, field, address_autofill_data, util
45+
)

l10n_CM/Unified/test_demo_ad_autofill_name_org.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import pytest
22
from selenium.webdriver import Firefox
33

4-
from l10n_CM.Unified.conftest import autofill_popup
54
from modules.browser_object_autofill_popup import AutofillPopup
65
from modules.page_object_autofill import AddressFill
76
from modules.util import Utilities

l10n_CM/Unified/test_demo_ad_preview_name_org.py

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -29,34 +29,11 @@ def test_demo_ad_preview_name_org(
2929
# Click the "Save" button
3030
autofill_popup.click_doorhanger_button("save")
3131

32-
# Double-click inside Name field and hover the mouse over any saved address entry in the dropdown (without selecting it).
33-
address_autofill.double_click("form-field", labels=["name"])
34-
# Get the first element from the autocomplete dropdown
35-
first_item = autofill_popup.get_nth_element(1)
36-
actual_value = autofill_popup.hover(first_item).get_primary_value(first_item)
37-
38-
# Get the primary value (name) from the first item in the dropdown and assert that the actual value matches the expected value
39-
expected_name = address_autofill_data.name
40-
assert expected_name == actual_value, (
41-
f"Expected {expected_name}, but got {actual_value}"
42-
)
43-
44-
# Double-click inside Name field and hover the mouse over any saved address entry in the dropdown (without selecting it).
45-
address_autofill.double_click("form-field", labels=["organization"])
46-
# Get the first element from the autocomplete dropdown
47-
first_item = autofill_popup.get_nth_element(1)
48-
actual_value = autofill_popup.hover(first_item).get_primary_value(first_item)
49-
50-
# Get the primary value (org) from the first item in the dropdown and assert that the actual value matches the expected value
51-
expected_org = address_autofill_data.organization
52-
assert expected_org == actual_value, (
53-
f"Expected {expected_org}, but got {actual_value}"
54-
)
55-
5632
fields_to_test = [
5733
"name",
5834
"organization"
5935
]
6036

6137
for field in fields_to_test:
62-
address_autofill.verify_autofill_preview(field, )
38+
address_autofill.verify_autofill_preview(field, address_autofill_data.name)
39+
address_autofill.verify_autofill_preview(field, address_autofill_data.organization)

l10n_CM/Unified/test_demo_cc_add_new_credit_card.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import pytest
44
from selenium.webdriver import Firefox
55

6-
from l10n_CM.Unified.conftest import region
76
from modules.page_object import AboutPrefs
87
from modules.util import Utilities
98

l10n_CM/Unified/test_demo_cc_doorhanger_data_is_stored_in_about_prefs.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import pytest
22
from selenium.webdriver import Firefox
33

4-
from l10n_CM.Unified.conftest import region
54
from modules.browser_object_autofill_popup import AutofillPopup
65
from modules.page_object_autofill import CreditCardFill
76
from modules.page_object_prefs import AboutPrefs

l10n_CM/region/Unified.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
"test_demo_cc_doorhanger_shown_on_valid_credit_card_submission.py",
1414
"test_demo_cc_dropdown-presence.py",
1515
"test_demo_cc_yellow_highlight.py",
16+
"test_demo_ad_yellow_highlight.py",
17+
"test_demo_ad_autofill_address_fields.py",
1618
"test_demo_ad_yellow_highlight_name_org.py",
1719
"test_demo_ad_yellow_highlight_address.py",
1820
"test_demo_ad_yellow_highlight_phone_email.py",

modules/data/navigation.components.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
},
131131

132132
"search-mode-switcher-option": {
133-
"selectorData": "toolbarbutton[label*='{title}']",
133+
"selectorData": "menuitem[label*='{title}']",
134134
"strategy": "css",
135135
"groups": []
136136
},
@@ -164,6 +164,7 @@
164164
},
165165

166166
"sponsored-suggestion": {
167+
"doNotCache": true,
167168
"selectorData": "urlbarView-row-body-description",
168169
"strategy": "class",
169170
"groups": []

modules/page_object_autofill.py

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,9 @@ def verify_autofill_data(
515515
"ZIP Code": autofill_data.postal_code,
516516
"Country": autofill_data.country,
517517
"Email": autofill_data.email,
518-
"Phone": util.normalize_phone_number(autofill_data.telephone),
518+
"Phone": util.normalize_regional_phone_numbers(
519+
autofill_data.telephone, region
520+
),
519521
}
520522

521523
# Validate each field
@@ -528,7 +530,7 @@ def verify_autofill_data(
528530

529531
# Normalize phone numbers before comparison
530532
if field == "Phone":
531-
actual = util.normalize_phone_number(actual)
533+
actual = util.normalize_regional_phone_numbers(actual, region)
532534

533535
assert actual == expected, (
534536
f"Mismatch in {field}: Expected '{expected}', but got '{actual}'"
@@ -549,6 +551,45 @@ def verify_field_yellow_highlights(
549551
expected_highlighted_fields=expected_highlighted_fields,
550552
)
551553

554+
def autofill_and_verify(
555+
self, address_autofill_popup, field_label, address_autofill_data, util
556+
):
557+
"""
558+
Autofills a form field, verifies the data, and clears it if necessary.
559+
Parameters:
560+
----------
561+
address_autofill : AddressFill
562+
The address autofill handler.
563+
address_autofill_popup : AutofillPopup
564+
The popup handler for autofill suggestions.
565+
field_label : str
566+
The label of the field being autofilled.
567+
address_autofill_data : dict
568+
The generated autofill data for verification.
569+
region : str
570+
The region code to handle localization.
571+
"""
572+
# Skip address-level1 (State) selection for DE and FR
573+
if field_label == "address-level1" and address_autofill_data.country in [
574+
"DE",
575+
"FR",
576+
]:
577+
return
578+
579+
# Double-click a field and choose the first element from the autocomplete dropdown
580+
self.double_click("form-field", labels=[field_label])
581+
first_item = address_autofill_popup.get_nth_element(1)
582+
address_autofill_popup.click_on(first_item)
583+
584+
# Verify autofill data
585+
self.verify_autofill_data(
586+
address_autofill_data, address_autofill_data.country, util
587+
)
588+
589+
# Clear form autofill
590+
self.double_click("form-field", labels=[field_label])
591+
address_autofill_popup.click_clear_form_option()
592+
552593
def verify_autofill_preview(self, field_label: str, expected_value: str):
553594
"""Reusable method to verify autofill preview for a given field."""
554595
self.double_click("form-field", labels=[field_label])

0 commit comments

Comments
 (0)