Skip to content

Commit 90d3a5a

Browse files
committed
e2e: test fixes
1 parent dd8beeb commit 90d3a5a

File tree

3 files changed

+31
-11
lines changed

3 files changed

+31
-11
lines changed

test/appium/tests/critical/chats/test_public_chat_browsing.py

+26-11
Original file line numberDiff line numberDiff line change
@@ -121,20 +121,30 @@ def test_community_mute_community_and_channel(self):
121121
self.home.mute_chat_long_press(chat_name=self.community_name, mute_period="mute-for-1-hour", community=True)
122122
device_time = self.home.driver.device_time
123123
current_time = datetime.datetime.strptime(device_time, "%Y-%m-%dT%H:%M:%S%z")
124-
expected_time = current_time + datetime.timedelta(hours=1)
125-
expected_text = "Muted until %s %s" % (
126-
expected_time.strftime('%H:%M'),
127-
"today" if current_time.hour < 23 else "tomorrow"
128-
)
124+
expected_times = [current_time + datetime.timedelta(minutes=i) for i in range(59, 62)]
125+
expected_texts = ["Muted until %s %s" % (
126+
exp_time.strftime('%H:%M'), "today" if current_time.hour < 23 else "tomorrow"
127+
) for exp_time in expected_times]
128+
129129
self.home.get_chat(self.community_name, community=True).long_press_element()
130-
if not self.home.element_by_text(expected_text).is_element_displayed():
131-
self.errors.append("Text '%s' is not shown for muted community" % expected_text)
130+
self.home.unmute_community_button.wait_for_visibility_of_element()
131+
try:
132+
current_text = self.home.unmute_community_button.unmute_caption_text
133+
if current_text not in expected_texts:
134+
self.errors.append("Text '%s' is not shown for muted community" % expected_texts[1])
135+
except NoSuchElementException:
136+
self.errors.append("Caption with text 'Muted until...' is not shown for muted community")
132137
self.home.click_system_back_button()
133138

134139
self.home.get_chat(self.community_name, community=True).click()
135140
self.community_view.get_channel(self.channel_name).long_press_element()
136-
if not self.home.element_by_text(expected_text).is_element_displayed():
137-
self.errors.append("Text '%s' is not shown for a channel in muted community" % expected_text)
141+
self.home.mute_channel_button.wait_for_visibility_of_element()
142+
try:
143+
current_text = self.home.mute_channel_button.unmute_caption_text
144+
if current_text not in expected_texts:
145+
self.errors.append("Text '%s' is not shown for a channel in muted community" % expected_texts[1])
146+
except NoSuchElementException:
147+
self.errors.append("Caption with text 'Muted until...' is not shown for a channel in muted community")
138148

139149
self.home.just_fyi("Unmute channel and check that the community is also unmuted")
140150
self.home.mute_channel_button.click()
@@ -154,8 +164,13 @@ def test_community_mute_community_and_channel(self):
154164
expected_time = current_time + datetime.timedelta(days=7)
155165
expected_text = "Muted until %s" % expected_time.strftime('%H:%M %a %-d %b')
156166
self.community_view.get_channel(self.channel_name).long_press_element()
157-
if not self.home.element_by_text(expected_text).is_element_displayed():
158-
self.errors.append("Text '%s' is not shown for a muted community channel" % expected_text)
167+
self.home.mute_channel_button.wait_for_visibility_of_element()
168+
try:
169+
current_text = self.home.mute_channel_button.unmute_caption_text
170+
if current_text != expected_text:
171+
self.errors.append("Text '%s' is not shown for a muted community channel" % expected_text)
172+
except NoSuchElementException:
173+
self.errors.append("Caption with text '%s' is not shown for a muted community channel" % expected_text)
159174
self.home.click_system_back_button()
160175
self.home.navigate_back_to_home_view()
161176
self.home.communities_tab.click()
53 Bytes
Loading

test/appium/views/home_view.py

+5
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,10 @@ def __init__(self, driver, accessibility_id):
212212
def text(self):
213213
return self.find_element().find_element(by=MobileBy.CLASS_NAME, value="android.widget.TextView").text
214214

215+
@property
216+
def unmute_caption_text(self):
217+
return self.find_element().find_element(by=MobileBy.XPATH, value="//android.widget.TextView[2]").text
218+
215219

216220
class HomeView(BaseView):
217221
def __init__(self, driver):
@@ -276,6 +280,7 @@ def __init__(self, driver):
276280
self.clear_history_button = Button(self.driver, accessibility_id="clear-history")
277281
self.mute_chat_button = MuteButton(self.driver, accessibility_id="mute-chat")
278282
self.mute_community_button = MuteButton(self.driver, accessibility_id="mute-community")
283+
self.unmute_community_button = MuteButton(self.driver, accessibility_id="unmute-community")
279284
self.mute_channel_button = MuteButton(self.driver, accessibility_id="chat-toggle-muted")
280285
self.mark_all_messages_as_read_button = Button(self.driver, accessibility_id="mark-as-read")
281286

0 commit comments

Comments
 (0)