🚟 Add schema batch 2 (#18696)
* 🚟 Add schema batch 2 * ⏬ Add maybe and optionals * 🧑⚖️ Make theme a required prop * 🍙 Fix misplaced square brackets that broke spec * 🎨 Assume default theme and fix tests - Fixes #18734 * ⬆️ Update schema and rebase * 🧪 Update tests * 🆙 Update progress bar value to be string or int * 🔩 Tighten schema
This commit is contained in:
parent
6669c33e33
commit
abe0342be0
|
@ -2,7 +2,6 @@
|
|||
(:require [quo.core :as quo]
|
||||
[test-helpers.component :as h]))
|
||||
|
||||
(def ^:private theme :light)
|
||||
|
||||
(defn- get-test-data
|
||||
[{:keys [state network]
|
||||
|
@ -18,94 +17,99 @@
|
|||
(h/test "component renders when state is sending and network is optimism"
|
||||
(h/render-with-theme-provider [quo/confirmation-propgress
|
||||
(get-test-data {:state :sending
|
||||
:network :optimism})]
|
||||
theme)
|
||||
(h/is-truthy (h/get-by-label-text :progress-box)))
|
||||
:network :optimism})])
|
||||
(h/is-truthy (h/get-by-label-text :progress-box))))
|
||||
|
||||
(h/test "component renders when state is confirmed and network is optimism"
|
||||
(h/render-with-theme-provider [quo/confirmation-propgress
|
||||
(get-test-data {:state :confirmed
|
||||
:network :optimism})]
|
||||
theme)
|
||||
(h/is-truthy (h/get-by-label-text :progress-box)))
|
||||
(h/test "component renders when state is confirmed and network is optimism"
|
||||
(h/render-with-theme-provider
|
||||
[quo/confirmation-propgress
|
||||
(get-test-data {:state :confirmed
|
||||
:network :optimism})])
|
||||
(h/is-truthy (h/get-by-label-text :progress-box)))
|
||||
|
||||
(h/test "component renders when state is finalising and network is optimism"
|
||||
(h/render-with-theme-provider [quo/confirmation-propgress
|
||||
(get-test-data {:state :finalising
|
||||
:network :optimism})]
|
||||
theme)
|
||||
(h/is-truthy (h/get-by-label-text :progress-box)))
|
||||
(h/test "component renders when state is finalising and network is optimism"
|
||||
(h/render-with-theme-provider
|
||||
[quo/confirmation-propgress
|
||||
(get-test-data {:state :finalising
|
||||
:network :optimism})])
|
||||
(h/is-truthy (h/get-by-label-text :progress-box)))
|
||||
|
||||
(h/test "component renders when state is finalized and network is optimism"
|
||||
(h/render-with-theme-provider [quo/confirmation-propgress
|
||||
(get-test-data {:state :finalized
|
||||
:network :optimism})]
|
||||
theme)
|
||||
(h/is-truthy (h/get-by-label-text :progress-box)))
|
||||
(h/test "component renders when state is finalized and network is optimism"
|
||||
(h/render-with-theme-provider
|
||||
[quo/confirmation-propgress
|
||||
(get-test-data {:state :finalized
|
||||
:network :optimism})])
|
||||
(h/is-truthy (h/get-by-label-text :progress-box)))
|
||||
|
||||
(h/test "component renders when state is error and network is optimism"
|
||||
(h/render-with-theme-provider [quo/confirmation-propgress
|
||||
(get-test-data {:state :error
|
||||
:network :optimism})]
|
||||
theme)
|
||||
(h/is-truthy (h/get-by-label-text :progress-box)))
|
||||
(h/test "component renders when state is error and network is optimism"
|
||||
(h/render-with-theme-provider
|
||||
[quo/confirmation-propgress
|
||||
(get-test-data {:state :error
|
||||
:network :optimism})])
|
||||
(h/is-truthy (h/get-by-label-text :progress-box)))
|
||||
|
||||
(h/test "component renders when state is sending and network is arbitrum"
|
||||
(h/render-with-theme-provider [quo/confirmation-propgress
|
||||
(get-test-data {:state :sending
|
||||
:network :arbitrum})]
|
||||
theme)
|
||||
(h/is-truthy (h/get-by-label-text :progress-box)))
|
||||
(h/test "component renders when state is sending and network is arbitrum"
|
||||
(h/render-with-theme-provider
|
||||
[quo/confirmation-propgress
|
||||
(get-test-data {:state :sending
|
||||
:network :arbitrum})])
|
||||
(h/is-truthy (h/get-by-label-text :progress-box)))
|
||||
|
||||
(h/test "component renders when state is confirmed and network is arbitrum"
|
||||
(h/render-with-theme-provider [quo/confirmation-propgress
|
||||
(get-test-data {:state :confirmed
|
||||
:network :arbitrum})]
|
||||
theme)
|
||||
(h/is-truthy (h/get-by-label-text :progress-box)))
|
||||
(h/test "component renders when state is confirmed and network is arbitrum"
|
||||
(h/render-with-theme-provider
|
||||
[quo/confirmation-propgress
|
||||
(get-test-data {:state :confirmed
|
||||
:network :arbitrum})])
|
||||
(h/is-truthy (h/get-by-label-text :progress-box)))
|
||||
|
||||
(h/test "component renders when state is finalising and network is arbitrum"
|
||||
(h/render-with-theme-provider [quo/confirmation-propgress
|
||||
(get-test-data {:state :finalising
|
||||
:network :arbitrum})]
|
||||
theme)
|
||||
(h/is-truthy (h/get-by-label-text :progress-box)))
|
||||
(h/test "component renders when state is finalising and network is arbitrum"
|
||||
(h/render-with-theme-provider
|
||||
[quo/confirmation-propgress
|
||||
(get-test-data {:state :finalising
|
||||
:network :arbitrum})])
|
||||
(h/is-truthy (h/get-by-label-text :progress-box)))
|
||||
|
||||
(h/test "component renders when state is finalized and network is arbitrum"
|
||||
(h/render-with-theme-provider [quo/confirmation-propgress
|
||||
(get-test-data {:state :finalized
|
||||
:network :arbitrum})]
|
||||
theme)
|
||||
(h/is-truthy (h/get-by-label-text :progress-box)))
|
||||
(h/test "component renders when state is finalized and network is arbitrum"
|
||||
(h/render-with-theme-provider
|
||||
[quo/confirmation-propgress
|
||||
(get-test-data {:state :finalized
|
||||
:network :arbitrum})])
|
||||
(h/is-truthy (h/get-by-label-text :progress-box)))
|
||||
|
||||
(h/test "component renders when state is error and network is arbitrum"
|
||||
(h/render-with-theme-provider [quo/confirmation-propgress
|
||||
(get-test-data {:state :error
|
||||
:network :arbitrum})]
|
||||
theme)
|
||||
(h/is-truthy (h/get-by-label-text :progress-box)))
|
||||
(h/test "component renders when state is error and network is arbitrum"
|
||||
(h/render-with-theme-provider
|
||||
[quo/confirmation-propgress
|
||||
(get-test-data {:state :error
|
||||
:network :arbitrum})])
|
||||
(h/is-truthy (h/get-by-label-text :progress-box)))
|
||||
|
||||
(h/test "component renders when state is pending and network is mainnet"
|
||||
(h/render-with-theme-provider [quo/confirmation-propgress (get-test-data {})] theme)
|
||||
(h/is-truthy (h/get-by-label-text :mainnet-progress-box)))
|
||||
(h/test "component renders when state is pending and network is mainnet"
|
||||
(h/render-with-theme-provider
|
||||
[quo/confirmation-propgress (get-test-data {})])
|
||||
(h/is-truthy (h/get-by-label-text :mainnet-progress-box)))
|
||||
|
||||
(h/test "component renders when state is sending and network is mainnet"
|
||||
(h/render-with-theme-provider [quo/confirmation-propgress (get-test-data {:state :sending})] theme)
|
||||
(h/is-truthy (h/get-by-label-text :mainnet-progress-box)))
|
||||
(h/test "component renders when state is sending and network is mainnet"
|
||||
(h/render-with-theme-provider
|
||||
[quo/confirmation-propgress (get-test-data {:state :sending})])
|
||||
(h/is-truthy (h/get-by-label-text :mainnet-progress-box)))
|
||||
|
||||
(h/test "component renders when state is confirmed and network is mainnet"
|
||||
(h/render-with-theme-provider [quo/confirmation-propgress (get-test-data {:state :confirmed})] theme)
|
||||
(h/is-truthy (h/get-by-label-text :mainnet-progress-box)))
|
||||
(h/test "component renders when state is confirmed and network is mainnet"
|
||||
(h/render-with-theme-provider
|
||||
[quo/confirmation-propgress (get-test-data {:state :confirmed})])
|
||||
(h/is-truthy (h/get-by-label-text :mainnet-progress-box)))
|
||||
|
||||
(h/test "component renders when state is finalising and network is mainnet"
|
||||
(h/render-with-theme-provider [quo/confirmation-propgress (get-test-data {:state :finalising})]
|
||||
theme)
|
||||
(h/is-truthy (h/get-by-label-text :mainnet-progress-box)))
|
||||
(h/test "component renders when state is finalising and network is mainnet"
|
||||
(h/render-with-theme-provider
|
||||
[quo/confirmation-propgress (get-test-data {:state :finalising})])
|
||||
(h/is-truthy (h/get-by-label-text :mainnet-progress-box)))
|
||||
|
||||
(h/test "component renders when state is finalized and network is mainnet"
|
||||
(h/render-with-theme-provider [quo/confirmation-propgress (get-test-data {:state :finalized})] theme)
|
||||
(h/is-truthy (h/get-by-label-text :mainnet-progress-box)))
|
||||
(h/test "component renders when state is finalized and network is mainnet"
|
||||
(h/render-with-theme-provider
|
||||
[quo/confirmation-propgress (get-test-data {:state :finalized})])
|
||||
(h/is-truthy (h/get-by-label-text :mainnet-progress-box)))
|
||||
|
||||
(h/test "component renders when state is error and network is mainnet"
|
||||
(h/render-with-theme-provider [quo/confirmation-propgress (get-test-data {:state :error})] theme)
|
||||
(h/is-truthy (h/get-by-label-text :mainnet-progress-box))))
|
||||
(h/test "component renders when state is error and network is mainnet"
|
||||
(h/render-with-theme-provider
|
||||
[quo/confirmation-propgress
|
||||
(get-test-data {:state :error})])
|
||||
(h/is-truthy (h/get-by-label-text :mainnet-progress-box)))
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
|
||||
(h/describe "Wallet: Network Amount"
|
||||
(h/test "Amount renders"
|
||||
(h/render [network-amount/view
|
||||
{:amount "5.123"
|
||||
:token :eth}])
|
||||
(h/render-with-theme-provider
|
||||
[network-amount/view
|
||||
{:amount "5.123"
|
||||
:token :eth}])
|
||||
(h/is-truthy (h/get-by-text "5.123 ETH"))))
|
||||
|
|
|
@ -5,7 +5,18 @@
|
|||
[quo.components.utilities.token.view :as token]
|
||||
[quo.components.wallet.network-amount.style :as style]
|
||||
[quo.theme :as quo.theme]
|
||||
[react-native.core :as rn]))
|
||||
[react-native.core :as rn]
|
||||
[schema.core :as schema]))
|
||||
|
||||
(def ?schema
|
||||
[:=>
|
||||
[:catn
|
||||
[:props
|
||||
[:map {:closed true}
|
||||
[:amount {:optional true} [:maybe :string]]
|
||||
[:token {:optional true} [:or :keyword :string]]
|
||||
[:theme :schema.common/theme]]]]
|
||||
:any])
|
||||
|
||||
(defn- view-internal
|
||||
[{:keys [amount token theme]}]
|
||||
|
@ -19,4 +30,4 @@
|
|||
[rn/view
|
||||
{:style (style/divider theme)}]])
|
||||
|
||||
(def view (quo.theme/with-theme view-internal))
|
||||
(def view (quo.theme/with-theme (schema/instrument #'view-internal ?schema)))
|
||||
|
|
|
@ -4,37 +4,37 @@
|
|||
[test-helpers.component :as h]))
|
||||
|
||||
(h/describe "Wallet: Network Bridge"
|
||||
(h/test "Amount renders"
|
||||
(h/render [network-bridge/view
|
||||
{:amount "50 SNT"
|
||||
:network :ethereum
|
||||
:status :default}])
|
||||
(h/test "Amount render-with-theme-providers"
|
||||
(h/render-with-theme-provider [network-bridge/view
|
||||
{:amount "50 SNT"
|
||||
:network :ethereum
|
||||
:status :default}])
|
||||
(h/is-truthy (h/get-by-text "50 SNT")))
|
||||
|
||||
(h/test "Network label renders"
|
||||
(h/render [network-bridge/view
|
||||
{:amount "50 SNT"
|
||||
:network :optimism
|
||||
:status :default}])
|
||||
(h/test "Network label render"
|
||||
(h/render-with-theme-provider [network-bridge/view
|
||||
{:amount "50 SNT"
|
||||
:network :optimism
|
||||
:status :default}])
|
||||
(h/is-truthy (h/get-by-text "Optimism")))
|
||||
|
||||
(h/test "Locked state"
|
||||
(h/render [network-bridge/view
|
||||
{:amount "50 SNT"
|
||||
:network :optimism
|
||||
:status :locked}])
|
||||
(h/render-with-theme-provider [network-bridge/view
|
||||
{:amount "50 SNT"
|
||||
:network :optimism
|
||||
:status :locked}])
|
||||
(h/is-truthy (h/get-by-label-text :lock)))
|
||||
|
||||
(h/test "Loading state"
|
||||
(h/render [network-bridge/view
|
||||
{:amount "50 SNT"
|
||||
:network :optimism
|
||||
:status :loading}])
|
||||
(h/render-with-theme-provider [network-bridge/view
|
||||
{:amount "50 SNT"
|
||||
:network :optimism
|
||||
:status :loading}])
|
||||
(h/is-truthy (h/get-by-label-text :loading)))
|
||||
|
||||
(h/test "Disabled state"
|
||||
(h/render [network-bridge/view
|
||||
{:amount "50 SNT"
|
||||
:network :optimism
|
||||
:status :disabled}])
|
||||
(h/render-with-theme-provider [network-bridge/view
|
||||
{:amount "50 SNT"
|
||||
:network :optimism
|
||||
:status :disabled}])
|
||||
(h/has-style (h/get-by-label-text :container) {:opacity 0.3})))
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
[quo.foundations.colors :as colors]
|
||||
[quo.foundations.resources :as resources]
|
||||
[quo.theme :as quo.theme]
|
||||
[react-native.core :as rn]))
|
||||
[react-native.core :as rn]
|
||||
[schema.core :as schema]))
|
||||
|
||||
(defn network-bridge-add
|
||||
[{:keys [network state theme container-style on-press]}]
|
||||
|
@ -24,6 +25,22 @@
|
|||
(= network :ethereum) "Mainnet"
|
||||
:else (string/capitalize (name network))))
|
||||
|
||||
(def ^:private ?network-bridge-status
|
||||
[:enum :add :loading :locked :disabled :default])
|
||||
|
||||
(def ?schema
|
||||
[:=>
|
||||
[:catn
|
||||
[:props
|
||||
[:map
|
||||
[:theme :schema.common/theme]
|
||||
[:network {:optional true} [:maybe :keyword]]
|
||||
[:status {:optional true} [:maybe ?network-bridge-status]]
|
||||
[:amount {:optional true} [:maybe :string]]
|
||||
[:container-style {:optional true} [:maybe :map]]
|
||||
[:on-press {:optional true} [:maybe fn?]]]]]
|
||||
:any])
|
||||
|
||||
(defn view-internal
|
||||
[{:keys [theme network status amount container-style on-press] :as args}]
|
||||
(if (= status :add)
|
||||
|
@ -62,4 +79,6 @@
|
|||
:style {:color (colors/theme-colors colors/neutral-50 colors/neutral-40 theme)}}
|
||||
(network->text network)]]]))
|
||||
|
||||
(def view (quo.theme/with-theme view-internal))
|
||||
(def view
|
||||
(quo.theme/with-theme
|
||||
(schema/instrument #'view-internal ?schema)))
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
(ns quo.components.wallet.network-routing.component-spec
|
||||
(:require [oops.core :as oops]
|
||||
[quo.components.wallet.network-routing.view :as network-routing]
|
||||
quo.theme
|
||||
[reagent.core :as reagent]
|
||||
[test-helpers.component :as h]))
|
||||
|
||||
|
@ -11,17 +12,18 @@
|
|||
:requesting-data? false
|
||||
:on-amount-selected (fn [_new-amount _network-idx] nil)}]
|
||||
(h/test "Renders Default"
|
||||
(h/render [network-routing/view default-props])
|
||||
(h/render-with-theme-provider [network-routing/view default-props])
|
||||
(h/is-truthy (h/get-by-label-text :network-routing)))
|
||||
|
||||
(h/test "Renders bars inside"
|
||||
(let [component (h/render [network-routing/view default-props])
|
||||
(let [component (h/render-with-theme-provider [network-routing/view default-props])
|
||||
rerender-fn #((oops/oget component "rerender") (reagent/as-element %))
|
||||
component (h/get-by-label-text :network-routing)]
|
||||
;; Fires on-layout callback since the total width is required
|
||||
(h/fire-event :layout component #js {:nativeEvent #js {:layout #js {:width 1000}}})
|
||||
;; Update props to trigger rerender, otherwise it won't be updated
|
||||
(rerender-fn [network-routing/view (assoc default-props :requesting-data? true)])
|
||||
(rerender-fn [quo.theme/provider {:theme :light}
|
||||
[network-routing/view (assoc default-props :requesting-data? true)]])
|
||||
;; Check number of networks rendered
|
||||
(->> (js->clj (h/query-all-by-label-text :network-routing-bar))
|
||||
(count)
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
[react-native.gesture :as gesture]
|
||||
[react-native.reanimated :as reanimated]
|
||||
[reagent.core :as reagent]
|
||||
[schema.core :as schema]
|
||||
[utils.number]))
|
||||
|
||||
(def ^:private timeouts (atom {}))
|
||||
|
@ -172,6 +173,22 @@
|
|||
[rn/view {:style (style/max-limit-bar-background network-name)}]
|
||||
[dashed-line network-name]])]))))
|
||||
|
||||
(def ?schema
|
||||
[:=>
|
||||
[:catn
|
||||
[:props
|
||||
[:map
|
||||
[:networks {:optional true}
|
||||
[:maybe
|
||||
[:sequential
|
||||
[:map
|
||||
[:amount :int]
|
||||
[:max-amount :int]
|
||||
[:network-name [:or :string :keyword]]]]]]
|
||||
[:container-style {:optional true} [:maybe :map]]
|
||||
[:theme :schema.common/theme]]]]
|
||||
:any])
|
||||
|
||||
(defn view-internal
|
||||
[{:keys [networks container-style theme] :as params}]
|
||||
(reagent/with-let [total-width (reagent/atom nil)]
|
||||
|
@ -186,4 +203,6 @@
|
|||
(doseq [[_ living-timeout] @timeouts]
|
||||
(js/clearTimeout living-timeout)))))
|
||||
|
||||
(def view (quo.theme/with-theme view-internal))
|
||||
(def view
|
||||
(quo.theme/with-theme
|
||||
(schema/instrument #'view-internal ?schema)))
|
||||
|
|
|
@ -2,7 +2,19 @@
|
|||
(:require
|
||||
[quo.components.wallet.progress-bar.style :as style]
|
||||
[quo.theme :as quo.theme]
|
||||
[react-native.core :as rn]))
|
||||
[react-native.core :as rn]
|
||||
[schema.core :as schema]))
|
||||
|
||||
(def ?schema
|
||||
[:=>
|
||||
[:catn
|
||||
[:props
|
||||
[:map
|
||||
[:customization-color {:optional true} [:maybe :schema.common/customization-color]]
|
||||
[:theme :schema.common/theme]
|
||||
[:progressed-value {:optional true} [:maybe [:or :string :int]]]
|
||||
[:full-width? {:optional true} [:maybe :boolean]]]]]
|
||||
:any])
|
||||
|
||||
(defn- view-internal
|
||||
[{:keys [full-width?] :as props}]
|
||||
|
@ -12,4 +24,6 @@
|
|||
(when full-width?
|
||||
[rn/view {:style (style/progressed-bar props)}])])
|
||||
|
||||
(def view (quo.theme/with-theme view-internal))
|
||||
(def view
|
||||
(quo.theme/with-theme
|
||||
(schema/instrument #'view-internal ?schema)))
|
||||
|
|
|
@ -13,48 +13,49 @@
|
|||
|
||||
(h/describe "Wallet: Summary Info"
|
||||
(h/test "Type of `status-account` title renders"
|
||||
(h/render [summary-info/view
|
||||
{:type :status-account
|
||||
:networks? true
|
||||
:values {:ethereum 150
|
||||
:optimism 50
|
||||
:arbitrum 25}
|
||||
:account-props status-account-props}])
|
||||
(h/render-with-theme-provider [summary-info/view
|
||||
{:type :status-account
|
||||
:networks? true
|
||||
:values {:ethereum 150
|
||||
:optimism 50
|
||||
:arbitrum 25}
|
||||
:account-props status-account-props}])
|
||||
(h/is-truthy (h/get-by-text "Collectibles vault")))
|
||||
|
||||
(h/test "Type of `user` title renders"
|
||||
(h/render [summary-info/view
|
||||
{:type :user
|
||||
:networks? true
|
||||
:values {:ethereum 150
|
||||
:optimism 50
|
||||
:arbitrum 25}
|
||||
:account-props {:full-name "M L"
|
||||
:status-indicator? false
|
||||
:size :small
|
||||
:customization-color :blue
|
||||
:name "Mark Libot"
|
||||
:address "0x0ah...78b"
|
||||
:status-account (merge status-account-props {:size 16})}}])
|
||||
(h/render-with-theme-provider [summary-info/view
|
||||
{:type :user
|
||||
:networks? true
|
||||
:values {:ethereum 150
|
||||
:optimism 50
|
||||
:arbitrum 25}
|
||||
:account-props {:full-name "M L"
|
||||
:status-indicator? false
|
||||
:size :small
|
||||
:customization-color :blue
|
||||
:name "Mark Libot"
|
||||
:address "0x0ah...78b"
|
||||
:status-account (merge status-account-props
|
||||
{:size 16})}}])
|
||||
(h/is-truthy (h/get-by-text "Mark Libot"))
|
||||
(h/is-truthy (h/get-by-text "Collectibles vault")))
|
||||
|
||||
(h/test "Networks true render"
|
||||
(h/render [summary-info/view
|
||||
{:type :status-account
|
||||
:networks? true
|
||||
:values {:ethereum 150
|
||||
:optimism 50
|
||||
:arbitrum 25}
|
||||
:account-props status-account-props}])
|
||||
(h/render-with-theme-provider [summary-info/view
|
||||
{:type :status-account
|
||||
:networks? true
|
||||
:values {:ethereum 150
|
||||
:optimism 50
|
||||
:arbitrum 25}
|
||||
:account-props status-account-props}])
|
||||
(h/is-truthy (h/get-by-label-text :networks)))
|
||||
|
||||
(h/test "Networks false render"
|
||||
(h/render [summary-info/view
|
||||
{:type :status-account
|
||||
:networks? false
|
||||
:values {:ethereum 150
|
||||
:optimism 50
|
||||
:arbitrum 25}
|
||||
:account-props status-account-props}])
|
||||
(h/render-with-theme-provider [summary-info/view
|
||||
{:type :status-account
|
||||
:networks? false
|
||||
:values {:ethereum 150
|
||||
:optimism 50
|
||||
:arbitrum 25}
|
||||
:account-props status-account-props}])
|
||||
(h/is-null (h/query-by-label-text :networks))))
|
||||
|
|
|
@ -8,7 +8,8 @@
|
|||
[quo.foundations.colors :as colors]
|
||||
[quo.foundations.resources :as resources]
|
||||
[quo.theme :as quo.theme]
|
||||
[react-native.core :as rn]))
|
||||
[react-native.core :as rn]
|
||||
[schema.core :as schema]))
|
||||
|
||||
(defn- network-amount
|
||||
[{:keys [network amount divider? theme]}]
|
||||
|
@ -51,6 +52,18 @@
|
|||
:amount (str (:amount arbitrum) " " (or (:token-symbol arbitrum) "ARB"))
|
||||
:theme theme}])]))
|
||||
|
||||
(def ?schema
|
||||
[:=>
|
||||
[:catn
|
||||
[:props
|
||||
[:map
|
||||
[:theme :schema.common/theme]
|
||||
[:type [:enum :status-account :saved-account :account :user]]
|
||||
[:account-props {:optional true} [:maybe :map]]
|
||||
[:networks? {:optional true} [:maybe :boolean]]
|
||||
[:values {:optional true} [:maybe :map]]]]]
|
||||
:any])
|
||||
|
||||
(defn- view-internal
|
||||
[{:keys [theme type account-props networks? values]}]
|
||||
[rn/view
|
||||
|
@ -91,4 +104,6 @@
|
|||
{:style (style/line-divider theme)}]
|
||||
[networks values theme]])])
|
||||
|
||||
(def view (quo.theme/with-theme view-internal))
|
||||
(def view
|
||||
(quo.theme/with-theme
|
||||
(schema/instrument #'view-internal ?schema)))
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
(:require [quo.core :as quo]
|
||||
[test-helpers.component :as h]))
|
||||
|
||||
(def ^:private theme :light)
|
||||
|
||||
(defn- get-test-data
|
||||
[{:keys [state network]
|
||||
:or {state :pending network :mainnet}}]
|
||||
|
@ -31,195 +29,206 @@
|
|||
|
||||
(h/describe "Transaction Progress"
|
||||
(h/test "component renders without props"
|
||||
(h/render-with-theme-provider [quo/transaction-progress] theme)
|
||||
(h/render-with-theme-provider
|
||||
[quo/transaction-progress])
|
||||
(h/is-truthy (h/get-by-label-text :transaction-progress)))
|
||||
|
||||
(h/test "component renders when state is pending and network is mainnet"
|
||||
(h/render-with-theme-provider [quo/transaction-progress
|
||||
(get-test-data {:network :optimism-arbitrum})]
|
||||
theme)
|
||||
(h/render-with-theme-provider
|
||||
[quo/transaction-progress (get-test-data {:network :optimism-arbitrum})])
|
||||
(h/is-truthy (h/get-by-label-text :transaction-progress)))
|
||||
|
||||
(h/test "component renders when state is sending and network is optimism-arbitrum"
|
||||
(h/render-with-theme-provider [quo/transaction-progress
|
||||
(get-test-data {:state :sending
|
||||
:network :optimism-arbitrum})]
|
||||
theme)
|
||||
(h/render-with-theme-provider
|
||||
[quo/transaction-progress
|
||||
(get-test-data {:state :sending
|
||||
:network :optimism-arbitrum})])
|
||||
(h/is-truthy (h/get-by-label-text :transaction-progress)))
|
||||
|
||||
(h/test "component renders when state is confirmed and network is optimism-arbitrum"
|
||||
(h/render-with-theme-provider [quo/transaction-progress
|
||||
(get-test-data {:state :confirmed
|
||||
:network :optimism-arbitrum})]
|
||||
theme)
|
||||
(h/render-with-theme-provider
|
||||
[quo/transaction-progress
|
||||
(get-test-data {:state :confirmed
|
||||
:network :optimism-arbitrum})])
|
||||
(h/is-truthy (h/get-by-label-text :transaction-progress)))
|
||||
|
||||
(h/test "component renders when state is finalising and network is optimism-arbitrum"
|
||||
(h/render-with-theme-provider [quo/transaction-progress
|
||||
(get-test-data {:state :finalising
|
||||
:network :optimism-arbitrum})]
|
||||
theme)
|
||||
(h/render-with-theme-provider
|
||||
[quo/transaction-progress
|
||||
(get-test-data {:state :finalising
|
||||
:network :optimism-arbitrum})])
|
||||
(h/is-truthy (h/get-by-label-text :transaction-progress)))
|
||||
|
||||
(h/test "component renders when state is finalized and network is optimism-arbitrum"
|
||||
(h/render-with-theme-provider [quo/transaction-progress
|
||||
(get-test-data {:state :finalized
|
||||
:network :optimism-arbitrum})]
|
||||
theme)
|
||||
(h/render-with-theme-provider
|
||||
[quo/transaction-progress
|
||||
(get-test-data {:state :finalized
|
||||
:network :optimism-arbitrum})])
|
||||
(h/is-truthy (h/get-by-label-text :transaction-progress)))
|
||||
|
||||
(h/test "component renders when state is error and network is optimism-arbitrum"
|
||||
(h/render-with-theme-provider [quo/transaction-progress
|
||||
(get-test-data {:state :error
|
||||
:network :optimism-arbitrum})]
|
||||
theme)
|
||||
(h/render-with-theme-provider
|
||||
[quo/transaction-progress
|
||||
(get-test-data {:state :error
|
||||
:network :optimism-arbitrum})])
|
||||
(h/is-truthy (h/get-by-label-text :transaction-progress)))
|
||||
|
||||
(h/test "component renders when state is sending and network is optimism"
|
||||
(h/render-with-theme-provider [quo/transaction-progress
|
||||
(get-test-data {:state :sending
|
||||
:network :optimism})]
|
||||
theme)
|
||||
(h/render-with-theme-provider
|
||||
[quo/transaction-progress
|
||||
(get-test-data {:state :sending
|
||||
:network :optimism})])
|
||||
(h/is-truthy (h/get-by-label-text :transaction-progress)))
|
||||
|
||||
(h/test "component renders when state is confirmed and network is optimism"
|
||||
(h/render-with-theme-provider [quo/transaction-progress
|
||||
(get-test-data {:state :confirmed
|
||||
:network :optimism})]
|
||||
theme)
|
||||
(h/render-with-theme-provider
|
||||
[quo/transaction-progress
|
||||
(get-test-data {:state :confirmed
|
||||
:network :optimism})])
|
||||
(h/is-truthy (h/get-by-label-text :transaction-progress)))
|
||||
|
||||
(h/test "component renders when state is finalising and network is optimism"
|
||||
(h/render-with-theme-provider [quo/transaction-progress
|
||||
(get-test-data {:state :finalising
|
||||
:network :optimism})]
|
||||
theme)
|
||||
(h/render-with-theme-provider
|
||||
[quo/transaction-progress
|
||||
(get-test-data {:state :finalising
|
||||
:network :optimism})])
|
||||
(h/is-truthy (h/get-by-label-text :transaction-progress)))
|
||||
|
||||
(h/test "component renders when state is finalized and network is optimism"
|
||||
(h/render-with-theme-provider [quo/transaction-progress
|
||||
(get-test-data {:state :finalized
|
||||
:network :optimism})]
|
||||
theme)
|
||||
(h/render-with-theme-provider
|
||||
[quo/transaction-progress
|
||||
(get-test-data {:state :finalized
|
||||
:network :optimism})])
|
||||
(h/is-truthy (h/get-by-label-text :transaction-progress)))
|
||||
|
||||
(h/test "component renders when state is error and network is optimism"
|
||||
(h/render-with-theme-provider [quo/transaction-progress
|
||||
(get-test-data {:state :error
|
||||
:network :optimism})]
|
||||
theme)
|
||||
(h/render-with-theme-provider
|
||||
[quo/transaction-progress
|
||||
(get-test-data {:state :error
|
||||
:network :optimism})])
|
||||
(h/is-truthy (h/get-by-label-text :transaction-progress)))
|
||||
|
||||
(h/test "component renders when state is sending and network is arbitrum"
|
||||
(h/render-with-theme-provider [quo/transaction-progress
|
||||
(get-test-data {:state :sending
|
||||
:network :arbitrum})]
|
||||
theme)
|
||||
(h/render-with-theme-provider
|
||||
[quo/transaction-progress
|
||||
(get-test-data {:state :sending
|
||||
:network :arbitrum})])
|
||||
(h/is-truthy (h/get-by-label-text :transaction-progress)))
|
||||
|
||||
(h/test "component renders when state is confirmed and network is arbitrum"
|
||||
(h/render-with-theme-provider [quo/transaction-progress
|
||||
(get-test-data {:state :confirmed
|
||||
:network :arbitrum})]
|
||||
theme)
|
||||
(h/render-with-theme-provider
|
||||
[quo/transaction-progress
|
||||
(get-test-data {:state :confirmed
|
||||
:network :arbitrum})])
|
||||
(h/is-truthy (h/get-by-label-text :transaction-progress)))
|
||||
|
||||
(h/test "component renders when state is finalising and network is arbitrum"
|
||||
(h/render-with-theme-provider [quo/transaction-progress
|
||||
(get-test-data {:state :finalising
|
||||
:network :arbitrum})]
|
||||
theme)
|
||||
(h/render-with-theme-provider
|
||||
[quo/transaction-progress
|
||||
(get-test-data {:state :finalising
|
||||
:network :arbitrum})])
|
||||
(h/is-truthy (h/get-by-label-text :transaction-progress)))
|
||||
|
||||
(h/test "component renders when state is finalized and network is arbitrum"
|
||||
(h/render-with-theme-provider [quo/transaction-progress
|
||||
(get-test-data {:state :finalized
|
||||
:network :arbitrum})]
|
||||
theme)
|
||||
(h/render-with-theme-provider
|
||||
[quo/transaction-progress
|
||||
(get-test-data {:state :finalized
|
||||
:network :arbitrum})])
|
||||
(h/is-truthy (h/get-by-label-text :transaction-progress)))
|
||||
|
||||
(h/test "component renders when state is error and network is arbitrum"
|
||||
(h/render-with-theme-provider [quo/transaction-progress
|
||||
(get-test-data {:state :error
|
||||
:network :arbitrum})]
|
||||
theme)
|
||||
(h/render-with-theme-provider
|
||||
[quo/transaction-progress
|
||||
(get-test-data {:state :error
|
||||
:network :arbitrum})])
|
||||
(h/is-truthy (h/get-by-label-text :transaction-progress)))
|
||||
|
||||
(h/test "component renders when state is pending and network is mainnet"
|
||||
(h/render-with-theme-provider [quo/transaction-progress (get-test-data {})] theme)
|
||||
(h/render-with-theme-provider
|
||||
[quo/transaction-progress (get-test-data {})])
|
||||
(h/is-truthy (h/get-by-label-text :transaction-progress)))
|
||||
|
||||
(h/test "component renders when state is sending and network is mainnet"
|
||||
(h/render-with-theme-provider [quo/transaction-progress (get-test-data {:state :sending})] theme)
|
||||
(h/render-with-theme-provider
|
||||
[quo/transaction-progress (get-test-data {:state :sending})])
|
||||
(h/is-truthy (h/get-by-label-text :transaction-progress)))
|
||||
|
||||
(h/test "component renders when state is confirmed and network is mainnet"
|
||||
(h/render-with-theme-provider [quo/transaction-progress (get-test-data {:state :confirmed})] theme)
|
||||
(h/render-with-theme-provider
|
||||
[quo/transaction-progress (get-test-data {:state :confirmed})])
|
||||
(h/is-truthy (h/get-by-label-text :transaction-progress)))
|
||||
|
||||
(h/test "component renders when state is finalising and network is mainnet"
|
||||
(h/render-with-theme-provider [quo/transaction-progress (get-test-data {:state :finalising})] theme)
|
||||
(h/render-with-theme-provider
|
||||
[quo/transaction-progress (get-test-data {:state :finalising})])
|
||||
(h/is-truthy (h/get-by-label-text :transaction-progress)))
|
||||
|
||||
(h/test "component renders when state is finalized and network is mainnet"
|
||||
(h/render-with-theme-provider [quo/transaction-progress (get-test-data {:state :finalized})] theme)
|
||||
(h/render-with-theme-provider
|
||||
[quo/transaction-progress (get-test-data {:state :finalized})])
|
||||
(h/is-truthy (h/get-by-label-text :transaction-progress)))
|
||||
|
||||
(h/test "component renders when state is error and network is mainnet"
|
||||
(h/render-with-theme-provider [quo/transaction-progress (get-test-data {:state :error})] theme)
|
||||
(h/render-with-theme-provider
|
||||
[quo/transaction-progress (get-test-data {:state :error})])
|
||||
(h/is-truthy (h/get-by-label-text :transaction-progress)))
|
||||
|
||||
(h/test "mainnet progress box is visible network is mainnet"
|
||||
(h/render-with-theme-provider [quo/transaction-progress (get-test-data {})] theme)
|
||||
(h/render-with-theme-provider
|
||||
[quo/transaction-progress (get-test-data {})])
|
||||
(h/is-truthy (h/get-by-label-text :mainnet-progress-box)))
|
||||
|
||||
(h/test "arbitrum-optimism progress box is visible network is optimism-arbitrum"
|
||||
(h/render-with-theme-provider [quo/transaction-progress
|
||||
(get-test-data {:network :optimism-arbitrum})]
|
||||
theme)
|
||||
(h/render-with-theme-provider
|
||||
[quo/transaction-progress (get-test-data {:network :optimism-arbitrum})])
|
||||
(h/is-truthy (h/get-all-by-label-text :progress-box)))
|
||||
|
||||
(h/test "arbitrum progress box is visible network is arbitrum"
|
||||
(h/render-with-theme-provider [quo/transaction-progress (get-test-data {:network :arbitrum})] theme)
|
||||
(h/render-with-theme-provider
|
||||
[quo/transaction-progress (get-test-data {:network :arbitrum})])
|
||||
(h/is-truthy (h/get-all-by-label-text :progress-box)))
|
||||
|
||||
(h/test "optimism progress box is visible network is optimism"
|
||||
(h/render-with-theme-provider [quo/transaction-progress (get-test-data {:network :optimism})] theme)
|
||||
(h/render-with-theme-provider
|
||||
[quo/transaction-progress (get-test-data {:network :optimism})])
|
||||
(h/is-truthy (h/get-all-by-label-text :progress-box)))
|
||||
|
||||
(h/test "title is visible network is optimism-arbitrum"
|
||||
(h/render-with-theme-provider [quo/transaction-progress
|
||||
(get-test-data {:network :optimism-arbitrum})]
|
||||
theme)
|
||||
(h/render-with-theme-provider
|
||||
[quo/transaction-progress (get-test-data {:network :optimism-arbitrum})])
|
||||
(h/is-truthy (h/get-by-text "Title")))
|
||||
|
||||
(h/test "title is visible network is mainnet"
|
||||
(h/render-with-theme-provider [quo/transaction-progress (get-test-data {})] theme)
|
||||
(h/render-with-theme-provider
|
||||
[quo/transaction-progress (get-test-data {})])
|
||||
(h/is-truthy (h/get-by-text "Title")))
|
||||
|
||||
(h/test "title is visible network is optimism"
|
||||
(h/render-with-theme-provider [quo/transaction-progress (get-test-data {:network :optimism})] theme)
|
||||
(h/render-with-theme-provider
|
||||
[quo/transaction-progress (get-test-data {:network :optimism})])
|
||||
(h/is-truthy (h/get-by-text "Title")))
|
||||
|
||||
(h/test "title is visible network is arbitrum"
|
||||
(h/render-with-theme-provider [quo/transaction-progress (get-test-data {:network :arbitrum})] theme)
|
||||
(h/render-with-theme-provider
|
||||
[quo/transaction-progress (get-test-data {:network :arbitrum})])
|
||||
(h/is-truthy (h/get-by-text "Title")))
|
||||
|
||||
(h/test "context tag is visible network is optimism-arbitrum"
|
||||
(h/render-with-theme-provider [quo/transaction-progress
|
||||
(get-test-data {:network :optimism-arbitrum})]
|
||||
theme)
|
||||
(h/render-with-theme-provider
|
||||
[quo/transaction-progress (get-test-data {:network :optimism-arbitrum})])
|
||||
(h/is-truthy (h/get-by-label-text :context-tag)))
|
||||
|
||||
(h/test "context tag is visible network is mainnet"
|
||||
(h/render-with-theme-provider [quo/transaction-progress (get-test-data {})] theme)
|
||||
(h/render-with-theme-provider
|
||||
[quo/transaction-progress (get-test-data {})])
|
||||
(h/is-truthy (h/get-by-label-text :context-tag)))
|
||||
|
||||
(h/test "context tag is visible network is optimism"
|
||||
(h/render-with-theme-provider [quo/transaction-progress (get-test-data {:network :optimism})] theme)
|
||||
(h/render-with-theme-provider
|
||||
[quo/transaction-progress (get-test-data {:network :optimism})])
|
||||
(h/is-truthy (h/get-by-label-text :context-tag)))
|
||||
|
||||
(h/test "context tag is visible network is optimism"
|
||||
(h/render-with-theme-provider [quo/transaction-progress (get-test-data {:network :arbitrum})] theme)
|
||||
(h/is-truthy (h/get-by-label-text :context-tag)))
|
||||
)
|
||||
(h/render-with-theme-provider
|
||||
[quo/transaction-progress (get-test-data {:network :arbitrum})])
|
||||
(h/is-truthy (h/get-by-label-text :context-tag))))
|
||||
|
|
|
@ -53,8 +53,10 @@
|
|||
(rtl/render (reagent/as-element component)))
|
||||
|
||||
(defn render-with-theme-provider
|
||||
[component theme]
|
||||
(rtl/render (reagent/as-element [quo.theme/provider {:theme theme} component])))
|
||||
([component]
|
||||
(render-with-theme-provider component :light))
|
||||
([component theme]
|
||||
(rtl/render (reagent/as-element [quo.theme/provider {:theme theme} component]))))
|
||||
|
||||
(def unmount
|
||||
"Unmount rendered component.
|
||||
|
|
Loading…
Reference in New Issue