Skip to content

Commit

Permalink
e2e: mentions + new e2e + unread mentions
Browse files Browse the repository at this point in the history
Signed-off-by: Churikova Tetiana <[email protected]>
  • Loading branch information
churik authored and cammellos committed May 28, 2021
1 parent ef13b4d commit 9aa3149
Show file tree
Hide file tree
Showing 15 changed files with 245 additions and 13 deletions.
8 changes: 5 additions & 3 deletions src/status_im/chat/db.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"collapse-gaps will take an array of messages and collapse any gap next to
each other in a single gap.
It will also append one last gap if the last message is a non-gap"
[messages chat-id synced-from]
[messages chat-id synced-from now]
(let [messages-with-gaps (reduce
(fn [acc {:keys [gap-parameters message-id] :as message}]
(let [last-element (peek acc)]
Expand All @@ -81,8 +81,10 @@
(conj acc (assoc message :gap-ids #{message-id})))))
[]
messages)]
;; If it's a gap or the chat is still syncing, do nothing
;; If it's a gap, the chat is still syncing or we are past the maximum data on the mailserver, do nothing
(if (or (nil? synced-from)
(:gap-ids (peek messages-with-gaps)))
(:gap-ids (peek messages-with-gaps))
(and (not (nil? synced-from))
(<= synced-from (- (quot now 1000) constants/one-month))))
messages-with-gaps
(conj messages-with-gaps (last-gap chat-id synced-from)))))
5 changes: 5 additions & 0 deletions src/status_im/constants.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,8 @@
(def ^:const status-community-id "0x039b2da47552aa117a96ea8f1d4d108ba66637c7517a3c94a57b99dbb8a002eda2")

(def ^:const timeline-chat-id "@timeline70bd746ddcc12beb96b2c9d572d0784ab137ffc774f5383e50585a932080b57cca0484b259e61cecbaa33a4c98a300a")

(def ^:const one-day (* 60 60 24))
(def ^:const three-days (* one-day 3))
(def ^:const one-week (* one-day 7))
(def ^:const one-month (* one-day 31))
8 changes: 8 additions & 0 deletions src/status_im/multiaccounts/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@
:webview-allow-permission-requests? (boolean enabled?)
{}))

(fx/defn switch-default-sync-period
{:events [:multiaccounts.ui/default-sync-period-switched]}
[cofx value]
(multiaccounts.update/multiaccount-update
cofx
:default-sync-period value
{}))

(fx/defn switch-preview-privacy-mode-flag
[{:keys [db]}]
(let [private? (get-in db [:multiaccount :preview-privacy?])]
Expand Down
2 changes: 1 addition & 1 deletion src/status_im/subs.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@
(-> message-list-seq
(chat.db/add-datemarks)
(hydrate-messages messages)
(chat.db/collapse-gaps chat-id synced-from))))))
(chat.db/collapse-gaps chat-id synced-from (datetime/timestamp)))))))

;;we want to keep data unchanged so react doesn't change component when we leave screen
(def memo-chat-messages-stream (atom nil))
Expand Down
30 changes: 30 additions & 0 deletions src/status_im/ui/screens/default_sync_period_settings/view.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
(ns status-im.ui.screens.default-sync-period-settings.view
(:require-macros [status-im.utils.views :as views])
(:require [status-im.ui.components.react :as react]
[status-im.i18n.i18n :as i18n]
[status-im.constants :as constants]
[quo.core :as quo]
[re-frame.core :as re-frame]
[status-im.ui.components.topbar :as topbar]))

(def titles {constants/one-day (i18n/label :t/one-day)
constants/three-days (i18n/label :t/three-days)
constants/one-week (i18n/label :t/one-week)
constants/one-month (i18n/label :t/one-month)})

