Allow running multiple integration tests
This commit is contained in:
parent
95af16f6ae
commit
901081a4cf
|
@ -100,6 +100,8 @@
|
||||||
:clearInterval js/clearInterval}}))
|
:clearInterval js/clearInterval}}))
|
||||||
|
|
||||||
(def keychain #js {:setGenericPassword (constantly (.resolve js/Promise true))
|
(def keychain #js {:setGenericPassword (constantly (.resolve js/Promise true))
|
||||||
|
:setInternetCredentials #(js/Promise.resolve)
|
||||||
|
:resetInternetCredentials #(js/Promise.resolve)
|
||||||
"ACCESSIBLE" {}
|
"ACCESSIBLE" {}
|
||||||
"ACCESS_CONTROL" {}})
|
"ACCESS_CONTROL" {}})
|
||||||
|
|
||||||
|
@ -133,6 +135,7 @@
|
||||||
(def react-native-navigation #js {:Navigation #js {:constants (fn [] #js {:then identity})
|
(def react-native-navigation #js {:Navigation #js {:constants (fn [] #js {:then identity})
|
||||||
:setDefaultOptions identity
|
:setDefaultOptions identity
|
||||||
:setRoot identity
|
:setRoot identity
|
||||||
|
:dismissOverlay #(js/Promise.resolve)
|
||||||
:setLazyComponentRegistrator identity
|
:setLazyComponentRegistrator identity
|
||||||
:push identity
|
:push identity
|
||||||
:registerComponent identity
|
:registerComponent identity
|
||||||
|
@ -238,7 +241,7 @@
|
||||||
|
|
||||||
(def react-native-permissions #js {:default #js {}})
|
(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
|
(def rn-emoji-keyboard
|
||||||
#js {:EmojiKeyboard #js {}})
|
#js {:EmojiKeyboard #js {}})
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
[day8.re-frame.test :as rf-test]
|
[day8.re-frame.test :as rf-test]
|
||||||
[re-frame.core :as rf]
|
[re-frame.core :as rf]
|
||||||
status-im.events
|
status-im.events
|
||||||
|
[status-im.multiaccounts.logout.core :as logout]
|
||||||
[status-im.transport.core :as transport]
|
[status-im.transport.core :as transport]
|
||||||
[status-im.utils.test :as utils.test]))
|
[status-im.utils.test :as utils.test]))
|
||||||
|
|
||||||
|
@ -10,30 +11,34 @@
|
||||||
|
|
||||||
(utils.test/init!)
|
(utils.test/init!)
|
||||||
|
|
||||||
(def initialize-app!
|
(defn initialize-app! []
|
||||||
#(rf/dispatch-sync [:init/app-started]))
|
(rf/dispatch-sync [:init/app-started]))
|
||||||
|
|
||||||
(def generate-and-derive-addresses!
|
(defn generate-and-derive-addresses! []
|
||||||
#(rf/dispatch [:generate-and-derive-addresses]))
|
(rf/dispatch [:generate-and-derive-addresses]))
|
||||||
|
|
||||||
(def create-multiaccount!
|
(defn create-multiaccount! []
|
||||||
#(rf/dispatch [:create-multiaccount password]))
|
(rf/dispatch [:create-multiaccount password]))
|
||||||
|
|
||||||
(def assert-app-initialized
|
(defn assert-app-initialized []
|
||||||
#(let [app-state @(rf/subscribe [:app-state])
|
(let [app-state @(rf/subscribe [:app-state])
|
||||||
multiaccounts-loading? @(rf/subscribe [:multiaccounts/loading])]
|
multiaccounts-loading? @(rf/subscribe [:multiaccounts/loading])]
|
||||||
(is (= "active" app-state))
|
(is (= "active" app-state))
|
||||||
(is (false? multiaccounts-loading?))))
|
(is (false? multiaccounts-loading?))))
|
||||||
|
|
||||||
(def assert-multiaccounts-generated
|
(defn assert-logout []
|
||||||
#(let [wizard-state @(rf/subscribe [:intro-wizard/choose-key])]
|
(let [multiaccounts-loading? @(rf/subscribe [:multiaccounts/loading])]
|
||||||
(is (= 5 (count (:multiaccounts wizard-state))))))
|
(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 []
|
(defn messenger-started []
|
||||||
@(rf/subscribe [:messenger/started?]))
|
@(rf/subscribe [:messenger/started?]))
|
||||||
|
|
||||||
(def assert-messenger-started
|
(defn assert-messenger-started []
|
||||||
#(is (messenger-started)))
|
(is (messenger-started)))
|
||||||
|
|
||||||
(deftest initialize-app-test
|
(deftest initialize-app-test
|
||||||
(rf-test/run-test-sync
|
(rf-test/run-test-sync
|
||||||
|
@ -43,6 +48,9 @@
|
||||||
(defn assert-multiaccount-loaded []
|
(defn assert-multiaccount-loaded []
|
||||||
(is (false? @(rf/subscribe [:multiaccounts/loading]))))
|
(is (false? @(rf/subscribe [:multiaccounts/loading]))))
|
||||||
|
|
||||||
|
(defn logout! []
|
||||||
|
(rf/dispatch [:logout]))
|
||||||
|
|
||||||
(deftest create-account-test
|
(deftest create-account-test
|
||||||
(rf-test/run-test-async
|
(rf-test/run-test-async
|
||||||
(initialize-app!) ; initialize app
|
(initialize-app!) ; initialize app
|
||||||
|
@ -55,7 +63,29 @@
|
||||||
(create-multiaccount!) ; create a multiaccount
|
(create-multiaccount!) ; create a multiaccount
|
||||||
(rf-test/wait-for ; wait for login
|
(rf-test/wait-for ; wait for login
|
||||||
[::transport/messenger-started]
|
[::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
|
(comment
|
||||||
(run-tests))
|
(run-tests))
|
||||||
|
|
|
@ -41,6 +41,8 @@
|
||||||
config
|
config
|
||||||
accounts-data))
|
accounts-data))
|
||||||
|
|
||||||
|
:logout (fn []
|
||||||
|
(.logout native-status))
|
||||||
:generateAliasAndIdenticonAsync (fn [seed callback]
|
:generateAliasAndIdenticonAsync (fn [seed callback]
|
||||||
(let [generated-identicon (.identicon native-status seed)
|
(let [generated-identicon (.identicon native-status seed)
|
||||||
generated-alias (.generateAlias native-status seed)]
|
generated-alias (.generateAlias native-status seed)]
|
||||||
|
|
Loading…
Reference in New Issue