From 9e5b8b5f9ccec332ba9d335688bfe99661572c7f Mon Sep 17 00:00:00 2001 From: Mohsen Date: Tue, 19 Mar 2024 20:57:58 +0300 Subject: [PATCH] [#19247] feat: migrate to new contact profile (#19246) Co-authored-by: Yevheniia Berdnyk Co-authored-by: Sean Hagstrom --- .env | 1 - src/legacy/status_im/contact/block.cljs | 11 ++-- .../text_combinations/page_top/view.cljs | 5 +- .../text_combinations/username/view.cljs | 14 +++-- src/status_im/common/scroll_page/view.cljs | 5 +- src/status_im/constants.cljs | 1 + src/status_im/contexts/chat/events.cljs | 8 +-- .../profile/contact/actions/view.cljs | 34 +++++----- .../profile/contact/add_nickname/view.cljs | 11 ++-- .../profile/contact/block_contact/view.cljs | 62 +++++++++---------- .../profile/contact/contact_request/view.cljs | 22 ++++--- .../profile/contact/header/style.cljs | 4 ++ .../contexts/profile/contact/header/view.cljs | 52 +++++++++++----- .../contexts/profile/contact/view.cljs | 54 +++++++++++----- src/status_im/feature_flags.cljs | 1 - .../activity_center/test_activity_center.py | 24 ++++--- .../critical/chats/test_1_1_public_chats.py | 4 +- .../tests/critical/chats/test_group_chat.py | 2 +- .../chats/test_public_chat_browsing.py | 4 +- .../critical/test_deep_and_universal_links.py | 12 ++-- test/appium/views/chat_view.py | 31 +++------- test/appium/views/home_view.py | 19 ++---- test/appium/views/profile_view.py | 1 + translations/en.json | 1 + 24 files changed, 214 insertions(+), 169 deletions(-) diff --git a/.env b/.env index 9d31feb57e..094c61e7b7 100644 --- a/.env +++ b/.env @@ -34,4 +34,3 @@ STICKERS_TEST_ENABLED=1 LOCAL_PAIRING_ENABLED=1 TEST_STATEOFUS=1 FAST_CREATE_COMMUNITY_ENABLED=1 -FLAG_NEW_CONTACT_UI_ENABLED=0 diff --git a/src/legacy/status_im/contact/block.cljs b/src/legacy/status_im/contact/block.cljs index ba8479b72a..607c476f5a 100644 --- a/src/legacy/status_im/contact/block.cljs +++ b/src/legacy/status_im/contact/block.cljs @@ -58,7 +58,9 @@ (rf/defn block-contact {:events [:contact.ui/block-contact-confirmed]} - [{:keys [db] :as cofx} public-key] + [{:keys [db] :as cofx} public-key + {:keys [handle-navigation?] + :or {handle-navigation? true}}] (let [contact (-> (contact.db/public-key->contact (:contacts/contacts db) public-key) @@ -75,9 +77,10 @@ (re-frame/dispatch [:sanitize-messages-and-process-response block-contact]) (re-frame/dispatch [:hide-popover]))) ;; reset navigation to avoid going back to non existing one to one chat - (if from-one-to-one-chat? - (navigation/pop-to-root :shell-stack) - (navigation/navigate-back))))) + (when handle-navigation? + (if from-one-to-one-chat? + (navigation/pop-to-root :shell-stack) + (navigation/navigate-back)))))) (rf/defn contact-unblocked {:events [:contacts/unblocked]} diff --git a/src/quo/components/text_combinations/page_top/view.cljs b/src/quo/components/text_combinations/page_top/view.cljs index c4d0fdaddb..b8110557da 100644 --- a/src/quo/components/text_combinations/page_top/view.cljs +++ b/src/quo/components/text_combinations/page_top/view.cljs @@ -115,12 +115,13 @@ emojis)) (defn- view-internal - [{:keys [theme description input blur? input-props container-style] + [{:keys [theme description title input blur? input-props container-style] emojis :emoji-dash :as props}] [rn/view {:style container-style} [rn/view {:style style/top-container} - [header props] + (when (or title input) + [header props]) (when description [description-container props]) (when emojis diff --git a/src/quo/components/text_combinations/username/view.cljs b/src/quo/components/text_combinations/username/view.cljs index df7170dc84..65e9ad31e3 100644 --- a/src/quo/components/text_combinations/username/view.cljs +++ b/src/quo/components/text_combinations/username/view.cljs @@ -7,12 +7,13 @@ [react-native.core :as rn])) (defn- username-text - [{:keys [theme name-type username blur?] + [{:keys [theme name-type username accessibility-label blur?] real-name :name}] [rn/view {:style style/username-text-container} [text/text - {:size :heading-1 - :weight :semi-bold} + {:size :heading-1 + :accessibility-label accessibility-label + :weight :semi-bold} username] (when (= name-type :nickname) [:<> @@ -22,9 +23,10 @@ :weight :medium} "∙"] [text/text - {:style (style/real-name-text theme blur?) - :size :paragraph-1 - :weight :medium} + {:style (style/real-name-text theme blur?) + :size :paragraph-1 + :accessibility-label :real-name + :weight :medium} real-name]])]) (defn- icon-20 diff --git a/src/status_im/common/scroll_page/view.cljs b/src/status_im/common/scroll_page/view.cljs index c68beeccbf..72d72b91c3 100644 --- a/src/status_im/common/scroll_page/view.cljs +++ b/src/status_im/common/scroll_page/view.cljs @@ -68,8 +68,9 @@ :right-side page-nav-right-section-buttons :center-opacity (reanimated/get-shared-value opacity-animation) :overlay-shown? overlay-shown?} - navigate-back? (assoc :icon-name :i/close - :on-press #(rf/dispatch [:navigate-back])) + navigate-back? (assoc :icon-name :i/close + :accessibility-label :back-button + :on-press #(rf/dispatch [:navigate-back])) page-nav-props (merge page-nav-props))]) (when title-colum title-colum) diff --git a/src/status_im/constants.cljs b/src/status_im/constants.cljs index 90dd28c0ea..65a84acd4a 100644 --- a/src/status_im/constants.cljs +++ b/src/status_im/constants.cljs @@ -73,6 +73,7 @@ (def ^:const contact-request-message-state-pending 1) (def ^:const contact-request-message-state-accepted 2) (def ^:const contact-request-message-state-declined 3) +(def ^:const contact-request-message-max-length 280) (def request-to-join-pending-state 1) diff --git a/src/status_im/contexts/chat/events.cljs b/src/status_im/contexts/chat/events.cljs index 50af142c95..0d574b4ee4 100644 --- a/src/status_im/contexts/chat/events.cljs +++ b/src/status_im/contexts/chat/events.cljs @@ -14,7 +14,6 @@ [status-im.contexts.chat.messenger.messages.delete-message-for-me.events :as delete-for-me] [status-im.contexts.chat.messenger.messages.delete-message.events :as delete-message] [status-im.contexts.chat.messenger.messages.list.state :as chat.state] - [status-im.feature-flags :as ff] [status-im.navigation.events :as navigation] [taoensso.timbre :as log] [utils.datetime :as datetime] @@ -444,8 +443,5 @@ {:pubkey public-key :ens ens-name :success-fn (fn [_] - {:dispatch [:open-modal - (if (ff/enabled? ::ff/profile.new-contact-ui) - :contact-profile - :profile)]})}]} - {:dispatch [:navigate-to :my-profile]})))) + {:dispatch [:open-modal :contact-profile]})}]} + {:dispatch [:open-modal :settings]})))) diff --git a/src/status_im/contexts/profile/contact/actions/view.cljs b/src/status_im/contexts/profile/contact/actions/view.cljs index 7f929bef3d..991c679296 100644 --- a/src/status_im/contexts/profile/contact/actions/view.cljs +++ b/src/status_im/contexts/profile/contact/actions/view.cljs @@ -68,24 +68,24 @@ (i18n/label :t/edit-nickname) (i18n/label :t/add-nickname-title)) :on-press on-add-nickname - :accessibility-label (if nickname :edit-nickname :add-nickname)} - {:icon :i/qr-code - :label (i18n/label :t/show-qr) - :on-press on-show-qr - :accessibility-label :show-qr-code} - {:icon :i/share - :label (i18n/label :t/share-profile) - :on-press on-share-profile - :accessibility-label :share-profile} - (when has-nickname? - {:icon :i/delete - :label (i18n/label :t/remove-nickname) - :on-press on-remove-nickname - :add-divider? true - :accessibility-label :remove-nickname - :danger? true})] + :accessibility-label (if nickname :edit-nickname :add-nickname)}] (when-not blocked? - [{:icon :i/untrustworthy + [{:icon :i/qr-code + :label (i18n/label :t/show-qr) + :on-press on-show-qr + :accessibility-label :show-qr-code} + {:icon :i/share + :label (i18n/label :t/share-profile) + :on-press on-share-profile + :accessibility-label :share-profile} + (when has-nickname? + {:icon :i/delete + :label (i18n/label :t/remove-nickname) + :on-press on-remove-nickname + :add-divider? true + :accessibility-label :remove-nickname + :danger? true}) + {:icon :i/untrustworthy :label (i18n/label :t/mark-untrustworthy) :on-press not-implemented/alert :accessibility-label :mark-untrustworthy diff --git a/src/status_im/contexts/profile/contact/add_nickname/view.cljs b/src/status_im/contexts/profile/contact/add_nickname/view.cljs index a6754a6e03..8441bd0195 100644 --- a/src/status_im/contexts/profile/contact/add_nickname/view.cljs +++ b/src/status_im/contexts/profile/contact/add_nickname/view.cljs @@ -20,6 +20,8 @@ profile-picture (profile.utils/photo profile) [unsaved-nickname set-unsaved-nickname] (rn/use-state nickname) [error-msg set-error-msg] (rn/use-state nil) + has-nickname? (rn/use-memo (fn [] (not (string/blank? nickname))) + [nickname]) validate-nickname (rn/use-callback (debounce/debounce (fn [name] @@ -72,10 +74,11 @@ (i18n/label :t/nickname-visible-to-you))]] [quo/bottom-actions {:actions :two-actions - :button-one-label (i18n/label :t/add-nickname-title) - :button-one-props {:disabled? (or (string/blank? unsaved-nickname) - (not (string/blank? error-msg))) - :on-press on-nickname-submit} + :button-one-label (i18n/label (if has-nickname? :t/update-nickname-title :t/add-nickname-title)) + :button-one-props {:disabled? (or (string/blank? unsaved-nickname) + (not (string/blank? error-msg))) + :customization-color customization-color + :on-press on-nickname-submit} :button-two-label (i18n/label :t/cancel) :button-two-props {:type :grey :on-press on-cancel}}]])) diff --git a/src/status_im/contexts/profile/contact/block_contact/view.cljs b/src/status_im/contexts/profile/contact/block_contact/view.cljs index a511823797..76b350ff5a 100644 --- a/src/status_im/contexts/profile/contact/block_contact/view.cljs +++ b/src/status_im/contexts/profile/contact/block_contact/view.cljs @@ -12,28 +12,26 @@ (defn view [] (let [{:keys [customization-color contact-request-state public-key] - :as contact} (rf/sub [:contacts/current-contact]) + :as contact} (rf/sub [:contacts/current-contact]) ;; TODO(@mohsen): remove default color, https://github.com/status-im/status-mobile/issues/18733 - customization-color (or customization-color constants/profile-default-color) - full-name (profile.utils/displayed-name contact) - profile-picture (profile.utils/photo contact) - [remove-contact? set-remove-contact?] (rn/use-state false) - on-remove-toggle (rn/use-callback #(set-remove-contact? not) []) - on-block-press (rn/use-callback - (fn [] - (rf/dispatch [:toasts/upsert - {:id :user-blocked - :type :positive - :text (i18n/label :t/user-blocked - {:username - full-name})}]) - (rf/dispatch [:contact.ui/block-contact-confirmed - public-key]) - (when remove-contact? - (rf/dispatch [:contact.ui/remove-contact-pressed - {:public-key public-key}])) - (on-close)) - [remove-contact? public-key full-name])] + customization-color (or customization-color constants/profile-default-color) + full-name (profile.utils/displayed-name contact) + profile-picture (profile.utils/photo contact) + on-block-press (rn/use-callback + (fn [] + (rf/dispatch [:toasts/upsert + {:id :user-blocked + :type :positive + :text (i18n/label :t/user-blocked + {:username + full-name})}]) + (rf/dispatch [:contact.ui/block-contact-confirmed + public-key + {:handle-navigation? false}]) + (rf/dispatch [:contact.ui/remove-contact-pressed + {:public-key public-key}]) + (on-close)) + [public-key full-name])] [:<> [quo/drawer-top {:type :context-tag @@ -52,19 +50,21 @@ :type :default} (i18n/label :t/blocking-a-user-message {:username full-name})] (when (= constants/contact-request-state-mutual contact-request-state) - [rn/pressable - {:style style/checkbox-wrapper - :on-press on-remove-toggle} + [rn/view + {:style style/checkbox-wrapper} [quo/selectors - {:type :checkbox - :checked? remove-contact? - :on-change on-remove-toggle}] + {:type :checkbox + :customization-color customization-color + :checked? true + :disabled? true}] [quo/text (i18n/label :t/remove-contact)]])] [quo/bottom-actions {:actions :two-actions :button-one-label (i18n/label :t/block) - :button-one-props {:type :danger - :on-press on-block-press} + :button-one-props {:type :danger + :accessibility-label :block-contact + :on-press on-block-press} :button-two-label (i18n/label :t/cancel) - :button-two-props {:type :grey - :on-press on-close}}]])) + :button-two-props {:type :grey + :accessibility-label :cancel + :on-press on-close}}]])) diff --git a/src/status_im/contexts/profile/contact/contact_request/view.cljs b/src/status_im/contexts/profile/contact/contact_request/view.cljs index fb5d9b3b4e..17c5e3334f 100644 --- a/src/status_im/contexts/profile/contact/contact_request/view.cljs +++ b/src/status_im/contexts/profile/contact/contact_request/view.cljs @@ -36,18 +36,24 @@ :full-name full-name :profile-picture profile-picture :customization-color customization-color}] - [rn/text {:style style/message-prompt-wrapper} + [quo/text {:style style/message-prompt-wrapper} (i18n/label :t/contact-request-message-prompt)] [rn/view {:style style/message-input-wrapper} [quo/input - {:type :text - :multiline? true - :char-limit 280 - :label (i18n/label :t/message) - :on-change-text on-message-change}]] + {:type :text + :multiline? true + :char-limit constants/contact-request-message-max-length + :max-length constants/contact-request-message-max-length + :placeholder (i18n/label :t/type-something) + :auto-focus true + :accessibility-label :contact-request-message + :label (i18n/label :t/message) + :on-change-text on-message-change}]] [quo/bottom-actions {:actions :one-action - :button-one-props {:disabled? (string/blank? message) - :on-press on-message-submit} + :button-one-props {:disabled? (string/blank? message) + :accessibility-label :send-contact-request + :customization-color customization-color + :on-press on-message-submit} :button-one-label (i18n/label :t/send-contact-request)}]])) diff --git a/src/status_im/contexts/profile/contact/header/style.cljs b/src/status_im/contexts/profile/contact/header/style.cljs index a2b2025c00..b452604ab9 100644 --- a/src/status_im/contexts/profile/contact/header/style.cljs +++ b/src/status_im/contexts/profile/contact/header/style.cljs @@ -12,6 +12,10 @@ :margin-bottom 16 :padding-horizontal 20}) +(def username-wrapper + {:margin-top 12 + :padding-horizontal 20}) + (defn header-container [border-radius theme margin-top] (reanimated/apply-animations-to-style diff --git a/src/status_im/contexts/profile/contact/header/view.cljs b/src/status_im/contexts/profile/contact/header/view.cljs index cdefb26930..ec5751f459 100644 --- a/src/status_im/contexts/profile/contact/header/view.cljs +++ b/src/status_im/contexts/profile/contact/header/view.cljs @@ -1,5 +1,6 @@ (ns status-im.contexts.profile.contact.header.view - (:require [quo.core :as quo] + (:require [clojure.string :as string] + [quo.core :as quo] [quo.foundations.colors :as colors] [quo.theme] [react-native.core :as rn] @@ -25,7 +26,7 @@ (defn view [{:keys [scroll-y]}] - (let [{:keys [public-key customization-color ens-name + (let [{:keys [public-key customization-color ens-name nickname secondary-name emoji-hash bio blocked? contact-request-state] :as contact} (rf/sub [:contacts/current-contact]) ;; TODO(@mohsen): remove default color, https://github.com/status-im/status-mobile/issues/18733 @@ -34,6 +35,13 @@ profile-picture (profile.utils/photo contact) online? (rf/sub [:visibility-status-updates/online? public-key]) theme (quo.theme/use-theme-value) + contact-status (rn/use-memo (fn [] + (cond + (= contact-request-state + constants/contact-request-state-mutual) :contact + blocked? :blocked + :else nil)) + [blocked? contact-request-state]) on-start-chat (rn/use-callback #(rf/dispatch [:chat.ui/start-chat public-key ens-name]) @@ -64,17 +72,24 @@ {:label (i18n/label :t/contact-profile-request-pending) :status {:type :pending} :size :large}]])] + [rn/view {:style style/username-wrapper} + [quo/username + {:name-type (if-not (string/blank? nickname) :nickname :default) + :accessibility-label :contact-name + :username full-name + :status contact-status + :name secondary-name}]] [quo/page-top - {:title full-name - :description :text - :description-text bio + {:description :text + :description-text (when-not blocked? bio) :emoji-dash emoji-hash}] (when blocked? [quo/button - {:container-style style/button-wrapper - :on-press on-unblock-press - :icon-left :i/block} + {:container-style style/button-wrapper + :on-press on-unblock-press + :customization-color customization-color + :icon-left :i/block} (i18n/label :t/unblock)]) (cond @@ -85,23 +100,26 @@ (= contact-request-state constants/contact-request-state-dismissed))) [quo/button - {:container-style style/button-wrapper - :on-press on-contact-request - :icon-left :i/add-user} + {:container-style style/button-wrapper + :on-press on-contact-request + :customization-color customization-color + :icon-left :i/add-user} (i18n/label :t/send-contact-request)] (= contact-request-state constants/contact-request-state-received) [quo/button - {:container-style style/button-wrapper - :on-press on-contact-review - :icon-left :i/add-user} + {:container-style style/button-wrapper + :on-press on-contact-review + :customization-color customization-color + :icon-left :i/add-user} (i18n/label :t/contact-request-review)] (= contact-request-state constants/contact-request-state-mutual) [quo/button - {:container-style style/button-wrapper - :on-press on-start-chat - :icon-left :i/messages} + {:container-style style/button-wrapper + :on-press on-start-chat + :customization-color customization-color + :icon-left :i/messages} (i18n/label :t/send-message)] :else nil)])) diff --git a/src/status_im/contexts/profile/contact/view.cljs b/src/status_im/contexts/profile/contact/view.cljs index e7f0e099ef..10ca3551d0 100644 --- a/src/status_im/contexts/profile/contact/view.cljs +++ b/src/status_im/contexts/profile/contact/view.cljs @@ -1,30 +1,50 @@ (ns status-im.contexts.profile.contact.view - (:require [quo.foundations.colors :as colors] + (:require [quo.core :as quo] + [quo.foundations.colors :as colors] [quo.theme] - [react-native.core :as rn] [react-native.reanimated :as reanimated] [status-im.common.scroll-page.view :as scroll-page] [status-im.constants :as constants] [status-im.contexts.profile.contact.actions.view :as actions] [status-im.contexts.profile.contact.header.view :as contact-header] + [status-im.contexts.shell.jump-to.constants :as jump-to.constants] + [utils.debounce :as debounce] + [utils.i18n :as i18n] [utils.re-frame :as rf])) +(defn on-show-actions + [] + (rf/dispatch [:show-bottom-sheet + {:content (fn [] [actions/view])}])) + +(defn on-jump-to + [] + (rf/dispatch [:navigate-back]) + (debounce/throttle-and-dispatch [:shell/navigate-to-jump-to] 500)) + (defn view [] (let [{:keys [customization-color]} (rf/sub [:contacts/current-contact]) scroll-y (reanimated/use-shared-value 0) - theme (quo.theme/use-theme-value) - on-action-press (rn/use-callback (fn [] - (rf/dispatch [:show-bottom-sheet - {:content (fn [] - [actions/view])}])))] - [scroll-page/scroll-page - {:navigate-back? true - :height 148 - :on-scroll #(reanimated/set-shared-value scroll-y %) - ;; TODO(@mohsen): remove default color, https://github.com/status-im/status-mobile/issues/18733 - :cover-color (or customization-color constants/profile-default-color) - :background-color (colors/theme-colors colors/white colors/neutral-95 theme) - :page-nav-props {:right-side [{:icon-name :i/options - :on-press on-action-press}]}} - [contact-header/view {:scroll-y scroll-y}]])) + theme (quo.theme/use-theme-value)] + [:<> + [scroll-page/scroll-page + {:navigate-back? true + :height 148 + :on-scroll #(reanimated/set-shared-value scroll-y %) + ;; TODO(@mohsen): remove default color, https://github.com/status-im/status-mobile/issues/18733 + :cover-color (colors/resolve-color (or customization-color constants/profile-default-color) + theme + 20) + :background-color (colors/theme-colors colors/white colors/neutral-95 theme) + :page-nav-props {:right-side [{:icon-name :i/options + :on-press on-show-actions + :accessibility-label :contact-actions}]}} + [contact-header/view {:scroll-y scroll-y}]] + [quo/floating-shell-button + {:jump-to + {:on-press on-jump-to + :customization-color customization-color + :label (i18n/label :t/jump-to)}} + {:position :absolute + :bottom jump-to.constants/floating-shell-button-height}]])) diff --git a/src/status_im/feature_flags.cljs b/src/status_im/feature_flags.cljs index a6cf042c3d..f19a5c3084 100644 --- a/src/status_im/feature_flags.cljs +++ b/src/status_im/feature_flags.cljs @@ -15,7 +15,6 @@ ::wallet.edit-derivation-path (enabled-in-env? :FLAG_EDIT_DERIVATION_PATH) ::wallet.remove-account (enabled-in-env? :FLAG_REMOVE_ACCOUNT_ENABLED) ::wallet.network-filter (enabled-in-env? :FLAG_NETWORK_FILTER_ENABLED) - ::profile.new-contact-ui (enabled-in-env? :FLAG_NEW_CONTACT_UI_ENABLED) ::community.edit-account-selection (enabled-in-env? :FLAG_EDIT_ACCOUNT_SELECTION_ENABLED)})) (defn feature-flags [] @feature-flags-config) diff --git a/test/appium/tests/activity_center/test_activity_center.py b/test/appium/tests/activity_center/test_activity_center.py index 99c95bd565..30f53082d9 100644 --- a/test/appium/tests/activity_center/test_activity_center.py +++ b/test/appium/tests/activity_center/test_activity_center.py @@ -49,8 +49,11 @@ class TestActivityCenterContactRequestMultipleDevicePR(MultipleSharedDeviceTestC self.errors.append("User is not found on 'Add contact' page after entering valid public key") chat = self.home_2.get_chat_view() - chat.view_profile_new_contact_button.click_until_presence_of_element(chat.profile_block_contact_button) - chat.profile_add_to_contacts_button.click() + chat.view_profile_new_contact_button.click_until_presence_of_element(chat.profile_send_contact_request_button) + chat.profile_send_contact_request_button.click() + chat.contact_request_message_input.send_keys("hi") + chat.confirm_send_contact_request_button.click() + chat.close_button.click_until_absense_of_element(chat.close_button) self.home_2.navigate_back_to_home_view() self.device_1.just_fyi("Device 1: check there is no PN when receiving new message to activity centre") @@ -83,7 +86,7 @@ class TestActivityCenterContactRequestMultipleDevicePR(MultipleSharedDeviceTestC self.home_2.open_activity_center_button.click() self.home_2.activity_unread_filter_button.click() if not self.home_2.element_by_text_part( - self.home_2.get_translation_by_key("add-me-to-your-contacts")).is_element_displayed(30): + self.home_2.get_translation_by_key("contact-request-outgoing")).is_element_displayed(30): self.errors.append( "Pending contact request is not shown on unread notification element on Activity center!") self.home_2.close_activity_centre.click() @@ -105,8 +108,11 @@ class TestActivityCenterContactRequestMultipleDevicePR(MultipleSharedDeviceTestC self.home_2.element_by_translation_id("paste").click() self.home_2.element_by_translation_id("user-found").wait_for_visibility_of_element(10) chat = self.home_2.get_chat_view() - chat.view_profile_new_contact_button.click_until_presence_of_element(chat.profile_block_contact_button) - chat.profile_add_to_contacts_button.click() + chat.view_profile_new_contact_button.click_until_presence_of_element(chat.profile_send_contact_request_button) + chat.profile_send_contact_request_button.click() + chat.contact_request_message_input.send_keys("hi") + chat.confirm_send_contact_request_button.click() + chat.close_button.click_until_absense_of_element(chat.close_button) self.device_1.just_fyi('Device1 accepts pending contact request by swiping') self.home_1.chats_tab.click() @@ -184,8 +190,12 @@ class TestActivityCenterContactRequestMultipleDevicePR(MultipleSharedDeviceTestC else: self.errors.append("User is not found on 'Add contact' page after entering valid public key") chat_1 = self.home_1.get_chat_view() - chat_1.view_profile_new_contact_button.click_until_presence_of_element(chat_1.profile_block_contact_button) - chat_1.profile_add_to_contacts_button.click() + chat_1.view_profile_new_contact_button.click_until_presence_of_element( + chat_1.profile_send_contact_request_button) + chat_1.profile_send_contact_request_button.click() + chat_1.contact_request_message_input.send_keys("hi") + chat_1.confirm_send_contact_request_button.click() + chat_1.close_button.click_until_absense_of_element(chat_1.close_button) self.home_2.just_fyi("Device 2 accepts contact request") self.home_2.handle_contact_request(new_username_1) diff --git a/test/appium/tests/critical/chats/test_1_1_public_chats.py b/test/appium/tests/critical/chats/test_1_1_public_chats.py index 4fc4367170..7201ad3175 100644 --- a/test/appium/tests/critical/chats/test_1_1_public_chats.py +++ b/test/appium/tests/critical/chats/test_1_1_public_chats.py @@ -34,7 +34,7 @@ class TestOneToOneChatMultipleSharedDevicesNewUi(MultipleSharedDeviceTestCase): for home in (self.home_1, self.home_2): home.navigate_back_to_home_view() home.chats_tab.click() - self.home_1.send_contact_request_via_bottom_sheet(self.public_key_2) + self.home_1.add_contact(self.public_key_2) self.home_2.just_fyi("Accepting contact request from activity centre") self.home_2.handle_contact_request(self.username_1) @@ -538,7 +538,7 @@ class TestOneToOneChatMultipleSharedDevicesNewUiTwo(MultipleSharedDeviceTestCase for home in (self.home_1, self.home_2): home.navigate_back_to_home_view() home.chats_tab.click() - self.home_1.send_contact_request_via_bottom_sheet(self.public_key_2) + self.home_1.add_contact(self.public_key_2) self.home_2.just_fyi("Accepting contact request from activity centre") self.home_2.handle_contact_request(self.username_1) diff --git a/test/appium/tests/critical/chats/test_group_chat.py b/test/appium/tests/critical/chats/test_group_chat.py index f3758c636b..68c82ff5b4 100644 --- a/test/appium/tests/critical/chats/test_group_chat.py +++ b/test/appium/tests/critical/chats/test_group_chat.py @@ -143,7 +143,7 @@ class TestGroupChatMultipleDeviceMergedNewUI(MultipleSharedDeviceTestCase): self.chats[0].just_fyi("Admin opens member_2 profile") self.chats[0].user_list_element_by_name(self.usernames[2]).click() try: - username_shown = self.chats[0].get_profile_view().default_username_text.text + username_shown = self.chats[0].get_profile_view().contact_name_text.text if username_shown != self.usernames[2]: self.errors.append( "Incorrect profile is opened from the list of reactions, username is %s but expected to be %s" % ( diff --git a/test/appium/tests/critical/chats/test_public_chat_browsing.py b/test/appium/tests/critical/chats/test_public_chat_browsing.py index 6b3abc13d2..198d809192 100644 --- a/test/appium/tests/critical/chats/test_public_chat_browsing.py +++ b/test/appium/tests/critical/chats/test_public_chat_browsing.py @@ -709,7 +709,9 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase): chat_element = self.channel_1.chat_element_by_text(message_unblocked) chat_element.find_element() chat_element.member_photo.click() - self.channel_1.profile_add_to_contacts_button.click() + self.channel_1.profile_send_contact_request_button.click() + self.channel_1.contact_request_message_input.send_keys("hi") + self.channel_1.confirm_send_contact_request_button.click() self.home_2.just_fyi("Accept contact request after being unblocked") self.home_2.navigate_back_to_home_view() self.home_2.handle_contact_request(self.username_1) diff --git a/test/appium/tests/critical/test_deep_and_universal_links.py b/test/appium/tests/critical/test_deep_and_universal_links.py index 875307f21f..d45a28844c 100644 --- a/test/appium/tests/critical/test_deep_and_universal_links.py +++ b/test/appium/tests/critical/test_deep_and_universal_links.py @@ -38,13 +38,14 @@ class TestDeepLinksOneDevice(MultipleSharedDeviceTestCase): self.channel.chat_message_input.clear() self.channel.send_message(url) self.channel.chat_element_by_text(url).click_on_link_inside_message_body() - if self.channel.profile_add_to_contacts_button.is_element_displayed(10): - username_text = self.profile_view.default_username_text.text + if self.channel.profile_send_contact_request_button.is_element_displayed(10): + # username_text = self.profile_view.default_username_text.text + username_text = self.profile_view.contact_name_text.text if not (username_text.endswith(url[-6:]) or username_text == text): self.errors.append("Incorrect username is shown for profile url %s" % url) else: self.errors.append("Profile was not opened by the profile url %s" % url) - self.home.navigate_back_to_chat_view() + self.profile_view.close_button.click() closed_community_urls = { "https://status.app/c/G8EAAMR_fz8tsCQ-aR2QrCS5sVAvvzc_N3mAA-En_Zxy4JA3j7Dl1A50Pd4DbooQOMbWf7E1_4wipgDyGe8XZEappDn-Qomf9l_xyXhSYBuSQic8InCEUBSRGR0oixSTh3iw5ZCxzkGSI95Iyu1EBpcIlFOEMPHpKUBIdkkoKBJglMDKko8O8dBvBtIYncOA8mwztwLpx3C0rK_u59PldFuXe4cx#zQ3shwQnEfMtcXpHXF4qJPyCGgw2F18N3nbGzYbzsVHnMq4yK": @@ -81,12 +82,13 @@ class TestDeepLinksOneDevice(MultipleSharedDeviceTestCase): for link, text in profile_links.items(): self.channel.just_fyi("Opening profile link %s" % link) self.browser_view.open_url(link) - shown_name_text = self.profile_view.default_username_text.text + # shown_name_text = self.profile_view.default_username_text.text + shown_name_text = self.profile_view.contact_name_text.text if text: name_is_shown = shown_name_text == text or shown_name_text.endswith(link[-6:]) else: name_is_shown = shown_name_text.endswith(link[-6:]) - if not self.channel.profile_add_to_contacts_button.is_element_displayed(10) or not name_is_shown: + if not self.channel.profile_send_contact_request_button.is_element_displayed(10) or not name_is_shown: self.errors.append("Profile was not opened by the profile deep link %s" % link) self.browser_view.click_system_back_button() diff --git a/test/appium/views/chat_view.py b/test/appium/views/chat_view.py index 25ea010b09..c7c57b6939 100644 --- a/test/appium/views/chat_view.py +++ b/test/appium/views/chat_view.py @@ -62,15 +62,6 @@ class GroupInfoButton(Button): return self.navigate() -class UnblockContactButton(Button): - def __init__(self, driver): - super().__init__(driver, accessibility_id="Unblock-item-button") - - def click(self): - self.scroll_to_element() - self.wait_for_element().click() - - class OpenInStatusButton(Button): def __init__(self, driver): super().__init__(driver, translation_id="browsing-open-in-status") @@ -101,21 +92,12 @@ class ChatOptionsButton(Button): class ProfileSendMessageButton(Button): def __init__(self, driver): - super().__init__(driver, accessibility_id="Chat-item-button") + super().__init__(driver, accessibility_id="icon, Send message") def navigate(self): return ChatView(self.driver) -class ProfileBlockContactButton(Button): - def __init__(self, driver): - super(ProfileBlockContactButton, self).__init__(driver, accessibility_id="Block-item-button") - - def click(self): - self.scroll_to_element() - self.wait_for_element().click() - - class ChatElementByText(Text): def __init__(self, driver, text): self.message_text = text @@ -868,11 +850,15 @@ class ChatView(BaseView): # Contact's profile self.contact_profile_picture = ProfilePictureElement(self.driver) self.profile_send_message_button = ProfileSendMessageButton(self.driver) - self.profile_block_contact_button = ProfileBlockContactButton(self.driver) - self.confirm_block_contact_button = Button(self.driver, accessibility_id="block-contact-confirm") - self.unblock_contact_button = UnblockContactButton(self.driver) + self.profile_options_button = Button(self.driver, accessibility_id="contact-actions") + self.profile_block_contact_button = Button(self.driver, accessibility_id="block-user") + self.confirm_block_contact_button = Button(self.driver, accessibility_id="block-contact") + self.unblock_contact_button = Button(self.driver, accessibility_id="icon, Unblock") self.profile_mute_contact = Button(self.driver, accessibility_id="Mute-item-button") self.profile_unmute_contact = Button(self.driver, accessibility_id="Unmute-item-button") + self.profile_send_contact_request_button = Button(self.driver, accessibility_id="icon, Send contact request") + self.contact_request_message_input = EditBox(self.driver, accessibility_id="contact-request-message") + self.confirm_send_contact_request_button = EditBox(self.driver, accessibility_id="send-contact-request") self.profile_add_to_contacts_button = Button(self.driver, accessibility_id="Add to contacts-item-button") self.profile_remove_from_contacts = Button(self.driver, accessibility_id="Remove from contacts-item-button") self.profile_details = Button(self.driver, accessibility_id="share-button") @@ -1172,6 +1158,7 @@ class ChatView(BaseView): def block_contact(self): self.driver.info("Block contact from other user profile") + self.profile_options_button.click() self.profile_block_contact_button.click() self.confirm_block_contact_button.click() diff --git a/test/appium/views/home_view.py b/test/appium/views/home_view.py index ce0fd47bb8..b039931d4d 100644 --- a/test/appium/views/home_view.py +++ b/test/appium/views/home_view.py @@ -412,10 +412,12 @@ class HomeView(BaseView): chat.view_profile_new_contact_button.click_until_presence_of_element(chat.profile_block_contact_button) if remove_from_contacts and chat.profile_remove_from_contacts.is_element_displayed(): chat.profile_remove_from_contacts.click() - chat.profile_add_to_contacts_button.click() + chat.profile_send_contact_request_button.click() + chat.contact_request_message_input.send_keys("hi") + chat.confirm_send_contact_request_button.click() if nickname: chat.set_nickname(nickname) - self.navigate_back_to_home_view() + chat.close_button.click_until_absense_of_element(chat.close_button) def create_group_chat(self, user_names_to_add: list, group_chat_name: str = 'new_group_chat'): self.driver.info("## Creating group chat '%s'" % group_chat_name, device=False) @@ -434,19 +436,6 @@ class HomeView(BaseView): self.driver.info("## Group chat %s is created successfully!" % group_chat_name, device=False) return chat - def send_contact_request_via_bottom_sheet(self, key: str): - chat = self.get_chat_view() - self.new_chat_button.click() - self.add_a_contact_chat_bottom_sheet_button.click() - chat.public_key_edit_box.click() - chat.public_key_edit_box.send_keys(key) - chat.element_by_translation_id("user-found").wait_for_visibility_of_element() - if not chat.view_profile_new_contact_button.is_element_displayed(): - chat.click_system_back_button() - chat.view_profile_new_contact_button.click_until_presence_of_element(chat.profile_add_to_contacts_button) - chat.profile_add_to_contacts_button.click() - self.navigate_back_to_home_view() - def create_community_e2e(self, name: str, description="some_description", set_image=False, file_name='sauce_logo.png', require_approval=True): diff --git a/test/appium/views/profile_view.py b/test/appium/views/profile_view.py index b3ecfce0c6..9fb897a7c0 100644 --- a/test/appium/views/profile_view.py +++ b/test/appium/views/profile_view.py @@ -194,6 +194,7 @@ class ProfileView(BaseView): # Header self.public_key_text = Text(self.driver, accessibility_id="chat-key") self.default_username_text = Text(self.driver, accessibility_id="default-username") + self.contact_name_text = Text(self.driver, accessibility_id="contact-name") self.share_my_profile_button = Button(self.driver, accessibility_id="share-header-button") self.profile_picture = ProfilePictureElement(self.driver) self.online_indicator = Button(self.driver, accessibility_id="online-profile-photo-dot") diff --git a/translations/en.json b/translations/en.json index 00e5926227..8fc44093ad 100644 --- a/translations/en.json +++ b/translations/en.json @@ -1662,6 +1662,7 @@ "add-nickname": "Add a nickname (optional)", "edit-nickname": "Edit nickname", "add-nickname-title": "Add nickname", + "update-nickname-title": "Update nickname", "nickname-visible-to-you": "Nickname will only be visible to you", "type-nickname": "Type nickname", "remove-nickname": "Remove nickname",