Skip to content

Commit

Permalink
Merge pull request #6370 from emilghittasv/playwright-expand-user-pro…
Browse files Browse the repository at this point in the history
…file-tests

Playwright extend user profile tests
  • Loading branch information
akatsoulas authored Nov 25, 2024
2 parents ce74630 + 3c328bc commit 80fb92e
Show file tree
Hide file tree
Showing 10 changed files with 337 additions and 101 deletions.
2 changes: 1 addition & 1 deletion playwright_tests/core/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(self, page: Page):
self.page = page

# Fetching test data from json files.
with open("test_data/profile_edit.json", "r") as edit_test_data_file:
with open("test_data/profile_edit.json", "r", encoding="utf-8") as edit_test_data_file:
profile_edit_test_data = json.load(edit_test_data_file)
edit_test_data_file.close()

Expand Down
2 changes: 1 addition & 1 deletion playwright_tests/flows/auth_flows/auth_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,5 @@ def sign_in_flow(self, username: str, account_password: str) -> str:
"""If the OTP code input field is displayed, provide the OTP code."""
self.__provide_otp_code(self.utilities.get_fxa_verification_code(
fxa_username=username))

self.utilities.wait_for_dom_to_load()
return username
Original file line number Diff line number Diff line change
Expand Up @@ -419,9 +419,9 @@ def click_on_post_reply_button(self, repliant_username) -> str:
self._click(self.__post_reply_button,
expected_locator=f"//span[@class='display-name' and contains(text(), "
f"'{repliant_username}')]")
return self._get_element_attribute_value(f"//span[@class='display-name' and "
f"contains(text(), '{repliant_username}')]/"
f"ancestor::div[@class='answer ']",
return self._get_element_attribute_value("(//span[@class='display-name' and "
f"contains(text(), '{repliant_username}')]"
"/ancestor::div[@class='answer '])[last()]",
"id")

# Question Tools actions.
Expand Down Expand Up @@ -577,3 +577,11 @@ def click_on_common_responses_cancel_button(self):

def click_on_common_responses_insert_response_button(self):
self._click(self.__common_responses_insert_response_button)

def get_time_from_reply(self, reply_id: str) -> str:
"""Returns the time displayed inside the question for when a reply was made.
Args:
reply_id (str): The reply id.
"""
return self._get_text_of_element(f"//div[@id='{reply_id}']//time/time")
9 changes: 9 additions & 0 deletions playwright_tests/pages/user_pages/my_profile_answers_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,12 @@ def get_my_answer_text(self, answer_id: str) -> str:
return self._get_text_of_element(f"//article[@id='profile']//"
f"a[contains(@href, '{answer_id}')]/"
f"following-sibling::blockquote")

def get_my_answer_question_title(self, answer_id: str) -> str:
"""Get the title of the question that the answer belongs to.
Args:
answer_id: str: The id of the answer.
"""
return self._get_text_of_element(f"//article[@id='profile']//a[contains(@href,"
f" '{answer_id}')]")
4 changes: 2 additions & 2 deletions playwright_tests/pages/user_pages/my_profile_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,10 @@ def click_cancel_button(self):
"""Click the cancel button"""
self._click(self.EDIT_PROFILE_PAGE_LOCATORS["cancel_button"])

def click_update_my_profile_button(self, expected_url=None):
def click_update_my_profile_button(self, expected_url=None, expected_locator=None):
"""Click the update my profile button"""
self._click(self.EDIT_PROFILE_PAGE_LOCATORS["update_my_profile_button"],
expected_url=expected_url)
expected_url=expected_url, expected_locator=expected_locator)

def click_close_account_option(self):
"""Click the close account and delete all profile information link"""
Expand Down
12 changes: 10 additions & 2 deletions playwright_tests/pages/user_pages/my_profile_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ def get_my_profile_display_name_header_text(self) -> str:
"""Get the display name header text."""
return self._get_text_of_element(self.PROFILE_DETAILS_LOCATORS["display_name_header"])

def get_expected_header_locator(self, expected_username: str) -> str:
"""Get the expected header locator.
Args:
expected_username (str): The expected username
"""
return f"//h2[normalize-space(text())='{expected_username}']"

