[#13687] Extend integration tests to create a community

This commit is contained in:
Erik Seppanen 2022-08-10 08:46:16 -04:00 committed by Andrea Maria Piana
parent f1f9fa105c
commit 959df25c02
No known key found for this signature in database
GPG Key ID: AA6CCA6DE0E06424
2 changed files with 21 additions and 9 deletions

View File

@ -137,6 +137,7 @@
:setRoot identity :setRoot identity
:dismissOverlay #(js/Promise.resolve) :dismissOverlay #(js/Promise.resolve)
:setLazyComponentRegistrator identity :setLazyComponentRegistrator identity
:pop identity
:push identity :push identity
:registerComponent identity :registerComponent identity
:events :events

View File

@ -5,10 +5,13 @@
status-im.events status-im.events
[status-im.multiaccounts.logout.core :as logout] [status-im.multiaccounts.logout.core :as logout]
[status-im.transport.core :as transport] [status-im.transport.core :as transport]
;; status-im.subs ;;so integration tests can run independently
[status-im.utils.test :as utils.test])) [status-im.utils.test :as utils.test]))
(def password "testabc") (def password "testabc")
(def community {:membership 1 :name "foo" :description "bar"})
(utils.test/init!) (utils.test/init!)
(defn initialize-app! [] (defn initialize-app! []
@ -48,6 +51,9 @@
(defn assert-multiaccount-loaded [] (defn assert-multiaccount-loaded []
(is (false? @(rf/subscribe [:multiaccounts/loading])))) (is (false? @(rf/subscribe [:multiaccounts/loading]))))
(defn assert-community-created []
(is (= @(rf/subscribe [:communities/create]) community)))
(defn logout! [] (defn logout! []
(rf/dispatch [:logout])) (rf/dispatch [:logout]))
@ -68,24 +74,29 @@
(rf-test/wait-for [::logout/logout-method] ; we need to logout to make sure the node is not in an inconsistent state between tests (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))))))) (assert-logout)))))))
;; This test is only to make sure running multiple integration tests doesn't hang (deftest create-community-test
;; can be removed as soon as another test is added
(deftest create-account-test-safety-check
(rf-test/run-test-async (rf-test/run-test-async
(initialize-app!) ; initialize app (initialize-app!) ; initialize app
(rf-test/wait-for (rf-test/wait-for
[:status-im.init.core/initialize-multiaccounts] ; wait so we load accounts.db [:status-im.init.core/initialize-multiaccounts]
(generate-and-derive-addresses!) ; generate 5 new keys (generate-and-derive-addresses!) ; generate 5 new keys
(rf-test/wait-for (rf-test/wait-for
[:multiaccount-generate-and-derive-addresses-success] ; wait for the keys [:multiaccount-generate-and-derive-addresses-success]
(assert-multiaccount-loaded) ; assert keys are generated (assert-multiaccount-loaded) ; assert keys are generated
(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/dispatch-sync [:status-im.communities.core/open-create-community])
(rf-test/wait-for [::logout/logout-method] (doseq [[k v] (dissoc community :membership)]
(assert-logout))))))) (rf/dispatch-sync [:status-im.communities.core/create-field k v]))
(rf/dispatch [:status-im.communities.core/create-confirmation-pressed])
(rf-test/wait-for
[:status-im.communities.core/community-created]
(assert-community-created)
(logout!)
(rf-test/wait-for [::logout/logout-method]
(assert-logout))))))))
(comment (comment
(run-tests)) (run-tests))