Skip to content

Commit

Permalink
Fix: actually run integration tests (#17900)
Browse files Browse the repository at this point in the history
Integration tests weren't running since #17762 was merged a week ago.

This commit also allows individual integration test namespaces to run if you change the :ns-regexp option in shadow-cljs. This is quite handy, since they are relatively slow.

Fixes #17895
  • Loading branch information
ilmotta authored and yevh-berdnyk committed Dec 8, 2023
1 parent 1855132 commit ffa6efb
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 28 deletions.
12 changes: 8 additions & 4 deletions src/status_im/utils/test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,21 @@

(def test-dir (.mkdtempSync fs test-dir-prefix))

(def initialized? (atom false))

(defn signal-received-callback
[a]
(re-frame/dispatch [:signals/signal-received a]))

;; We poll for signals, could not get callback working
(defn init!
[]
(.setSignalEventCallback native-status)
(js/setInterval (fn []
(.pollSignal native-status signal-received-callback)
100)))
(when-not @initialized?
(.setSignalEventCallback native-status)
(reset! initialized? true)
(js/setInterval (fn []
(.pollSignal native-status signal-received-callback)
100))))

(def status
(clj->js
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(ns status-im2.integration-test.chat
(ns status-im2.integration-test.chat-test
(:require
[cljs.test :refer [deftest is]]
[day8.re-frame.test :as rf-test]
Expand All @@ -16,7 +16,7 @@
"0x0402905bed83f0bbf993cee8239012ccb1a8bc86907ead834c1e38476a0eda71414eed0e25f525f270592a2eebb01c9119a4ed6429ba114e51f5cb0a28dae1adfd")

(deftest one-to-one-chat-test
(h/log-headline one-to-one-chat-test)
(h/log-headline :one-to-one-chat-test)
(rf-test/run-test-async
(h/with-app-initialized
(h/with-account
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(ns status-im2.integration-test.community
(ns status-im2.integration-test.community-test
(:require [cljs.test :refer [deftest]]
[day8.re-frame.test :as rf-test]
[re-frame.core :as rf]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(ns status-im2.integration-test.core
(ns status-im2.integration-test.core-test
(:require
[cljs.test :refer [deftest]]
[day8.re-frame.test :as rf-test]
Expand All @@ -8,17 +8,14 @@
status-im.subs.root
[status-im.utils.test :as utils.test]
status-im2.events
status-im2.integration-test.chat
status-im2.integration-test.wallet
status-im2.navigation.core
status-im2.subs.root
[test-helpers.integration :as h]))

(utils.test/init!)

(deftest initialize-app-test
(h/log-headline :initialize-app-test)
(rf-test/run-test-async
(utils.test/init!)
(rf/dispatch [:app-started])
(rf-test/wait-for
;; use initialize-view because it has the longest avg. time and
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns status-im2.integration-test.wallet
(ns status-im2.integration-test.wallet-test
(:require
[cljs.test :refer [deftest is]]
[cljs.test :refer [is]]
[clojure.string :as string]
[day8.re-frame.test :as rf-test]
[re-frame.core :as rf]
Expand All @@ -12,7 +12,9 @@
status-im2.subs.root
[test-helpers.integration :as h]))

(deftest create-wallet-account-test
;; Workaround to skip test. Switch to `deftest` when test is fixed.
(defn create-wallet-account-test
[]
(h/log-headline :create-wallet-account-test)
(rf-test/run-test-async
(h/with-app-initialized
Expand All @@ -24,7 +26,9 @@
(h/logout)
(rf-test/wait-for [::logout/logout-method]))))))

(deftest back-up-seed-phrase-test
;; Workaround to skip test. Switch to `deftest` when test is fixed.
(defn back-up-seed-phrase-test
[]
(h/log-headline :back-up-seed-phrase-test)
(rf-test/run-test-async
(h/with-app-initialized
Expand Down
24 changes: 12 additions & 12 deletions src/test_helpers/integration.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@

(defmacro with-app-initialized
[& body]
`(if (app-initialized)
(do ~@body)
(do
(rf/dispatch [:app-started])
(rf-test/wait-for
[:profile/get-profiles-overview-success]
~@body))))
`(do
(status-im.utils.test/init!)
(if (test-helpers.integration/app-initialized)
(do ~@body)
(do
(rf/dispatch [:app-started])
(rf-test/wait-for [:profile/get-profiles-overview-success]
~@body)))))

(defmacro with-account
[& body]
`(if (messenger-started)
`(if (test-helpers.integration/messenger-started)
(do ~@body)
(do
(create-multiaccount!)
(rf-test/wait-for
[:status-im.transport.core/messenger-started]
(assert-messenger-started)
(test-helpers.integration/create-multiaccount!)
(rf-test/wait-for [:status-im.transport.core/messenger-started]
(test-helpers.integration/assert-messenger-started)
~@body))))
1 change: 1 addition & 0 deletions src/test_helpers/integration.cljs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
(ns test-helpers.integration
(:require-macros [test-helpers.integration])
(:require
[cljs.test :refer [is]]
[native-module.core :as native-module]
Expand Down

0 comments on commit ffa6efb

Please sign in to comment.