Skip to content

Commit

Permalink
Merge pull request mozilla#5913 from emilghittasv/playwright-code-cle…
Browse files Browse the repository at this point in the history
…anup

Fix some failing playwright tests & code cleanup
  • Loading branch information
emilghittasv authored Mar 6, 2024
2 parents 7c049ea + d69fae1 commit a1e41bc
Show file tree
Hide file tree
Showing 14 changed files with 368 additions and 504 deletions.
69 changes: 69 additions & 0 deletions playwright_tests/flows/ask_a_question_flows/aaq_flows/aaq_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,72 @@ def adding_an_image_to_aaq_form(self):
super()._get_upload_image_button_locator().set_input_files(
super().aaq_question_test_data["valid_firefox_question"]["image_path"]
)

def deleting_question_flow(self):
super()._click_delete_this_question_question_tools_option()
super()._click_delete_this_question_button()

def editing_question_flow(self, subject='', body='', troubleshoot='', submit_edit=True):
if subject != '':
super()._clear_subject_input_field()
super()._add_text_to_aaq_form_subject_field(subject)

if body != '':
super()._clear_the_question_body_textarea_field()
super()._add_text_to_aaq_textarea_field(body)

if troubleshoot != '':
super()._add_text_to_troubleshooting_information_textarea(troubleshoot)

if submit_edit:
super()._click_aaq_edit_submit_button()

def editing_reply_flow(self, reply_body: str, submit_reply=True):
super()._clear_the_question_body_textarea_field()
super()._add_text_to_aaq_textarea_field(reply_body)

if submit_reply:
super()._click_on_update_answer_button()
else:
super()._click_aaq_form_cancel_button()

def delete_question_reply(self, answer_id: str, delete_reply:bool):
super()._click_on_reply_more_options_button(answer_id)
super()._click_on_delete_this_post_for_a_certain_reply(answer_id)

if delete_reply:
super()._click_delete_this_question_button()
else:
super()._click_on_cancel_delete_button()

def post_question_reply_flow(self,
repliant_username: str,
reply='',
submit_reply=True,
quoted_reply=False,
reply_for_id='') -> str:
if quoted_reply:
super()._click_on_reply_more_options_button(reply_for_id)
super()._click_on_quote_for_a_certain_reply(reply_for_id)

if reply != '' and quoted_reply:
super()._type_inside_the_post_a_reply_textarea(reply)
elif reply != '' and not quoted_reply:
super()._add_text_to_post_a_reply_textarea(reply)

if submit_reply:
return super()._click_on_post_reply_button(repliant_username)

def report_question_abuse(self, answer_id: str, text=''):
super()._click_on_reply_more_options_button(answer_id)
super()._click_on_report_abuse_for_a_certain_reply(answer_id)

if text != '':
super()._add_text_to_report_abuse_textarea(text)

super()._click_on_report_abuse_submit_button()
super()._click_abuse_modal_close_button()

def spam_marking_a_reply(self, reply_id: str):
super()._click_on_reply_more_options_button(reply_id)
super()._click_on_mark_as_spam_for_a_certain_reply(reply_id)
Original file line number Diff line number Diff line change
@@ -1,14 +1,38 @@
from playwright.sync_api import Page
from playwright_tests.core.testutilities import TestUtilities
from playwright_tests.pages.messaging_system_pages.inbox_page import InboxPage
from playwright_tests.pages.messaging_system_pages.new_message import NewMessagePage
from playwright_tests.pages.messaging_system_pages.sent_messages import SentMessagePage


class MessagingSystemFlows(TestUtilities, NewMessagePage):
class MessagingSystemFlows(TestUtilities, NewMessagePage, SentMessagePage, InboxPage):
def __init__(self, page: Page):
super().__init__(page)

# Send message form with data flow.
def complete_send_message_form_with_data(self, recipient_username: str, message_body: str):
super()._type_into_new_message_to_input_field(recipient_username)
super()._click_on_a_searched_user(recipient_username)
super()._fill_into_new_message_body_textarea(message_body)
def complete_send_message_form_with_data(self,
recipient_username='',
message_body='',
submit_message=True):
if recipient_username != '':
super()._type_into_new_message_to_input_field(recipient_username)
super()._click_on_a_searched_user(recipient_username)

if message_body != '':
super()._fill_into_new_message_body_textarea(message_body)

if submit_message:
super()._click_on_new_message_send_button()

def delete_message_flow(self, username: str,
delete_message=True,
from_sent_list=False,
from_inbox_list=False):
if from_sent_list:
super()._click_on_sent_message_delete_button(username)

if from_inbox_list:
super()._click_on_inbox_message_delete_button(username)

