Fix: actually run integration tests (#17900)

Integration tests weren't running since https://github.com/status-im/status-mobile/pull/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 https://github.com/status-im/status-mobile/issues/17895
This commit is contained in:
Icaro Motta 2023-11-15 19:51:09 -03:00 committed by GitHub
parent 5ceb7c2215
commit b9353b1ccd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 34 additions and 28 deletions

View File

@ -15,6 +15,8 @@
(def test-dir (.mkdtempSync fs test-dir-prefix))
(def initialized? (atom false))
(defn signal-received-callback
[a]
(re-frame/dispatch [:signals/signal-received a]))
@ -22,10 +24,12 @@
;; 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

View File

@ -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]
@ -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

View File

@ -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]

View File

@ -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]
@ -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

View File

@ -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]
@ -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
@ -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

View File

@ -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))))

View File

@ -1,4 +1,5 @@
(ns test-helpers.integration
(:require-macros [test-helpers.integration])
(:require
[cljs.test :refer [is]]
[native-module.core :as native-module]