Onboarding tests: fixed existing and added new

This commit is contained in:
Gustavo Nunes 2017-01-26 22:55:45 -02:00 committed by Roman Volosovskyi
parent 4c3440425f
commit a8a588bb70
15 changed files with 140 additions and 94 deletions

36
env/dev/user.clj vendored
View File

@ -12,12 +12,23 @@
(apply hash-map)
:profiles))
(defn get-test-build [build]
(update build :source-paths
(fn [paths] (let [paths-set (set paths)]
(-> paths-set
(disj "env/dev")
(conj "env/test" "test/cljs")
vec)))))
(def cljs-builds
(get-in profiles [:dev :cljsbuild :builds]))
(def buids-by-id
(into {} (map (fn [{:keys [id] :as build}] [id build]) cljs-builds)))
(defn start-figwheel
"Start figwheel for one or more builds"
[build-ids]
[build-ids cljs-builds]
(ra/start-figwheel!
{:figwheel-options {:nrepl-port 7888}
:build-ids build-ids
@ -38,8 +49,27 @@
(spit path js-resourced))
ctx)}])
(defn test-id? [id]
(s/includes? (name id) "-test"))
(defn get-id [id]
(-> id
name
(s/replace #"-test" "")
keyword))
(defn get-builds [ids all-builds]
(keep
(fn [id]
(let [build (get all-builds (get-id id))]
(if (test-id? id)
(get-test-build build)
build)))
ids))
(let [env-build-ids (System/getenv "BUILD_IDS")
build-ids (if env-build-ids
(map keyword (s/split env-build-ids #","))
[:android])]
(start-figwheel build-ids))
[:android])
builds (get-builds build-ids buids-by-id)]
(start-figwheel build-ids builds))

View File

@ -1,21 +1,25 @@
(ns ^:figwheel-no-load env.android-test.main
(ns ^:figwheel-no-load env.android.main
(:require [reagent.core :as r]
[status-im.android.core :as core]
[figwheel.client :as figwheel :include-macros true]
;[status-im.test.handlers-stubs :refer [init-stubs]]
))
(enable-console-print!)
[status-im.test.handlers-stubs :refer [init-stubs]]))
(set! js/console.disableYellowBox true)
(enable-console-print!)
(def cnt (r/atom 0))
(defn reloader [] @cnt [core/app-root])
(def root-el (r/as-element [reloader]))
(defn callback []
(swap! cnt inc)
(status-im.components.status/init-jail)
(re-frame.core/dispatch [:load-commands!]))
(figwheel/watch-and-reload
:websocket-url "ws://localhost:3449/figwheel-ws"
:websocket-url "ws://10.0.3.2:3449/figwheel-ws"
:heads-up-display false
:jsload-callback #(swap! cnt inc))
:jsload-callback callback)
(core/init)
;(init-stubs)
(init-stubs)

View File

@ -4,7 +4,7 @@
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.9.0-alpha13"]
[org.clojure/clojurescript "1.9.229"]
[org.clojure/clojurescript "1.9.456"]
[reagent "0.6.0" :exclusions [cljsjs/react cljsjs/react-dom cljsjs/react-dom-server]]
[re-frame "0.7.0"]
[natal-shell "0.3.0"]
@ -40,12 +40,6 @@
:main "env.android.main"
:output-dir "target/android"
:optimizations :none}}
{:id :android-test
:source-paths ["src" "env/dev"]
:compiler {:output-to "target/android/not-used.js"
:main "env.android-test.main"
:output-dir "target/android-test"
:optimizations :none}}
{:id :test
:source-paths ["src" "test/cljs"]
:compiler

View File

@ -0,0 +1,17 @@
(ns status-im.accessibility-ids)
;; Toolbar
(def toolbar-back-button :toolbar-back-button)
;; Drawer
(def drawer-status-input :drawer-status-input)
;; Chat
(def chat-cancel-response-button :chat-cancel-response-button)
(def chat-message-input :chat-message-input)
(def chat-send-button :chat-send-button)
(defn chat-request-message-button [command-name]
(keyword (str "request-" (name command-name))))
;; Accounts
(def accounts-create-button :accounts-create-button)

View File

@ -21,6 +21,7 @@
[status-im.utils.listview :as lw]
[status-im.accounts.views.account :refer [account-view]]
[status-im.i18n :refer [label]]
[status-im.accessibility-ids :as id]
[status-im.accounts.styles :as st]
[status-im.constants :refer [console-chat-id]]))
@ -74,7 +75,7 @@
(label :t/recover-access)]]]]
[view st/add-account-button-container
[touchable-highlight {:on-press create-account
:accessibility-label :create-account}
:accessibility-label id/accounts-create-button}
[view st/add-account-button
[image {:source {:uri :icon_add_white}
:style st/icon-plus}]

View File

@ -12,6 +12,7 @@
[status-im.chat.styles.message-input :as st]
[status-im.chat.styles.plain-message :as st-message]
[status-im.chat.styles.response :as st-response]
[status-im.accessibility-ids :as id]
[reagent.core :as r]
[clojure.string :as str]))
@ -49,7 +50,7 @@
(.-contentSize)
(.-height))]
(set-layout-size size))
:accessibility-label :input
:accessibility-label id/chat-message-input
:on-focus #(do (dispatch [:set :focused true])
(dispatch [:set-chat-ui-props :show-emoji? false]))
:on-blur #(do (dispatch [:set :focused false])
@ -65,7 +66,7 @@
(command-input-options icon-width disable? sending-disabled?)
{:auto-focus (not fullscreen)
:blur-on-submit false
:accessibility-label :input
:accessibility-label id/chat-message-input
:on-focus #(dispatch [:set :focused true])
:on-blur #(dispatch [:set :focused false])
:default-value (or input-command "")}
@ -110,7 +111,7 @@
[send-button {:on-press (fn [e]
(when-not @sending-disabled?
(dispatch [:set-chat-ui-props :show-emoji? false])
(on-press e)))}]))
(on-press e)))
:accessibility-label id/chat-send-button}]))
(when (and @command? (= :command (:type @command)))
[command/command-icon @command])]]))})))

