From 739d10a9ef93e8b96c22cd910d9a78dc588b7956 Mon Sep 17 00:00:00 2001 From: Parvesh Monu Date: Mon, 6 Feb 2023 20:40:46 +0530 Subject: [PATCH 1/3] Add tests for bottom-tabs-notifications-data subscription (#14992) --- src/status_im2/subs/shell_test.cljs | 80 +++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 src/status_im2/subs/shell_test.cljs diff --git a/src/status_im2/subs/shell_test.cljs b/src/status_im2/subs/shell_test.cljs new file mode 100644 index 0000000000..047deddea5 --- /dev/null +++ b/src/status_im2/subs/shell_test.cljs @@ -0,0 +1,80 @@ +(ns status-im2.subs.shell-test + (:require [utils.re-frame :as rf] + [re-frame.db :as rf-db] + [test-helpers.unit :as h] + [cljs.test :refer [is testing]] + [status-im2.constants :as constants])) + +(def public-profile-timeline-chats + {"0xpublic-chat" {:chat-type constants/public-chat-type + :unviewed-messages-count 5 + :unviewed-mentions-count 6} + "0xprofile-chat" {:chat-type constants/profile-chat-type + :unviewed-messages-count 5 + :unviewed-mentions-count 6} + "0xtimeline-chat" {:chat-type constants/timeline-chat-type + :unviewed-messages-count 5 + :unviewed-mentions-count 6}}) + +(def expected-notification-data-for-public-profile-timeline-chats + {:communities-stack {:new-notifications? false + :notification-indicator :unread-dot + :counter-label 0} + :chats-stack {:new-notifications? false + :notification-indicator :unread-dot + :counter-label 0}}) + +(def one-to-one-group-community-chats1 + {"0xone-to-one-chat1" {:chat-type constants/one-to-one-chat-type + :unviewed-messages-count 5 + :unviewed-mentions-count 0} + "0xgroup-chat1" {:chat-type constants/private-group-chat-type + :unviewed-messages-count 2 + :unviewed-mentions-count 0} + "0xcommunity-chat1" {:chat-type constants/community-chat-type + :unviewed-messages-count 3 + :unviewed-mentions-count 0}}) + +(def expected-notification-data-for-one-to-one-group-community-chats1 + {:communities-stack {:new-notifications? true + :notification-indicator :unread-dot + :counter-label 0} + :chats-stack {:new-notifications? true + :notification-indicator :unread-dot + :counter-label 0}}) + +(def one-to-one-group-community-chats2 + (merge + one-to-one-group-community-chats1 + {"0xone-to-one-chat2" {:chat-type constants/one-to-one-chat-type + :unviewed-messages-count 8 + :unviewed-mentions-count 6} + "0xgroup-chat2" {:chat-type constants/private-group-chat-type + :unviewed-messages-count 4 + :unviewed-mentions-count 3} + "0xcommunity-chat2" {:chat-type constants/community-chat-type + :unviewed-messages-count 9 + :unviewed-mentions-count 7}})) + +(def expected-notification-data-for-one-to-one-group-community-chats2 + {:communities-stack {:new-notifications? true + :notification-indicator :counter + :counter-label 7} + :chats-stack {:new-notifications? true + :notification-indicator :counter + :counter-label 9}}) + +(h/deftest-sub :shell/bottom-tabs-notifications-data + [sub-name] + (testing "public, profile and timeline chats should not affect shell bottom tab indicator" + (swap! rf-db/app-db assoc :chats public-profile-timeline-chats) + (is (= (rf/sub [sub-name]) expected-notification-data-for-public-profile-timeline-chats))) + + (testing "chats with only unviewed-messages, without unviewed-mentions count should use unread-dot" + (swap! rf-db/app-db assoc :chats one-to-one-group-community-chats1) + (is (= (rf/sub [sub-name]) expected-notification-data-for-one-to-one-group-community-chats1))) + + (testing + "chats with both unviewed-messages and unviewed-mentions count should use counter with mentions count" + (swap! rf-db/app-db assoc :chats one-to-one-group-community-chats2) + (is (= (rf/sub [sub-name]) expected-notification-data-for-one-to-one-group-community-chats2)))) From b9ac26edd78c536abec1344494ef1c9b7db131a0 Mon Sep 17 00:00:00 2001 From: Parvesh Monu Date: Mon, 6 Feb 2023 22:13:45 +0530 Subject: [PATCH 2/3] fix selected members are not shown on the group creation screen (#14991) --- src/status_im/ui/screens/home/sheet/views.cljs | 6 ++++-- src/status_im/ui/screens/home/views.cljs | 8 ++++++-- .../ui2/screens/chat/components/new_chat/view.cljs | 2 -- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/status_im/ui/screens/home/sheet/views.cljs b/src/status_im/ui/screens/home/sheet/views.cljs index b944888532..d03938695d 100644 --- a/src/status_im/ui/screens/home/sheet/views.cljs +++ b/src/status_im/ui/screens/home/sheet/views.cljs @@ -76,8 +76,10 @@ :icon-color (colors/theme-colors colors/neutral-50 colors/neutral-40) :accessibility-label :start-a-new-chat :icon :i/new-message - :on-press #(hide-sheet-and-dispatch [:bottom-sheet/show-sheet - :start-a-new-chat {}])}] + :on-press (fn [] + (rf/dispatch [:group-chat/clear-contacts]) + (hide-sheet-and-dispatch [:bottom-sheet/show-sheet + :start-a-new-chat {}]))}] [quo2/menu-item {:type :transparent :title (i18n/label :t/add-a-contact) diff --git a/src/status_im/ui/screens/home/views.cljs b/src/status_im/ui/screens/home/views.cljs index 6aa58aecfa..bc4ac06ad8 100644 --- a/src/status_im/ui/screens/home/views.cljs +++ b/src/status_im/ui/screens/home/views.cljs @@ -259,7 +259,9 @@ (views/letsubs [logging-in? [:multiaccounts/login]] [components.plus-button/plus-button-old {:on-press (when-not logging-in? - #(re-frame/dispatch [:bottom-sheet/show-sheet :start-a-new-chat {}])) + (fn [] + (re-frame/dispatch [:group-chat/clear-contacts]) + (re-frame/dispatch [:bottom-sheet/show-sheet :start-a-new-chat {}]))) :loading logging-in? :accessibility-label :new-chat-button}])) @@ -268,7 +270,9 @@ (views/letsubs [logging-in? [:multiaccounts/login]] [components.plus-button/plus-button-old {:on-press (when-not logging-in? - #(re-frame/dispatch [:bottom-sheet/show-sheet :start-a-new-chat {}])) + (fn [] + (re-frame/dispatch [:group-chat/clear-contacts]) + (re-frame/dispatch [:bottom-sheet/show-sheet :start-a-new-chat {}]))) :loading logging-in? :accessibility-label :new-chat-button}])) diff --git a/src/status_im/ui2/screens/chat/components/new_chat/view.cljs b/src/status_im/ui2/screens/chat/components/new_chat/view.cljs index 5d7515f1e9..0d2438ca36 100644 --- a/src/status_im/ui2/screens/chat/components/new_chat/view.cljs +++ b/src/status_im/ui2/screens/chat/components/new_chat/view.cljs @@ -13,7 +13,6 @@ [quo2.components.markdown.text :as text] [status-im.ui.components.invite.events :as invite.events] [status-im.ui2.screens.chat.components.new-chat.styles :as style] - [quo.react :as quo.react] [quo.components.safe-area :as safe-area] [status-im.react-native.resources :as resources])) @@ -65,7 +64,6 @@ [] [:f> (fn [] - (quo.react/effect! #(rf/dispatch [:group-chat/clear-contacts]) []) (let [contacts (rf/sub [:contacts/sorted-and-grouped-by-first-letter]) selected-contacts-count (rf/sub [:selected-contacts-count]) From e61bd769a8bb71200c6dc7f1176acb94f411059b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Mon, 6 Feb 2023 11:58:22 +0100 Subject: [PATCH 3/3] ci: fetch E2E APK from android-e2e jobs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using `copyArtifacts()` is more reliable and faster then fetching APKs based on URLs acquired by parsing GitHub comments from Jenkins builds. Signed-off-by: Jakub SokoĊ‚owski --- ci/Jenkinsfile.combined | 2 +- ci/tests/Jenkinsfile.e2e-nightly | 13 +++++++-- ci/tests/Jenkinsfile.e2e-prs | 48 +++++++++++++++++++++----------- ci/tests/Jenkinsfile.e2e-upgrade | 24 ++++++++++++---- 4 files changed, 62 insertions(+), 25 deletions(-) diff --git a/ci/Jenkinsfile.combined b/ci/Jenkinsfile.combined index 4f75eac06f..78dcd04134 100644 --- a/ci/Jenkinsfile.combined +++ b/ci/Jenkinsfile.combined @@ -105,7 +105,7 @@ pipeline { e2eApk = utils.getEnv(apke2e, 'SAUCE_URL') build( job: 'status-mobile/e2e/status-app-nightly', - parameters: [string(name: 'APK_NAME', value: e2eApk)], + parameters: [string(name: 'APK_URL', value: e2eApk)], wait: false ) } } diff --git a/ci/tests/Jenkinsfile.e2e-nightly b/ci/tests/Jenkinsfile.e2e-nightly index a29a4c0877..b498e14e46 100644 --- a/ci/tests/Jenkinsfile.e2e-nightly +++ b/ci/tests/Jenkinsfile.e2e-nightly @@ -4,8 +4,8 @@ pipeline { parameters { string( - name: 'APK_NAME', - description: 'Filename of APK uploaded to SauceLabs.', + name: 'APK_URL', + description: 'URL of APK uploaded to SauceLabs.', ) string( name: 'KEYWORD_EXPRESSION', @@ -20,6 +20,14 @@ pipeline { stages { + stage('Prep') { + steps { script { + if (params.PR_ID == null) { + error("PR_ID parameter not set!") + } + } } + } + stage('Setup') { steps { script { dir('test/appium') { @@ -27,6 +35,7 @@ pipeline { } } } } + stage('Test') { steps { withCredentials([ diff --git a/ci/tests/Jenkinsfile.e2e-prs b/ci/tests/Jenkinsfile.e2e-prs index 098bb160f8..563d3405c6 100644 --- a/ci/tests/Jenkinsfile.e2e-prs +++ b/ci/tests/Jenkinsfile.e2e-prs @@ -1,4 +1,4 @@ -library 'status-jenkins-lib@v1.6.3' +library 'status-jenkins-lib@v1.6.5' pipeline { @@ -10,16 +10,6 @@ pipeline { description: 'Name of the branch to checkout and build.', defaultValue: 'develop', ) -/* Commented to use TEST_MARKERS values from job params - string( - name: 'TEST_MARKERS', - description: 'Marker expression for matching tests to run.', - defaultValue: 'new_ui_critical', - ) */ - string( - name: 'APK_NAME', - description: 'Filename of APK uploaded to SauceLabs, path, or URL.', - ) string( name: 'PR_ID', description: 'ID of the Pull Request triggering this build.', @@ -34,6 +24,19 @@ pipeline { description: 'IDs of the TestRail case, separated by a comma (Optional)', defaultValue: '', ) + /* FIXME: Remove this no longer relevant argument */ + string( + name: 'APK_NAME', + description: 'OBSOLETE ARGUMENT TO BE REMOVED', + defaultValue: 'DUMMY', + ) + /* Commented to use TEST_MARKERS values from job params + string( + name: 'TEST_MARKERS', + description: 'Marker expression for matching tests to run.', + defaultValue: 'new_ui_critical', + ) + */ } options { @@ -41,12 +44,25 @@ pipeline { } stages { - stage('Checks') { + stage('Prep') { steps { script { - if (params.APK_NAME == null) { error("APK_NAME parameter not set!") } - if (params.PR_ID == null) { error("PR_ID parameter not set!") } + currentBuild.displayName = "PR-${params.PR_ID}" + if (params.PR_ID == null) { + error("PR_ID parameter not set!") + } } } } + + stage('Fetch') { + steps { script { /* WARNING: This copies the latest available artifact. */ + copyArtifacts( + projectName: "status-mobile/prs/android-e2e/PR-${params.PR_ID}", + selector: lastWithArtifacts(), + ) + apk_path = "${env.PWD}/${utils.findFile('result/*.apk')}" + } } + } + stage('Setup') { steps { script { dir('test/appium') { @@ -54,9 +70,9 @@ pipeline { } } } } + stage('Test') { steps { script { - currentBuild.displayName = "PR-${params.PR_ID}" /* for managing optional arguments */ def extraPytestOpts = '' if (params.TR_CASE_IDS != '') { @@ -103,7 +119,7 @@ pipeline { --rerun_count=2 \ --testrail_report=True \ -k \"${params.KEYWORD_EXPRESSION}\" \ - --apk=${params.APK_NAME} \ + --apk=${apk_path} \ --build=PR-${params.PR_ID}-${utils.timestamp()} \ --pr_number=${params.PR_ID} \ ${extraPytestOpts} diff --git a/ci/tests/Jenkinsfile.e2e-upgrade b/ci/tests/Jenkinsfile.e2e-upgrade index b442b317fc..5a81707b6c 100644 --- a/ci/tests/Jenkinsfile.e2e-upgrade +++ b/ci/tests/Jenkinsfile.e2e-upgrade @@ -4,12 +4,12 @@ pipeline { parameters { string( - name: 'APK_NAME', - description: 'Filename of APK uploaded to SauceLabs (base for upgrade, usually release build)', + name: 'APK_URL', + description: 'URL of APK to be tested(base for upgrade, usually release build)', ) string( - name: 'APK_NAME_UPGRADE', - description: 'Filename of APK of upgraded application (installed on top of base)', + name: 'APK_URL_UPGRADE', + description: 'URL of APK of upgraded application (installed on top of base)', ) string( name: 'KEYWORD_EXPRESSION', @@ -29,6 +29,17 @@ pipeline { stages { + stage('Prep') { + steps { script { + if (params.APK_URL == null) { + error("APK_URL parameter not set!") + } + if (params.APK_URL_UPGRADE == null) { + error("APK_URL_UPGRADE parameter not set!") + } + } } + } + stage('Setup') { steps { script { dir('test/appium') { @@ -36,6 +47,7 @@ pipeline { } } } } + stage('Test') { steps { script { /* for managing optional arguments */ @@ -77,8 +89,8 @@ pipeline { --numprocesses 4 \ --rerun_count=2 \ --testrail_report=True \ - --apk=${params.APK_NAME} \ - --apk_upgrade=${params.APK_NAME_UPGRADE} \ + --apk=${params.APK_URL} \ + --apk_upgrade=${params.APK_URL_UPGRADE} \ ${extraPytestOpts} """ }