Skip to content

Commit

Permalink
Use patternfly table
Browse files Browse the repository at this point in the history
  • Loading branch information
mastastny committed Nov 28, 2024
1 parent 2f0a7af commit 20b5cfb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
9 changes: 4 additions & 5 deletions testsuite/tests/ui/mail_and_messages/test_message_counter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand All @@ -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)
26 changes: 12 additions & 14 deletions testsuite/ui/views/admin/audience/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down

0 comments on commit 20b5cfb

Please sign in to comment.