View File

@ -8,6 +8,7 @@
icon
touchable-highlight]]
[status-im.chat.styles.message :as st]
[status-im.accessibility-ids :as id]
[status-im.models.commands :refer [parse-command-request]]
[status-im.components.animation :as anim]))
@ -18,12 +19,6 @@
params (:set-params command)]
(dispatch [:set-response-chat-command message-id command-key params])))
(defn label [command]
(when command
(->> (:name command)
name
(str "request-"))))
(def min-scale 1)
(def max-scale 1.3)
@ -66,7 +61,7 @@
{:on-press (when (and (not @answered?) status-initialized?)
#(set-chat-command message-id command))
:style (st/command-request-image-touchable top-offset?)
:accessibility-label (label command)}
:accessibility-label (id/chat-request-message-button (:name command))}
[animated-view {:style (st/command-request-image-view command scale-anim-val)}
(when command-icon
[icon command-icon st/command-request-image])]]))})))

View File

@ -21,6 +21,7 @@
[status-im.utils.platform :refer [ios?]]
[status-im.components.webview-bridge :refer [webview-bridge]]
[status-im.i18n :refer [label]]
[status-im.accessibility-ids :as id]
[status-im.utils.datetime :as dt]
[status-im.utils.name :refer [shortened-name]]
[status-im.utils.js-resources :as js-res]
@ -69,7 +70,8 @@
[view st/inner-container
[command-icon @command]
[info-container @command]
[touchable-highlight {:on-press #(dispatch [:start-cancel-command])}
[touchable-highlight {:on-press #(dispatch [:start-cancel-command])
:accessibility-label id/chat-cancel-response-button}
[view st/cancel-container
[icon :close_white st/cancel-icon]]]]]
[view (merge (drag/pan-handlers pan-responder)

View File

@ -18,6 +18,7 @@
[status-im.utils.gfycat.core :refer [generate-gfy]]
[status-im.utils.utils :refer [clean-text]]
[status-im.i18n :refer [label]]
[status-im.accessibility-ids :as id]
[status-im.components.react :refer [dismiss-keyboard!]]
[clojure.string :as str]
[status-im.components.chat-icon.screen :as ci]))
@ -82,7 +83,7 @@
:auto-focus true
:focus status-edit?
:max-length 140
:accessibility-label :input
:accessibility-label id/drawer-status-input
:placeholder (label :t/profile-no-status)
:default-value status
:on-blur #(do

View File

@ -11,6 +11,7 @@
icon-search]]
[status-im.components.toolbar.actions :as act]
[status-im.components.toolbar.styles :as st]
[status-im.accessibility-ids :as id]
[status-im.utils.platform :refer [platform-specific]]))
(defn toolbar [{title :title
@ -31,7 +32,7 @@
[view (get-in platform-specific [:component-styles :toolbar-nav-action])
[image (:image nav-action)]]]
[touchable-highlight {:on-press #(dispatch [:navigate-back])
:accessibility-label :navigate-back}
:accessibility-label id/toolbar-back-button}
[view (get-in platform-specific [:component-styles :toolbar-nav-action])
[image {:source {:uri :icon_back}
:style icon-back}]]]))]

View File

