From cc24794b743fb4b2babdb9696e689a8e4feb122d Mon Sep 17 00:00:00 2001 From: Paul Fitzgerald Date: Thu, 25 Jan 2024 19:00:18 +0000 Subject: [PATCH 1/2] chore (shell): add indicators to share wallet qrs (#18523) --- .../contexts/shell/share/wallet/style.cljs | 18 +++++ .../contexts/shell/share/wallet/view.cljs | 74 ++++++++++++++----- 2 files changed, 74 insertions(+), 18 deletions(-) create mode 100644 src/status_im/contexts/shell/share/wallet/style.cljs diff --git a/src/status_im/contexts/shell/share/wallet/style.cljs b/src/status_im/contexts/shell/share/wallet/style.cljs new file mode 100644 index 00000000000..b5e029c67f7 --- /dev/null +++ b/src/status_im/contexts/shell/share/wallet/style.cljs @@ -0,0 +1,18 @@ +(ns status-im.contexts.shell.share.wallet.style + (:require + [quo.foundations.colors :as colors])) + +(defn indicator-wrapper-style + [active?] + {:width 8 + :height 8 + :border-radius 4 + :background-color colors/white + :opacity (if active? 1.0 0.5)}) + +(def indicator-list-style + {:display :flex + :flex-direction :row + :align-items :center + :justify-content :center + :gap 8}) diff --git a/src/status_im/contexts/shell/share/wallet/view.cljs b/src/status_im/contexts/shell/share/wallet/view.cljs index fcec17b1a0a..e04e6c2b7b9 100644 --- a/src/status_im/contexts/shell/share/wallet/view.cljs +++ b/src/status_im/contexts/shell/share/wallet/view.cljs @@ -6,6 +6,7 @@ [react-native.share :as share] [reagent.core :as reagent] [status-im.contexts.shell.share.style :as style] + [status-im.contexts.shell.share.wallet.style :as wallet-style] [status-im.contexts.wallet.common.sheets.network-preferences.view :as network-preferences] [status-im.contexts.wallet.common.utils :as utils] [utils.i18n :as i18n] @@ -43,10 +44,11 @@ (rf/dispatch [:hide-bottom-sheet]) (reset! selected-networks (map #(get utils/id->network %) chain-ids)))}])}])) -(defn wallet-qr-code-item - [account width index] - (let [selected-networks (reagent/atom [:ethereum :optimism :arbitrum]) - wallet-type (reagent/atom :wallet-legacy)] +(defn- wallet-qr-code-item-internal + [props] + (let [{:keys [account width index]} props + selected-networks (reagent/atom [:ethereum :optimism :arbitrum]) + wallet-type (reagent/atom :wallet-legacy)] (fn [] (let [share-title (str (:name account) " " (i18n/label :t/address)) qr-url (utils/get-wallet-qr {:wallet-type @wallet-type @@ -57,7 +59,7 @@ :port (rf/sub [:mediaserver/port]) :qr-size qr-size :error-level :highest})] - [rn/view {:style {:width width :margin-left (if (zero? index) 0 -30)}} + [rn/view {:style {:height qr-size :width width :margin-left (if (zero? index) 0 -30)}} [rn/view {:style style/qr-code-container} [quo/share-qr-code {:type @wallet-type @@ -73,18 +75,54 @@ :on-legacy-press #(reset! wallet-type :wallet-legacy) :on-settings-press #(open-preferences @selected-networks)}]]])))) +(def wallet-qr-code-item (memoize wallet-qr-code-item-internal)) + +(defn- indicator + [active?] + [rn/view + {:style (wallet-style/indicator-wrapper-style active?)}]) + +(defn- indicator-list + [indicator-count current-index] + [rn/view + {:style wallet-style/indicator-list-style} + (for [i (range indicator-count)] + (let [current-index (cond (<= current-index 0) 0 + (>= current-index (dec indicator-count)) (dec indicator-count) + :else current-index)] + ^{:key i} [indicator (= current-index i)]))]) + +(defn render-item + [item] + (let [width (rf/sub [:dimensions/window-width])] + [wallet-qr-code-item + {:account item + :index (:position item) + :width width}])) + (defn wallet-tab [] - (let [accounts (rf/sub [:wallet/accounts]) - width (rf/sub [:dimensions/window-width])] - [rn/flat-list - {:horizontal true - :deceleration-rate 0.9 - :snap-to-alignment "start" - :snap-to-interval (- width 30) - :disable-interval-momentum true - :scroll-event-throttle 64 - :data accounts - :directional-lock-enabled true - :render-fn (fn [account index] - (wallet-qr-code-item account width index))}])) + (let [accounts (rf/sub [:wallet/accounts]) + width (rf/sub [:dimensions/window-width]) + current-index (reagent/atom 0)] + (fn [] + [rn/view + [rn/flat-list + {:horizontal true + :deceleration-rate 0.9 + :snap-to-alignment :start + :snap-to-interval (- width 30) + :disable-interval-momentum true + :scroll-event-throttle 64 + :data accounts + :directional-lock-enabled true + :shows-horizontal-scroll-indicator false + :on-scroll (fn [e] + (reset! current-index (js/Math.ceil + (/ e.nativeEvent.contentOffset.x + width)))) + :render-fn render-item}] + (when (> (count accounts) 1) + [rn/view + {:style {:margin-top 20}} + (indicator-list (count accounts) @current-index)])]))) From ad7a95ed3d02a244882338ddfb5f4549c43f2aa0 Mon Sep 17 00:00:00 2001 From: Yevheniia Berdnyk Date: Thu, 25 Jan 2024 20:00:39 +0200 Subject: [PATCH 2/2] e2e: updated deep/universal links tests --- .../critical/test_deep_and_universal_links.py | 51 ++++++++++++------- test/appium/views/chat_view.py | 1 + 2 files changed, 33 insertions(+), 19 deletions(-) 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 c75a42709f2..d686c967c98 100644 --- a/test/appium/tests/critical/test_deep_and_universal_links.py +++ b/test/appium/tests/critical/test_deep_and_universal_links.py @@ -45,20 +45,27 @@ def test_links_open_universal_links_from_chat(self): self.errors.append("Profile was not opened by the profile url %s" % url) self.home.navigate_back_to_chat_view() - closed_community_urls = [ - "https://status.app/c/G8EAAGTiXKuwNbVVAu0GNLD-XzX4oz_E8oC1-7qSLikaTnCuG9Ag13ZgQKrMd8En9Qcpuaj3Qx3mfZ1atZzH8Zw-x_sFJ_MDv0P_7YfqoV-pNr3V4dsza-jVk41GaCGWasJb92Oer8qggaoNWf0tYCgSH19VonXciKPUz3ITdgke#zQ3shbmfT3hvh4mKa1v6uAjjyztQEroh8Mfn6Ckegjd7LT3XK", - "https://status.app/c/Ow==#zQ3shbmfT3hvh4mKa1v6uAjjyztQEroh8Mfn6Ckegjd7LT3XK", - "https://status.app/c#zQ3shbmfT3hvh4mKa1v6uAjjyztQEroh8Mfn6Ckegjd7LT3XK", - "https://status.app/c/ixiACjAKCHRlc3RDb21tEhZkemZ4Z2Nodmpra2xra2xrbCAgbGxsGAYiByM4OEIwRkYqARQD#zQ3shuK3RAMBGtNWJ5QAKtuGeyEhiwko5gXhyGg6T89Q2xrHq" - ] - for url in closed_community_urls: + closed_community_urls = { + "https://status.app/c/G8EAAMR_fz8tsCQ-aR2QrCS5sVAvvzc_N3mAA-En_Zxy4JA3j7Dl1A50Pd4DbooQOMbWf7E1_4wipgDyGe8XZEappDn-Qomf9l_xyXhSYBuSQic8InCEUBSRGR0oixSTh3iw5ZCxzkGSI95Iyu1EBpcIlFOEMPHpKUBIdkkoKBJglMDKko8O8dBvBtIYncOA8mwztwLpx3C0rK_u59PldFuXe4cx#zQ3shwQnEfMtcXpHXF4qJPyCGgw2F18N3nbGzYbzsVHnMq4yK": + "Status mobile QA community max", + "https://status.app/c/GyoAAORtA48geFrtWr2mu-G5DnFaI0sgqUIIaBFX_DJ_mRbXmzoMnCJnqwI=#zQ3shQhL414wEjDJMEpgTjd14aHCiBDnk6Bq5YTWoi4b7wvnu": + "test_comm_enc", + "https://status.app/c/G00AAGS9TbI9mSR-ZNmFrhRjNuEeXAAbcAIUaLLJyjMOG3ACJQ12oIHD78QhzO9s_T5bUeU7rnATWJg3mGgTUemrAg==#zQ3shspPKCZ1VPVQ9dLXGufUGvGphjxVwrcZ6rkZc7S39T4b3": + "closed community", + "https://status.app/c/GyAAAOQbK4dMy1OMI8s2nGvJR3QRqBQqbExff0-cgmN0T-4C#zQ3shqQ4voo845RAkip2JkYTjL4dpiGnRhaNHjVDxPdEZ1xvP": + "e2e_open", + "https://status.app/c/G0UAAMTyNsn2QZDEG0EXftOl8pOEfwEBOOSA_YTfIk85xmADDgINGmxpUHAXzK36bN0fK42Xf4YD2yjPk1z2pbFwFw==#zQ3shgkDFQEnwxji7CvMTokMrShmC2UgxiJ549X5Aw746zQrK": + "open community" + } + for url, text in closed_community_urls.items(): 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 not self.channel.element_by_translation_id( - "community-admins-will-review-your-request").is_element_displayed(10): + if not self.community_view.join_button.is_element_displayed( + 10) or self.community_view.community_title.text != text: self.errors.append("Closed community was not requested to join by the url %s" % url) - self.home.jump_to_card_by_text(self.community_name) + if text != "open community": # the last one + self.home.jump_to_card_by_text(self.community_name) self.errors.verify_no_errors() @@ -84,16 +91,22 @@ def test_links_deep_links(self): self.errors.append("Profile was not opened by the profile deep link %s" % link) self.browser_view.click_system_back_button() - community_links = [ - "status-app://c/G8EAAGTiXKuwNbVVAu0GNLD-XzX4oz_E8oC1-7qSLikaTnCuG9Ag13ZgQKrMd8En9Qcpuaj3Qx3mfZ1atZzH8Zw-x_sFJ_MDv0P_7YfqoV-pNr3V4dsza-jVk41GaCGWasJb92Oer8qggaoNWf0tYCgSH19VonXciKPUz3ITdgke#zQ3shbmfT3hvh4mKa1v6uAjjyztQEroh8Mfn6Ckegjd7LT3XK", - "status-app://c/Ow==#zQ3shbmfT3hvh4mKa1v6uAjjyztQEroh8Mfn6Ckegjd7LT3XK", - "status-app://c#zQ3shbmfT3hvh4mKa1v6uAjjyztQEroh8Mfn6Ckegjd7LT3XK", - "status-app://c/ixiACjAKCHRlc3RDb21tEhZkemZ4Z2Nodmpra2xra2xrbCAgbGxsGAYiByM4OEIwRkYqARQD#zQ3shuK3RAMBGtNWJ5QAKtuGeyEhiwko5gXhyGg6T89Q2xrHq" - ] - for link in community_links: + community_links = { + "status.app://c/G8EAAMR_fz8tsCQ-aR2QrCS5sVAvvzc_N3mAA-En_Zxy4JA3j7Dl1A50Pd4DbooQOMbWf7E1_4wipgDyGe8XZEappDn-Qomf9l_xyXhSYBuSQic8InCEUBSRGR0oixSTh3iw5ZCxzkGSI95Iyu1EBpcIlFOEMPHpKUBIdkkoKBJglMDKko8O8dBvBtIYncOA8mwztwLpx3C0rK_u59PldFuXe4cx#zQ3shwQnEfMtcXpHXF4qJPyCGgw2F18N3nbGzYbzsVHnMq4yK": + "Status mobile QA community max", + "status.app://c/GyoAAORtA48geFrtWr2mu-G5DnFaI0sgqUIIaBFX_DJ_mRbXmzoMnCJnqwI=#zQ3shQhL414wEjDJMEpgTjd14aHCiBDnk6Bq5YTWoi4b7wvnu": + "test_comm_enc", + "status.app://c/G00AAGS9TbI9mSR-ZNmFrhRjNuEeXAAbcAIUaLLJyjMOG3ACJQ12oIHD78QhzO9s_T5bUeU7rnATWJg3mGgTUemrAg==#zQ3shspPKCZ1VPVQ9dLXGufUGvGphjxVwrcZ6rkZc7S39T4b3": + "closed community", + "status.app://c/G0UAAMTyNsn2QZDEG0EXftOl8pOEfwEBOOSA_YTfIk85xmADDgINGmxpUHAXzK36bN0fK42Xf4YD2yjPk1z2pbFwFw==#zQ3shgkDFQEnwxji7CvMTokMrShmC2UgxiJ549X5Aw746zQrK": + "open community", + "status.app://c/GyAAAOQbK4dMy1OMI8s2nGvJR3QRqBQqbExff0-cgmN0T-4C#zQ3shqQ4voo845RAkip2JkYTjL4dpiGnRhaNHjVDxPdEZ1xvP": + "e2e_open" + } + for link, text in community_links.items(): self.browser_view.open_url(link) - if not self.channel.element_by_translation_id( - "community-admins-will-review-your-request").is_element_displayed(10): + if not self.community_view.join_button.is_element_displayed( + 10) or self.community_view.community_title.text != text: self.errors.append("Closed community was not requested to join by the deep link %s" % link) self.home.navigate_back_to_home_view() self.home.browser_tab.click() diff --git a/test/appium/views/chat_view.py b/test/appium/views/chat_view.py index d5c67d40077..49038c584bf 100644 --- a/test/appium/views/chat_view.py +++ b/test/appium/views/chat_view.py @@ -425,6 +425,7 @@ def __init__(self, driver): self.close_community_view_button = Button( self.driver, xpath="//*[@content-desc='community-options-for-community']/../*[1]//android.widget.ImageView") + self.community_title = Text(self.driver, accessibility_id="community-title") self.community_description_text = Text(self.driver, accessibility_id="community-description-text") self.community_status_joined = Text(self.driver, accessibility_id="status-tag-positive") self.community_status_pending = Text(self.driver, accessibility_id="status-tag-pending")