Allow running multiple integration tests
This commit is contained in:
parent
95af16f6ae
commit
901081a4cf
|
@ -100,6 +100,8 @@
|
|||
:clearInterval js/clearInterval}}))
|
||||
|
||||
(def keychain #js {:setGenericPassword (constantly (.resolve js/Promise true))
|
||||
:setInternetCredentials #(js/Promise.resolve)
|
||||
:resetInternetCredentials #(js/Promise.resolve)
|
||||
"ACCESSIBLE" {}
|
||||
"ACCESS_CONTROL" {}})
|
||||
|
||||
|
@ -133,6 +135,7 @@
|
|||
(def react-native-navigation #js {:Navigation #js {:constants (fn [] #js {:then identity})
|
||||
:setDefaultOptions identity
|
||||
:setRoot identity
|
||||
:dismissOverlay #(js/Promise.resolve)
|
||||
:setLazyComponentRegistrator identity
|
||||
:push identity
|
||||
:registerComponent identity
|
||||
|
@ -238,7 +241,7 @@
|
|||
|
||||
(def react-native-permissions #js {:default #js {}})
|
||||
|
||||
(def push-notification-ios #js {})
|
||||
(def push-notification-ios #js {:default #js {:abandonPermissions identity}})
|
||||
|
||||
(def rn-emoji-keyboard
|
||||
#js {:EmojiKeyboard #js {}})
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
[day8.re-frame.test :as rf-test]
|
||||
[re-frame.core :as rf]
|
||||
status-im.events
|
||||
[status-im.multiaccounts.logout.core :as logout]
|
||||
[status-im.transport.core :as transport]
|
||||
[status-im.utils.test :as utils.test]))
|
||||
|
||||
|
@ -10,30 +11,34 @@
|
|||
|
||||
(utils.test/init!)
|
||||
|
||||
(def initialize-app!
|
||||
#(rf/dispatch-sync [:init/app-started]))
|
||||
(defn initialize-app! []
|
||||
(rf/dispatch-sync [:init/app-started]))
|
||||
|
||||
(def generate-and-derive-addresses!
|
||||
#(rf/dispatch [:generate-and-derive-addresses]))
|
||||
(defn generate-and-derive-addresses! []
|
||||
(rf/dispatch [:generate-and-derive-addresses]))
|
||||
|
||||
(def create-multiaccount!
|
||||
#(rf/dispatch [:create-multiaccount password]))
|
||||
(defn create-multiaccount! []
|
||||
(rf/dispatch [:create-multiaccount password]))
|
||||
|
||||
(def assert-app-initialized
|
||||
#(let [app-state @(rf/subscribe [:app-state])
|
||||
multiaccounts-loading? @(rf/subscribe [:multiaccounts/loading])]
|
||||
(is (= "active" app-state))
|
||||
(is (false? multiaccounts-loading?))))
|
||||
(defn assert-app-initialized []
|
||||
(let [app-state @(rf/subscribe [:app-state])
|
||||
multiaccounts-loading? @(rf/subscribe [:multiaccounts/loading])]
|
||||
(is (= "active" app-state))
|
||||
(is (false? multiaccounts-loading?))))
|
||||
|
||||
(def assert-multiaccounts-generated
|
||||
#(let [wizard-state @(rf/subscribe [:intro-wizard/choose-key])]
|
||||
(is (= 5 (count (:multiaccounts wizard-state))))))
|
||||
(defn assert-logout []
|
||||
(let [multiaccounts-loading? @(rf/subscribe [:multiaccounts/loading])]
|
||||
(is multiaccounts-loading?)))
|
||||
|
||||
(defn assert-multiaccounts-generated []
|
||||
(let [wizard-state @(rf/subscribe [:intro-wizard/choose-key])]
|
||||
(is (= 5 (count (:multiaccounts wizard-state))))))
|
||||
|
||||
(defn messenger-started []
|
||||
@(rf/subscribe [:messenger/started?]))
|
||||
|
||||
(def assert-messenger-started
|
||||
#(is (messenger-started)))
|
||||
(defn assert-messenger-started []
|
||||
(is (messenger-started)))
|
||||
|
||||
(deftest initialize-app-test
|
||||
(rf-test/run-test-sync
|
||||
|
@ -43,6 +48,9 @@
|
|||
(defn assert-multiaccount-loaded []
|
||||
(is (false? @(rf/subscribe [:multiaccounts/loading]))))
|
||||
|
||||
(defn logout! []
|
||||
(rf/dispatch [:logout]))
|
||||
|
||||
(deftest create-account-test
|
||||
(rf-test/run-test-async
|
||||
(initialize-app!) ; initialize app
|
||||
|
@ -55,7 +63,29 @@
|
|||
(create-multiaccount!) ; create a multiaccount
|
||||
(rf-test/wait-for ; wait for login
|
||||
[::transport/messenger-started]
|
||||
(assert-messenger-started))))))
|
||||
(assert-messenger-started)
|
||||
(logout!)
|
||||
(rf-test/wait-for [::logout/logout-method] ; we need to logout to make sure the node is not in an inconsistent state between tests
|
||||
(assert-logout)))))))
|
||||
|
||||
;; This test is only to make sure running multiple integration tests doesn't hang
|
||||
;; can be removed as soon as another test is added
|
||||
(deftest create-account-test-safety-check
|
||||
(rf-test/run-test-async
|
||||
(initialize-app!) ; initialize app
|
||||
(rf-test/wait-for
|
||||
[:status-im.init.core/initialize-multiaccounts] ; wait so we load accounts.db
|
||||
(generate-and-derive-addresses!) ; generate 5 new keys
|
||||
(rf-test/wait-for
|
||||
[:multiaccount-generate-and-derive-addresses-success] ; wait for the keys
|
||||
(assert-multiaccount-loaded) ; assert keys are generated
|
||||
(create-multiaccount!) ; create a multiaccount
|
||||
(rf-test/wait-for ; wait for login
|
||||
[::transport/messenger-started]
|
||||
(assert-messenger-started)
|
||||
(logout!)
|
||||
(rf-test/wait-for [::logout/logout-method]
|
||||
(assert-logout)))))))
|
||||
|
||||
(comment
|
||||
(run-tests))
|
||||
|
|
|
@ -41,6 +41,8 @@
|
|||
config
|
||||
accounts-data))
|
||||
|
||||
:logout (fn []
|
||||
(.logout native-status))
|
||||
:generateAliasAndIdenticonAsync (fn [seed callback]
|
||||
(let [generated-identicon (.identicon native-status seed)
|
||||
generated-alias (.generateAlias native-status seed)]
|
||||
|
|
Loading…
Reference in New Issue