def get_my_profile_display_name_username_text(self) -> str:
"""Get the display name username text."""
return self._get_text_of_element(self.PROFILE_DETAILS_LOCATORS["username_info"])
Expand Down Expand Up @@ -110,9 +118,9 @@ def get_my_contributed_from_text(self) -> str:
"""Get the contributed from text."""
return self._get_text_of_element(self.PROFILE_DETAILS_LOCATORS["contributed_from_info"])

def get_my_profile_bio_text(self) -> str:
def get_my_profile_bio_text_paragraphs(self) -> list[str]:
"""Get the bio text."""
return self._get_text_of_element(self.PROFILE_DETAILS_LOCATORS["bio_info"])
return self._get_text_of_elements(self.PROFILE_DETAILS_LOCATORS["bio_info"])

def get_my_profile_page_header(self) -> str:
"""Get the profile page header."""
Expand Down
15 changes: 6 additions & 9 deletions playwright_tests/test_data/profile_edit.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
"valid_user_edit": {
"username": "modifiedUsernameAutoTestt",
"display_name": "Modified display name",
"display_name_chrome": "Modified display name ch",
"display_name_firefox": "Modified displayed name fx",
"biography": "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",
"biography": "Test\n<b>What the</b>\n\n<blockquote> Another test </blockquote>\n\n<code>host_ip = socket.gethostbyname(socket.gethostname()</code>\n\n<ul>\n<li> Test</li>\n<li>We</li>\n</ul>\n\n<ol>\n<li><i>www</i></li>\n</ol>\n\n<strong>Emil</strong>\n\nThe <abbr title=\"World Health Organization\">WHO</abbr> was founded in 1948.\n\n<a href='https://www.digi24.ro'>Digi link</a>",
"website": "https://edition.cnn.com/",
"twitter_username": "twitterTestUser",
"community_portal_username": "169008142",
Expand All @@ -20,16 +18,15 @@
"involved_from_year": "2017"
},
"valid_user_edit_with_symbols":{
"username_with_valid_symbols_firefox": "[email protected]+and-and_",
"username_with_valid_symbols_chrome": "[email protected]+and-and_"
"username_with_valid_symbols_firefox": "[email protected]+and-and_",
"username_with_non_ascii_japanese_chars": "こんにちは"
},
"invalid_username_with_symbols": {
"username_with_invalid_symbols": "testMozilla12^"
"username_with_invalid_symbols": "testMozilla12^",
"username_with_non_ascii_arabic_chars": "أهلاًبك",
"emoji_for_username": "Test\uD83D\uDE3A\uD83D\uDE38"
},
"uppercase_lowercase_valid_username": {
"uppercase_lowercase_username": "fICENCEp"
},
"biography_field_with_html_data": {
"biography_html_data": "Test\n<b>What the</b>\n\n<blockquote> Another test </blockquote>\n\n<code>\n\nhost_ip = socket.gethostbyname(socket.gethostname())\n\nif browser == \"chrome\":\nbrowser_options = ChromeOptions()\nbrowser_options.add_argument(\"-headless\")\nbrowser_options.add_argument('-window-size=1200x600')\nbrowser_options.add_argument(\"-disable-gpu\")\nbrowser_options.add_argument(\"--log-level=3\")\n\nelse:\nbrowser_options = FirefoxOptions()\nbrowser_options.add_argument(\"-headless\")\nbrowser_options.add_argument('-window-size=1200x600')\nbrowser_options.add_argument(\"-disable-gpu\")\nbrowser_options.log.level = 'warn'\n\ndriver = webdriver.Remote(\ncommand_executor=f'http://{host_ip}:4444',\noptions=browser_options\n)\n\n</code>\n\n<ul>\n<li> Test</li>\n<li>We</li>\n</ul>\n\n<ol>\n<li><i>www</i></li>\n</ol>\n\n<strong>Emil</strong>\n\n "
}
}
4 changes: 1 addition & 3 deletions playwright_tests/tests/contribute_tests/test_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,7 @@ def test_change_group_avatar(page: Page):
def test_add_new_group_leader(page: Page):
utilities = Utilities(page)
sumo_pages = SumoPages(page)
test_user = utilities.username_extraction_from_email(
utilities.user_secrets_accounts["TEST_ACCOUNT_12"]
)
test_user = "manualtest4"

test_group = utilities.user_message_test_data['test_groups'][2]

Expand Down
Loading

0 comments on commit 80fb92e

Please sign in to comment.