(defn radio-item [id value]
[quo/list-item
{:active (= value id)
:accessory :radio
:title (get titles id)
:on-press #(re-frame/dispatch [:multiaccounts.ui/default-sync-period-switched id])}])

(views/defview default-sync-period-settings []
(views/letsubs [{:keys [default-sync-period]} [:multiaccount]]
[react/view {:flex 1}
[topbar/topbar {:title (i18n/label :t/show-profile-pictures)}]
[react/view {:margin-top 8}
[radio-item constants/one-day default-sync-period]
[radio-item constants/three-days default-sync-period]
[radio-item constants/one-week default-sync-period]
[radio-item constants/one-month default-sync-period]]]))
5 changes: 5 additions & 0 deletions src/status_im/ui/screens/routing/profile_stack.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
[status-im.ui.screens.mobile-network-settings.view
:as
mobile-network-settings]
[status-im.ui.screens.default-sync-period-settings.view
:as
default-sync-period-settings]
[status-im.ui.screens.network.edit-network.views :as edit-network]
[status-im.ui.screens.network.views :as network]
[status-im.ui.screens.network.network-details.views :as network-details]
Expand Down Expand Up @@ -121,6 +124,8 @@
:component fleet-settings/fleet-settings}
{:name :mobile-network-settings
:component mobile-network-settings/mobile-network-settings}
{:name :default-sync-period-settings
:component default-sync-period-settings/default-sync-period-settings}
{:name :backup-seed
:component profile.seed/backup-seed}
{:name :delete-profile
Expand Down
17 changes: 17 additions & 0 deletions src/status_im/ui/screens/sync_settings/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
(:require [re-frame.core :as re-frame]
[quo.core :as quo]
[status-im.i18n.i18n :as i18n]
[status-im.constants :as constants]
[status-im.ui.components.colors :as colors]
[status-im.ui.components.react :as react]
[status-im.ui.components.topbar :as topbar]))

(views/defview sync-settings []
(views/letsubs [{:keys [syncing-on-mobile-network?
default-sync-period
use-mailservers?]} [:multiaccount]
current-mailserver-name [:mailserver/current-name]]
[react/view {:style {:flex 1 :background-color colors/white}}
Expand All @@ -25,6 +27,21 @@
:accessory-text (if syncing-on-mobile-network?
(i18n/label :t/mobile-network-use-mobile)
(i18n/label :t/mobile-network-use-wifi))}]
[quo/list-item {:size :small
:title (i18n/label :t/default-sync-period)
:accessibility-label :default-sync-period-button
:on-press #(re-frame/dispatch [:navigate-to :default-sync-period-settings])
:chevron true
:accessory :text
:accessory-text (cond
(= default-sync-period constants/one-day)
(i18n/label :t/one-day)
(= default-sync-period constants/three-days)
(i18n/label :t/three-days)
(= default-sync-period constants/one-week)
(i18n/label :t/one-week)
(= default-sync-period constants/one-month)
(i18n/label :t/one-month))}]
[quo/list-item {:size :small
:accessibility-label :offline-messages-settings-button
:title (i18n/label :t/history-nodes)
Expand Down
6 changes: 3 additions & 3 deletions status-go-version.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"_comment": "DO NOT EDIT THIS FILE BY HAND. USE 'scripts/update-status-go.sh <tag>' instead",
"owner": "status-im",
"repo": "status-go",
"version": "v0.79.6",
"commit-sha1": "c74c9eedfd16ba06d6076b79f87e4401b19ab621",
"src-sha256": "1g0z0inr8qp2964xkas4365d8v9shh9c8mwrbhhrkdd1yl6ggy4b"
"version": "feature/allow-set-mailserver-sync-value",
"commit-sha1": "d828673de5f83be139fe0c97e97a04abb5c56cd3",
"src-sha256": "1j7a7yvf643k6aa99igmwwjj5agbidljybd65i53d0qbq9iqnmpb"
}
4 changes: 3 additions & 1 deletion test/appium/tests/atomic/account_management/test_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1131,9 +1131,11 @@ def test_ens_mentions_pn_and_nickname_in_public_and_1_1_chats(self):
if not element.is_element_displayed():
self.errors.append('Was not redirected to user profile after tapping on mention!')

home_1.just_fyi('check that PN is received and after tap you are redirected to public chat')
home_1.just_fyi('check that PN is received and after tap you are redirected to public chat, mention is highligted')
home_1.open_notification_bar()
home_1.element_by_text_part(username_2).click()
if home_1.element_starts_with_text(user_1['ens'] +'.stateofus.eth').is_element_differs_from_template('mentioned.png', 2):
self.errors.append('Mention is not highlighted!')
chat_1.element_starts_with_text(user_1['ens'] +'.stateofus.eth','button').click()
if not profile_1.contacts_button.is_element_displayed():
self.errors.append('Was not redirected to own profile after tapping on mention of myself from another user!')
Expand Down
22 changes: 22 additions & 0 deletions test/appium/tests/atomic/chats/test_chats_management.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import time
import random
import emoji

from tests import marks
from tests.users import basic_user, dummy_user, ens_user_ropsten, ens_user, ens_user_message_sender
Expand Down Expand Up @@ -837,6 +839,26 @@ def test_reply_to_message_in_chats(self):
if public_replied_message.replied_message_text != message_from_sender:
self.errors.append("Reply is not present in message received in public chat")

device_1.just_fyi('Can reply to link')
link_message, reply = 'Test with link: https://status.im/', 'reply to link'
chat_public_1.send_message(link_message)
chat_public_2.quote_message(link_message[:10])
chat_public_2.send_message(reply)
public_replied_message = chat_public_1.chat_element_by_text(reply)
if public_replied_message.replied_message_text != link_message:
self.errors.append("Reply for '%s' not present in message received in public chat" % link_message)

device_1.just_fyi('Can reply to emoji message')
reply = 'reply to emoji'
emoji_message = random.choice(list(emoji.EMOJI_UNICODE))
emoji_unicode = emoji.EMOJI_UNICODE[emoji_message]
chat_public_1.send_message(emoji.emojize(emoji_message))
chat_public_2.quote_message(emoji.emojize(emoji_message))
chat_public_2.send_message(reply)
public_replied_message = chat_public_1.chat_element_by_text(reply)
if public_replied_message.replied_message_text != emoji_unicode:
self.errors.append("Reply for '%s' emoji not present in message received in public chat" % emoji_unicode)

self.errors.verify_no_errors()

@marks.testrail_id(6315)
Expand Down
116 changes: 114 additions & 2 deletions test/appium/tests/atomic/chats/test_group_chat.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
from tests import marks
from tests.base_test_case import MultipleDeviceTestCase, SingleDeviceTestCase
from tests.users import transaction_senders, basic_user
from tests.users import transaction_senders, ens_user
from views.sign_in_view import SignInView
from views.chat_view import ChatView
from time import sleep
import random, emoji


class TestGroupChatMultipleDevice(MultipleDeviceTestCase):

@marks.testrail_id(3994)
@marks.high
def test_create_new_group_chat_messaging_pn_delived(self):
def test_create_new_group_chat_messaging_pn_delivered(self):
self.create_drivers(2)
device_1, device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1])
device_1_home, device_2_home = device_1.create_user(), device_2.create_user(enable_notifications=True)
Expand Down Expand Up @@ -407,6 +408,117 @@ def test_rename_group_chat(self):

self.errors.verify_no_errors()

@marks.testrail_id(6327)
@marks.medium
def test_nicknames_ens_group_chats(self):
self.create_drivers(2)
home_1 = SignInView(self.drivers[0]).create_user()
home_2 = SignInView(self.drivers[1]).recover_access(ens_user['passphrase'])
profile_1, profile_2 = [home.profile_button.click() for home in (home_1, home_2)]
key_1, username_1 = profile_1.get_public_key_and_username(return_username=True)
ens, full_ens, username_2 = ens_user['ens'], '@%s' % ens_user['ens'], ens_user['username']
[profile.switch_network() for profile in (profile_1, profile_2)]

home_2.just_fyi('Set ENS')
profile_2 = home_2.profile_button.click()
dapp_view = profile_2.ens_usernames_button.click()
dapp_view.element_by_text('Get started').click()
dapp_view.ens_name_input.set_value(ens)
dapp_view.check_ens_name.click_until_presence_of_element(dapp_view.element_by_translation_id("ens-got-it"))
dapp_view.element_by_translation_id("ens-got-it").click()
home_2.home_button.click()

home_1.just_fyi('Set nickname, using emojis, special chars and cyrrilic chars without adding to contact')
emoji_message = random.choice(list(emoji.EMOJI_UNICODE))
emoji_unicode = emoji.EMOJI_UNICODE[emoji_message]
special_char, cyrrilic = '"£¢€¥~`•|√π¶∆×°™®©%$@', 'стат'
nickname_to_set = emoji.emojize(emoji_message) + special_char + cyrrilic
nickname_expected = emoji_unicode + special_char + cyrrilic
chat_1 = home_1.add_contact(ens, add_in_contacts=False, nickname=nickname_to_set)
if chat_1.user_name_text.text != nickname_expected:
self.errors.append('Expected special char nickname %s does not match actual %s' % (nickname_expected, chat_1.user_name_text.text))

home_1.just_fyi('Can remove nickname without adding to contact')
chat_1.chat_options.click()
chat_1.view_profile_button.click()
chat_1.profile_nickname_button.click()
chat_1.nickname_input_field.clear()
chat_1.element_by_text('Done').click()
chat_1.back_button.click()
if chat_1.user_name_text.text != full_ens:
self.errors.append('Nickname was not removed! real chat name is %s instead of %s' % (chat_1.user_name_text.text, full_ens))

home_1.just_fyi('Adding ENS user to contacts and start group chat with him')
group_name = 'ens_group'
chat_1.add_to_contacts.click()
chat_2 = home_2.add_contact(key_1)
chat_2.send_message("first")
chat_2.home_button.click()
chat_1.home_button.click()
chat_1 = home_1.create_group_chat([full_ens], group_name)
chat_2 = home_2.get_chat(group_name).click()
chat_2.join_chat_button.click()

home_1.just_fyi('Check ENS and in group chat and suggestions list')
chat_1.element_by_text_part(full_ens).wait_for_visibility_of_element(60)
chat_1.select_mention_from_suggestion_list(ens, typed_search_pattern=ens[:2])
if chat_1.chat_message_input.text != '@' + ens + ' ':
self.errors.append(
'ENS username is not resolved in chat input after selecting it in mention suggestions list!')
additional_text = 'and more'
chat_1.send_as_keyevent(additional_text)
chat_1.send_message_button.click()
message_text = '%s %s' % (full_ens, additional_text)
if not chat_1.chat_element_by_text(message_text).is_element_displayed():
self.errors.append("ENS name is not resolved on sent message")
chat_1 = home_1.get_chat_view()

home_1.just_fyi('Set nickname via group info and check that can mention by nickname /username in group chat')
nickname = 'funny_bunny'
device_2_options = chat_1.get_user_options(full_ens)
device_2_options.view_profile_button.click()
chat_1.set_nickname(nickname)
if not chat_1.element_by_text(nickname).is_element_displayed():
self.errors.append('Nickname is not shown in profile view after setting from froup info')
chat_1.back_button.click()
if not chat_1.element_by_text(nickname).is_element_displayed():
self.errors.append('Nickname is not shown in group info view after setting from froup info')
chat_1.back_button.click()
message_text = '%s %s' % (nickname, additional_text)
if not chat_1.chat_element_by_text(message_text).is_element_displayed():
self.errors.append("ENS name was not replaced with nickname on sent message")
chat_1.chat_message_input.send_keys('@')
if not chat_1.element_by_text('%s %s' %(nickname, full_ens)).is_element_displayed():
self.errors.append("ENS name with nickname is not shown in mention input after set")
if not chat_1.element_by_text(username_2).is_element_displayed():
self.errors.append("3-random name is not shown in mention input after set from group info")
chat_1.chat_message_input.clear()
chat_1.select_mention_from_suggestion_list('%s %s' %(nickname, full_ens), typed_search_pattern=username_2[:2])
if chat_1.chat_message_input.text != '@' + ens + ' ':
self.errors.append('ENS is not resolved in chat input after setting nickname in mention suggestions list (search by 3-random name)!')
chat_1.chat_message_input.clear()
chat_1.select_mention_from_suggestion_list('%s %s' % (nickname, full_ens), typed_search_pattern=nickname[:2])
if chat_1.chat_message_input.text != '@' + ens + ' ':
self.errors.append('ENS is not resolved in chat input after setting nickname in mention suggestions list (search by nickname)!')
chat_1.chat_message_input.clear()

home_1.just_fyi('Can delete nickname via group info and recheck received messages')
device_2_options = chat_1.get_user_options(full_ens)
device_2_options.view_profile_button.click()
chat_1.profile_nickname_button.click()
chat_1.nickname_input_field.clear()
chat_1.element_by_text('Done').click()
chat_1.back_button.click()
chat_1.back_button.click()
message_text = '%s %s' % (full_ens, additional_text)
if not chat_1.chat_element_by_text(message_text).is_element_displayed():
self.errors.append("ENS name is not resolved on sent message after removing nickname")
chat_1.chat_message_input.send_keys('@')
if chat_1.element_by_text_part(nickname).is_element_displayed():
self.errors.append("Nickname is shown in group chat after removing!")

self.errors.verify_no_errors()

@marks.testrail_id(5752)
@marks.medium
def test_block_and_unblock_user_from_group_chat_via_group_info(self):
Expand Down
14 changes: 13 additions & 1 deletion test/appium/tests/atomic/chats/test_public.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,14 @@ def test_unread_messages_counter_public_chat(self):
self.create_drivers(2)
driver_2 = self.drivers[1]
home_1, home_2 = SignInView(self.drivers[0]).create_user(), SignInView(self.drivers[1]).create_user()
profile_1 = home_1.profile_button.click()
username_1 = profile_1.default_username_text.text
profile_1.home_button.click()

chat_name = home_1.get_random_chat_name()
chat_1, chat_2 = home_1.join_public_chat(chat_name), home_2.join_public_chat(chat_name)
home_1.get_back_to_home_view()
chat_1.send_message('пиу')
chat_1.home_button.click()
message, message_2 = 'test message', 'test message2'
chat_2.send_message(message)

Expand All @@ -77,6 +81,14 @@ def test_unread_messages_counter_public_chat(self):
chat_element = home_1.get_chat('#' + chat_name)
if not chat_element.new_messages_public_chat.is_element_displayed():
self.errors.append('New messages counter is not shown in public chat')

home_1.just_fyi("Check unread message counter when mentioned in public chat")
chat_2 = home_2.get_chat_view()
chat_2.select_mention_from_suggestion_list(username_1, username_1[:2])
chat_2.send_message_button.click()
if chat_element.new_messages_counter.text == '1':
self.errors.append('Counter is not shown for mention in public chat')

chat_element.click()
home_1.home_button.double_click()

Expand Down
Loading

0 comments on commit 9aa3149

Please sign in to comment.