Skip to content

Commit

Permalink
Separate setup code
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveWM committed Oct 28, 2023
1 parent 56ff4d4 commit f4468ab
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 52 deletions.
36 changes: 11 additions & 25 deletions src/status_im2/integration_test/chat.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,18 @@
[status-im2.integration-test.helpers :as helpers]
[status-im2.navigation.core]
[status-im2.subs.root] ; so integration tests can run independently
[taoensso.timbre :as log]))
[taoensso.timbre :as log])
(:require-macros
[status-im2.integration-test.macros :refer [with-app-initialized with-account]]))

(def chat-id
"0x0402905bed83f0bbf993cee8239012ccb1a8bc86907ead834c1e38476a0eda71414eed0e25f525f270592a2eebb01c9119a4ed6429ba114e51f5cb0a28dae1adfd")

(deftest one-to-one-chat-test
(log/info "========= one-to-one-chat-test ==================")
(rf-test/run-test-async
(helpers/initialize-app!)
(rf-test/wait-for
[:profile/get-profiles-overview-success]
(helpers/create-multiaccount!)
(rf-test/wait-for
[::transport/messenger-started]
(with-app-initialized
(with-account
(helpers/assert-messenger-started)
(rf/dispatch-sync [:chat.ui/start-chat chat-id]) ;; start a new chat
(rf-test/wait-for
Expand All @@ -38,12 +36,8 @@
(deftest delete-chat-test
(log/info "========= delete-chat-test ==================")
(rf-test/run-test-async
(helpers/initialize-app!)
(rf-test/wait-for
[:profile/get-profiles-overview-success]
(helpers/create-multiaccount!)
(rf-test/wait-for
[::transport/messenger-started]
(with-app-initialized
(with-account
(helpers/assert-messenger-started)
(rf/dispatch-sync [:chat.ui/start-chat chat-id]) ;; start a new chat
(rf-test/wait-for
Expand All @@ -59,12 +53,8 @@
(deftest mute-chat-test
(log/info "========= mute-chat-test ==================")
(rf-test/run-test-async
(helpers/initialize-app!)
(rf-test/wait-for
[:profile/get-profiles-overview-success]
(helpers/create-multiaccount!)
(rf-test/wait-for
[::transport/messenger-started]
(with-app-initialized
(with-account
(helpers/assert-messenger-started)
(rf/dispatch-sync [:chat.ui/start-chat chat-id]) ;; start a new chat
(rf-test/wait-for
Expand All @@ -91,12 +81,8 @@
"0x048a6773339d11ccf5fd81677b7e54daeec544a1287bd92b725047ad6faa9a9b9f8ea86ed5a226d2a994f5f46d0b43321fd8de7b7997a166e67905c8c73cd37cea"
primary-name "zQ3...9cX9gA"]
(rf-test/run-test-async
(helpers/initialize-app!)
(rf-test/wait-for
[:profile/get-profiles-overview-success]
(helpers/create-multiaccount!)
(rf-test/wait-for
[::transport/messenger-started]
(with-app-initialized
(with-account
(helpers/assert-messenger-started)
;; search for contact using compressed key
(rf/dispatch [:contacts/set-new-identity compressed-key])
Expand Down
21 changes: 7 additions & 14 deletions src/status_im2/integration_test/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
[status-im.events]
[status-im.multiaccounts.logout.core :as logout] ; so integration tests can run independently
[status-im.subs.root]
[status-im.transport.core :as transport]
[status-im.utils.test :as utils.test]
[status-im2.events]
[status-im2.integration-test.chat]
Expand All @@ -15,7 +14,9 @@
[status-im2.integration-test.wallet]
[status-im2.navigation.core] ; so integration tests can run independently
[status-im2.subs.root]
[taoensso.timbre :as log]))
[taoensso.timbre :as log])
(:require-macros
[status-im2.integration-test.macros :refer [with-app-initialized with-account]]))

(utils.test/init!)

Expand All @@ -34,25 +35,17 @@
(deftest create-account-test
(log/info "====== create-account-test ==================")
(rf-test/run-test-async
(helpers/initialize-app!) ; initialize app
(rf-test/wait-for
[:profile/get-profiles-overview-success]
(helpers/create-multiaccount!) ; create a multiaccount
(rf-test/wait-for ; wait for login
[::transport/messenger-started]
(with-app-initialized
(with-account
(helpers/assert-messenger-started)
(helpers/logout!)
(rf-test/wait-for [::logout/logout-method])))))

(deftest create-community-test
(log/info "====== create-community-test ==================")
(rf-test/run-test-async
(helpers/initialize-app!) ; initialize app
(rf-test/wait-for
[:profile/get-profiles-overview-success]
(helpers/create-multiaccount!) ; create a multiaccount
(rf-test/wait-for ; wait for login
[::transport/messenger-started]
(with-app-initialized
(with-account
(helpers/assert-messenger-started)
(rf/dispatch-sync [:legacy-only-for-e2e/open-create-community])
(doseq [[k v] (dissoc constants/community :membership)]
Expand Down
19 changes: 19 additions & 0 deletions src/status_im2/integration_test/macros.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
(ns status-im2.integration-test.macros
(:require [day8.re-frame.test :as rf-test]
[re-frame.core :as rf]))

(defmacro with-app-initialized
[& body]
`(do
(rf/dispatch [:app-started])
(rf-test/wait-for
[:profile/get-profiles-overview-success]
~@body)))

(defmacro with-account
[& body]
`(do
(status-im2.integration-test.helpers/create-multiaccount!)
(rf-test/wait-for
[:status-im.transport.core/messenger-started]
~@body)))
20 changes: 7 additions & 13 deletions src/status_im2/integration_test/wallet.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,15 @@
[status-im2.integration-test.helpers :as helpers]
[status-im2.navigation.core]
[status-im2.subs.root]
[taoensso.timbre :as log]))
[taoensso.timbre :as log])
(:require-macros
[status-im2.integration-test.macros :refer [with-app-initialized with-account]]))

(deftest create-wallet-account-test
(log/info "====== create-wallet-account-test ==================")
(rf-test/run-test-async
(helpers/initialize-app!)
(rf-test/wait-for
[:profile/get-profiles-overview-success]
(helpers/create-multiaccount!) ; create a multiaccount
(rf-test/wait-for ; wait for login
[::transport/messenger-started]
(with-app-initialized
(with-account
(helpers/assert-messenger-started)
(helpers/create-new-account!) ; create a new account
(rf-test/wait-for
Expand All @@ -34,12 +32,8 @@
(deftest back-up-seed-phrase-test
(log/info "========= back-up-seed-phrase-test ==================")
(rf-test/run-test-async
(helpers/initialize-app!)
(rf-test/wait-for
[:profile/get-profiles-overview-success]
(helpers/create-multiaccount!)
(rf-test/wait-for
[::transport/messenger-started]
(with-app-initialized
(with-account
(helpers/assert-messenger-started)
(rf/dispatch-sync [:set-in [:my-profile/seed :step] :12-words]) ; display seed phrase to user
(rf/dispatch-sync [:my-profile/enter-two-random-words]) ; begin prompting user for seed words
Expand Down

0 comments on commit f4468ab

Please sign in to comment.