From 20b5cfb8548dc264160769225a6a68c899b61803 Mon Sep 17 00:00:00 2001 From: Marek Stastny Date: Thu, 28 Nov 2024 09:43:56 +0100 Subject: [PATCH] Use patternfly table --- .../mail_and_messages/test_message_counter.py | 9 +++---- testsuite/ui/views/admin/audience/messages.py | 26 +++++++++---------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/testsuite/tests/ui/mail_and_messages/test_message_counter.py b/testsuite/tests/ui/mail_and_messages/test_message_counter.py index dc6cbf65..e1531dc1 100644 --- a/testsuite/tests/ui/mail_and_messages/test_message_counter.py +++ b/testsuite/tests/ui/mail_and_messages/test_message_counter.py @@ -25,7 +25,6 @@ def send_message_from_devel(navigator, subject, body): # pylint: disable=too-many-arguments -@pytest.mark.disruptive # test should be mark as disruptive because it deletes the state of inbox messages @pytest.mark.usefixtures("login", "application", "service") def test_message_counter(custom_devel_login, custom_admin_login, account, navigator): """ @@ -51,16 +50,16 @@ def test_message_counter(custom_devel_login, custom_admin_login, account, naviga assert_dashboard_counters(navigator, start_msg_count + 2, start_unread_msg_count + 2) admin_messages_view = navigator.navigate(MessagesView) - link = admin_messages_view.get_unread_msg_link(subject="subject1") + link = admin_messages_view.get_unread_msg_link(Subject="subject1", From=account.entity_name) link.click() admin_messages_view = navigator.navigate(MessagesView) - link = admin_messages_view.get_unread_msg_link(subject="subject2") + link = admin_messages_view.get_unread_msg_link(Subject="subject2", From=account.entity_name) link.click() assert_dashboard_counters(navigator, start_msg_count + 2, start_unread_msg_count + 0) admin_messages_view = navigator.navigate(MessagesView) - admin_messages_view.delete_message("subject1") - admin_messages_view.delete_message("subject2") + admin_messages_view.delete_message(Subject="subject1", From=account.entity_name) + admin_messages_view.delete_message(Subject="subject2", From=account.entity_name) assert_dashboard_counters(navigator, start_msg_count + 0, start_unread_msg_count + 0) diff --git a/testsuite/ui/views/admin/audience/messages.py b/testsuite/ui/views/admin/audience/messages.py index 319dd973..183cdbc5 100644 --- a/testsuite/ui/views/admin/audience/messages.py +++ b/testsuite/ui/views/admin/audience/messages.py @@ -39,27 +39,25 @@ def delete_all(self): self.select_dropdown.item_select(select_all_item) # item_select does not have better selector than exact text self.actions_dropdown.open() self.actions_dropdown.item_select("Delete") - time.sleep(1) + self.delete_dialog_button.wait_displayed(timeout="1s") self.delete_dialog_button.click() - def delete_message(self, subject): + def delete_message(self, **kwargs): """ - Deletes first message with given subject + Deletes first message with which matches given text values in columns + e.g. delete_message(Subject='subject1, From='user1') will delete message with subject subject1 from + user user1 if such message exists and is not already deleted. """ - delete_button = self.browser.elements(f"//table[@id='messages']//tr[descendant::a[text()='{subject}']]//button") - if delete_button: - delete_button[0].click() + row = self.table.row(**kwargs) + if row.From.text != '(deleted)': + row[4].click() - def get_unread_msg_link(self, subject=None): + def get_unread_msg_link(self, **kwargs): """Returns link to the first unread message, None if such message does not exist - :param str subject: Specify unread message, with given subject + **kwargs: Allows filter rows by values in the columns. + Keys are names of the columns, values are text values in the specified column. """ - links = self.browser.elements("//tr[contains(@class, 'unread')]//td[@data-label='Subject']/a") - if not links: - return None - if subject: - links = [link for link in links if link.text == subject] - return links[0] + return self.table.row(_row__attr=('class', 'unread'), **kwargs).Subject.browser.element("./a") def get_first_unread_msg_link_gen(self): """