if delete_message:
super()._click_on_delete_page_delete_button()
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
from playwright.sync_api import Page
from playwright_tests.core.testutilities import TestUtilities
from playwright_tests.pages.top_navbar import TopNavbar
from playwright_tests.pages.user_pages.my_profile_edit import MyProfileEdit
from playwright_tests.pages.user_pages.my_profile_edit_contribution_areas_page import \
MyProfileEditContributionAreasPage
from playwright_tests.pages.user_pages.my_profile_edit_settings_page import \
MyProfileEditSettingsPage
from playwright_tests.pages.user_pages.my_profile_user_navbar import UserNavbar


class EditProfileDataFlow(MyProfileEdit, TestUtilities):
class EditProfileDataFlow(MyProfileEdit,
TestUtilities,
MyProfileEditContributionAreasPage,
TopNavbar,
UserNavbar,
MyProfileEditSettingsPage):
def __init__(self, page: Page):
super().__init__(page)

Expand Down Expand Up @@ -50,3 +61,19 @@ def _clear_input_fields(self):
super()._clear_all_input_fields()
super()._clear_username_field()
super()._clear_biography_textarea_field()

def check_all_user_settings(self):
super()._click_on_settings_profile_option()
super()._click_on_all_settings_checkboxes()
super()._click_on_update_button()

def check_all_profile_contribution_areas(self, checked: bool):
super()._click_on_settings_profile_option()
super()._click_on_edit_contribution_areas_option()

if not checked:
super()._click_on_unchecked_cont_areas_checkboxes()
else:
super()._click_on_all_checked_cont_areas_checkboxes()

super()._click_on_update_contribution_areas_button()
2 changes: 1 addition & 1 deletion playwright_tests/test_data/aaq_question.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"common_responses_response": "Zoom feature"
},
"troubleshooting_information_kb_article_url": "https://support.mozilla.org/en-US/kb/use-troubleshooting-information-page-fix-firefox",
"troubleshooting_information_textarea_field": "Test Troubleshooting data",
"troubleshooting_information": "Test Troubleshooting data",
"troubleshoot_product_and_os_versions": ["Test os", "Test product version"],
"products_aaq_url": {
"Firefox": "https://support.allizom.org/en-US/questions/new/desktop/form",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,7 @@ def test_post_aaq_questions_for_all_freemium_products_topics(self):
question_info['aaq_subject']
)

self.sumo_pages.question_page._click_delete_this_question_question_tools_option()
self.sumo_pages.question_page._click_delete_this_question_button()
self.sumo_pages.aaq_flow.deleting_question_flow()

self.logger.info(
"Verifying that the question is no longer displayed inside My Questions page")
Expand Down Expand Up @@ -363,7 +362,7 @@ def test_share_firefox_data_functionality(self):

self.logger.info("Adding text inside the troubleshooting information field")
self.sumo_pages.aaq_form_page._add_text_to_troubleshooting_information_textarea(
super().aaq_question_test_data["troubleshooting_information_textarea_field"]
super().aaq_question_test_data["troubleshooting_information"]
)

self.logger.info("Submitting the aaq question")
Expand All @@ -375,16 +374,15 @@ def test_share_firefox_data_functionality(self):

expect(
self.sumo_pages.question_page._get_more_information_with_text_locator(
super().aaq_question_test_data["troubleshooting_information_textarea_field"]
super().aaq_question_test_data["troubleshooting_information"]
)
).to_be_visible()

self.logger.info("Closing additional details panel")
self.sumo_pages.question_page._click_on_the_additional_system_panel_close_button()

self.logger.info("Deleting the posted question")
self.sumo_pages.question_page._click_delete_this_question_question_tools_option()
self.sumo_pages.question_page._click_delete_this_question_button()
self.sumo_pages.aaq_flow.deleting_question_flow()

@pytest.mark.aaqPage
def test_additional_system_details_user_agent_information(self):
Expand Down Expand Up @@ -421,8 +419,7 @@ def test_additional_system_details_user_agent_information(self):
self.sumo_pages.question_page._click_on_the_additional_system_panel_close_button()

self.logger.info("Deleting the posted question")
self.sumo_pages.question_page._click_delete_this_question_question_tools_option()
self.sumo_pages.question_page._click_delete_this_question_button()
self.sumo_pages.aaq_flow.deleting_question_flow()

@pytest.mark.aaqPage
def test_system_details_information(self):
Expand Down Expand Up @@ -480,5 +477,4 @@ def test_system_details_information(self):
)

self.logger.info("Deleting the posted question")
self.sumo_pages.question_page._click_delete_this_question_question_tools_option()
self.sumo_pages.question_page._click_delete_this_question_button()
self.sumo_pages.aaq_flow.deleting_question_flow()
Loading

0 comments on commit a1e41bc

Please sign in to comment.