@ -1,51 +0,0 @@
(ns status-im.console
(:require [clojure.test :refer :all]
[status-im.appium :refer :all]))
(def message-text
(str "Your phone number is also required to use the app. Type"
" the exclamation mark or hit the icon to open the command "
"list and choose the !phone command"))
(defaction send-sommand []
(click :send-message)
(click :send-message))
(defaction respond-to-request
[request value]
(click (keyword (str "request-" (name request))))
(write :input value)
(send-sommand))
(appium-test happy-case
(click :create-account)
(respond-to-request :keypair "123")
(contains-text message-text)
(respond-to-request :phone "+380671111111")
(respond-to-request :confirmation-code "1234")
(click :navigate-back)
(contains-text "Switch users"))
(appium-test wrong-confirmation-code
(click :create-account)
(respond-to-request :keypair "123")
(respond-to-request :phone "+380671111111")
(respond-to-request :confirmation-code "432")
(contains-text "Wrong format")
(respond-to-request :confirmation-code "4321")
(contains-text "Wrong code!")
(write :input "1234")
(send-sommand)
(click :navigate-back)
(contains-text "Switch users"))
(appium-test wrong-phone-number
(click :create-account)
(respond-to-request :keypair "123")
(respond-to-request :phone "+380671111111")
(write :input "+380671111112")
(send-sommand)
(write :input "1234")
(send-sommand)
(click :navigate-back)
(contains-text "Switch users"))

View File

@ -1,4 +1,4 @@
(ns status-im.appium
(ns status-im.test.appium
(:require [clojure.java.io :as io]
[clojure.test :refer :all])
(:import (org.openqa.selenium.remote DesiredCapabilities)
@ -14,7 +14,6 @@
app (io/file dir "app-debug.apk")
capabilities (doto (DesiredCapabilities.)
(.setCapability "deviceName" "device")
(.setCapability "platformVersion" "6.0.0")
(.setCapability "app" (.getAbsolutePath app))
(.setCapability "appPackage" "im.status.ethereum")
(.setCapability "appActivity" ".MainActivity"))
@ -49,7 +48,7 @@
(.getText (by-xpath driver xpath)))
(defn xpath-by-text [text]
(str ".//*[@text='" text "']"))
(str ".//*[@text=\"" text "\"]"))
(defn click-by-text [driver text]
(let [elements (->> (xpath-by-text text)
@ -70,7 +69,9 @@
(defmacro appium-test
"Defines test which will create new appium session and will pass that
session as first argument to each command inside it's body. After execution
of all commands session will be closed.
of all commands, the session will be closed.
Also, at the start of every test, the 'Continue' button from the 'Your phone
appears to be ROOTED' message will be pressed.
For instance,

View File

@ -0,0 +1,49 @@
(ns status-im.test.console
(:require [clojure.test :refer :all]
[status-im.accessibility-ids :as id]
[status-im.test.appium :refer :all]))
(defaction send-command []
(click id/chat-send-button))
(defaction respond-to-request [request value]
(click (id/chat-request-message-button request))
(write id/chat-message-input value)
(send-command))
(defaction confirm-password [value]
(write id/chat-message-input value)
(send-command))
(appium-test sign-up-successfully
(respond-to-request :password "password")
(confirm-password "password")
(respond-to-request :phone "2015550123")
(respond-to-request :confirmation-code "1234")
(contains-text "Done!")
(click id/toolbar-back-button)
(contains-text "Chats"))
(appium-test wrong-password
(respond-to-request :password "abc")
(contains-text "Password should be not less then 6 symbols.")
(click id/chat-cancel-response-button)
(respond-to-request :password "password")
(confirm-password "abc")
(contains-text "Password confirmation doesn't match password."))
(appium-test wrong-phone-number
(respond-to-request :password "password")
(confirm-password "password")
(respond-to-request :phone "1234")
(contains-text "Invalid phone number"))
(appium-test wrong-confirmation-code
(respond-to-request :password "password")
(confirm-password "password")
(respond-to-request :phone "2015550123")
(respond-to-request :confirmation-code "432")
(contains-text "Wrong format")
(click id/chat-cancel-response-button)
(respond-to-request :confirmation-code "4321")
(contains-text "Wrong code!"))

View File

@ -7,9 +7,10 @@
(defn init-stubs []
(register-handler :sign-up
(u/side-effect!
(fn []
;; todo save phone number to db
(sign-up-service/on-sign-up-response)))
(sign-up-service/on-sign-up-response))))
(register-handler :sign-up-confirm
(u/side-effect!

View File

@ -1,7 +1,7 @@
(ns status-im.test.runner
(:require [doo.runner :refer-macros [doo-tests]]
(:require #_[doo.runner :refer-macros [doo-tests]]
[status-im.test.handlers]
[status-im.test.commands.handlers]))
(doo-tests 'status-im.test.handlers
#_(doo-tests 'status-im.test.handlers
'status-im.test.commands.handlers)