🚟 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:
Shivek Khurana 2024-02-12 14:44:40 +00:00 committed by GitHub
parent 6669c33e33
commit abe0342be0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 339 additions and 242 deletions

View File

@ -2,7 +2,6 @@
(:require [quo.core :as quo] (:require [quo.core :as quo]
[test-helpers.component :as h])) [test-helpers.component :as h]))
(def ^:private theme :light)
(defn- get-test-data (defn- get-test-data
[{:keys [state network] [{:keys [state network]
@ -18,94 +17,99 @@
(h/test "component renders when state is sending and network is optimism" (h/test "component renders when state is sending and network is optimism"
(h/render-with-theme-provider [quo/confirmation-propgress (h/render-with-theme-provider [quo/confirmation-propgress
(get-test-data {:state :sending (get-test-data {:state :sending
:network :optimism})] :network :optimism})])
theme) (h/is-truthy (h/get-by-label-text :progress-box))))
(h/is-truthy (h/get-by-label-text :progress-box)))
(h/test "component renders when state is confirmed and network is optimism" (h/test "component renders when state is confirmed and network is optimism"
(h/render-with-theme-provider [quo/confirmation-propgress (h/render-with-theme-provider
[quo/confirmation-propgress
(get-test-data {:state :confirmed (get-test-data {:state :confirmed
:network :optimism})] :network :optimism})])
theme)
(h/is-truthy (h/get-by-label-text :progress-box))) (h/is-truthy (h/get-by-label-text :progress-box)))
(h/test "component renders when state is finalising and network is optimism" (h/test "component renders when state is finalising and network is optimism"
(h/render-with-theme-provider [quo/confirmation-propgress (h/render-with-theme-provider
[quo/confirmation-propgress
(get-test-data {:state :finalising (get-test-data {:state :finalising
:network :optimism})] :network :optimism})])
theme)
(h/is-truthy (h/get-by-label-text :progress-box))) (h/is-truthy (h/get-by-label-text :progress-box)))
(h/test "component renders when state is finalized and network is optimism" (h/test "component renders when state is finalized and network is optimism"
(h/render-with-theme-provider [quo/confirmation-propgress (h/render-with-theme-provider
[quo/confirmation-propgress
(get-test-data {:state :finalized (get-test-data {:state :finalized
:network :optimism})] :network :optimism})])
theme)
(h/is-truthy (h/get-by-label-text :progress-box))) (h/is-truthy (h/get-by-label-text :progress-box)))
(h/test "component renders when state is error and network is optimism" (h/test "component renders when state is error and network is optimism"
(h/render-with-theme-provider [quo/confirmation-propgress (h/render-with-theme-provider
[quo/confirmation-propgress
(get-test-data {:state :error (get-test-data {:state :error
:network :optimism})] :network :optimism})])
theme)
(h/is-truthy (h/get-by-label-text :progress-box))) (h/is-truthy (h/get-by-label-text :progress-box)))
(h/test "component renders when state is sending and network is arbitrum" (h/test "component renders when state is sending and network is arbitrum"
(h/render-with-theme-provider [quo/confirmation-propgress (h/render-with-theme-provider
[quo/confirmation-propgress
(get-test-data {:state :sending (get-test-data {:state :sending
:network :arbitrum})] :network :arbitrum})])
theme)
(h/is-truthy (h/get-by-label-text :progress-box))) (h/is-truthy (h/get-by-label-text :progress-box)))
(h/test "component renders when state is confirmed and network is arbitrum" (h/test "component renders when state is confirmed and network is arbitrum"
(h/render-with-theme-provider [quo/confirmation-propgress (h/render-with-theme-provider
[quo/confirmation-propgress
(get-test-data {:state :confirmed (get-test-data {:state :confirmed
:network :arbitrum})] :network :arbitrum})])
theme)
(h/is-truthy (h/get-by-label-text :progress-box))) (h/is-truthy (h/get-by-label-text :progress-box)))
(h/test "component renders when state is finalising and network is arbitrum" (h/test "component renders when state is finalising and network is arbitrum"
(h/render-with-theme-provider [quo/confirmation-propgress (h/render-with-theme-provider
[quo/confirmation-propgress
(get-test-data {:state :finalising (get-test-data {:state :finalising
:network :arbitrum})] :network :arbitrum})])
theme)
(h/is-truthy (h/get-by-label-text :progress-box))) (h/is-truthy (h/get-by-label-text :progress-box)))
(h/test "component renders when state is finalized and network is arbitrum" (h/test "component renders when state is finalized and network is arbitrum"
(h/render-with-theme-provider [quo/confirmation-propgress (h/render-with-theme-provider
[quo/confirmation-propgress
(get-test-data {:state :finalized (get-test-data {:state :finalized
:network :arbitrum})] :network :arbitrum})])
theme)
(h/is-truthy (h/get-by-label-text :progress-box))) (h/is-truthy (h/get-by-label-text :progress-box)))
(h/test "component renders when state is error and network is arbitrum" (h/test "component renders when state is error and network is arbitrum"
(h/render-with-theme-provider [quo/confirmation-propgress (h/render-with-theme-provider
[quo/confirmation-propgress
(get-test-data {:state :error (get-test-data {:state :error
:network :arbitrum})] :network :arbitrum})])
theme)
(h/is-truthy (h/get-by-label-text :progress-box))) (h/is-truthy (h/get-by-label-text :progress-box)))
(h/test "component renders when state is pending and network is mainnet" (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/render-with-theme-provider
[quo/confirmation-propgress (get-test-data {})])
(h/is-truthy (h/get-by-label-text :mainnet-progress-box))) (h/is-truthy (h/get-by-label-text :mainnet-progress-box)))
(h/test "component renders when state is sending and network is mainnet" (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/render-with-theme-provider
[quo/confirmation-propgress (get-test-data {:state :sending})])
(h/is-truthy (h/get-by-label-text :mainnet-progress-box))) (h/is-truthy (h/get-by-label-text :mainnet-progress-box)))
(h/test "component renders when state is confirmed and network is mainnet" (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/render-with-theme-provider
[quo/confirmation-propgress (get-test-data {:state :confirmed})])
(h/is-truthy (h/get-by-label-text :mainnet-progress-box))) (h/is-truthy (h/get-by-label-text :mainnet-progress-box)))
(h/test "component renders when state is finalising and network is mainnet" (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/render-with-theme-provider
theme) [quo/confirmation-propgress (get-test-data {:state :finalising})])
(h/is-truthy (h/get-by-label-text :mainnet-progress-box))) (h/is-truthy (h/get-by-label-text :mainnet-progress-box)))
(h/test "component renders when state is finalized and network is mainnet" (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/render-with-theme-provider
[quo/confirmation-propgress (get-test-data {:state :finalized})])
(h/is-truthy (h/get-by-label-text :mainnet-progress-box))) (h/is-truthy (h/get-by-label-text :mainnet-progress-box)))
(h/test "component renders when state is error and network is mainnet" (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/render-with-theme-provider
(h/is-truthy (h/get-by-label-text :mainnet-progress-box)))) [quo/confirmation-propgress
(get-test-data {:state :error})])
(h/is-truthy (h/get-by-label-text :mainnet-progress-box)))

View File

@ -5,7 +5,8 @@
(h/describe "Wallet: Network Amount" (h/describe "Wallet: Network Amount"
(h/test "Amount renders" (h/test "Amount renders"
(h/render [network-amount/view (h/render-with-theme-provider
[network-amount/view
{:amount "5.123" {:amount "5.123"
:token :eth}]) :token :eth}])
(h/is-truthy (h/get-by-text "5.123 ETH")))) (h/is-truthy (h/get-by-text "5.123 ETH"))))

View File

@ -5,7 +5,18 @@
[quo.components.utilities.token.view :as token] [quo.components.utilities.token.view :as token]
[quo.components.wallet.network-amount.style :as style] [quo.components.wallet.network-amount.style :as style]
[quo.theme :as quo.theme] [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 (defn- view-internal
[{:keys [amount token theme]}] [{:keys [amount token theme]}]
@ -19,4 +30,4 @@
[rn/view [rn/view
{:style (style/divider theme)}]]) {:style (style/divider theme)}]])
(def view (quo.theme/with-theme view-internal)) (def view (quo.theme/with-theme (schema/instrument #'view-internal ?schema)))

View File

@ -4,36 +4,36 @@
[test-helpers.component :as h])) [test-helpers.component :as h]))
(h/describe "Wallet: Network Bridge" (h/describe "Wallet: Network Bridge"
(h/test "Amount renders" (h/test "Amount render-with-theme-providers"
(h/render [network-bridge/view (h/render-with-theme-provider [network-bridge/view
{:amount "50 SNT" {:amount "50 SNT"
:network :ethereum :network :ethereum
:status :default}]) :status :default}])
(h/is-truthy (h/get-by-text "50 SNT"))) (h/is-truthy (h/get-by-text "50 SNT")))
(h/test "Network label renders" (h/test "Network label render"
(h/render [network-bridge/view (h/render-with-theme-provider [network-bridge/view
{:amount "50 SNT" {:amount "50 SNT"
:network :optimism :network :optimism
:status :default}]) :status :default}])
(h/is-truthy (h/get-by-text "Optimism"))) (h/is-truthy (h/get-by-text "Optimism")))
(h/test "Locked state" (h/test "Locked state"
(h/render [network-bridge/view (h/render-with-theme-provider [network-bridge/view
{:amount "50 SNT" {:amount "50 SNT"
:network :optimism :network :optimism
:status :locked}]) :status :locked}])
(h/is-truthy (h/get-by-label-text :lock))) (h/is-truthy (h/get-by-label-text :lock)))
(h/test "Loading state" (h/test "Loading state"
(h/render [network-bridge/view (h/render-with-theme-provider [network-bridge/view
{:amount "50 SNT" {:amount "50 SNT"
:network :optimism :network :optimism
:status :loading}]) :status :loading}])
(h/is-truthy (h/get-by-label-text :loading))) (h/is-truthy (h/get-by-label-text :loading)))
(h/test "Disabled state" (h/test "Disabled state"
(h/render [network-bridge/view (h/render-with-theme-provider [network-bridge/view
{:amount "50 SNT" {:amount "50 SNT"
:network :optimism :network :optimism
:status :disabled}]) :status :disabled}])

View File

@ -7,7 +7,8 @@
[quo.foundations.colors :as colors] [quo.foundations.colors :as colors]
[quo.foundations.resources :as resources] [quo.foundations.resources :as resources]
[quo.theme :as quo.theme] [quo.theme :as quo.theme]
[react-native.core :as rn])) [react-native.core :as rn]
[schema.core :as schema]))
(defn network-bridge-add (defn network-bridge-add
[{:keys [network state theme container-style on-press]}] [{:keys [network state theme container-style on-press]}]
@ -24,6 +25,22 @@
(= network :ethereum) "Mainnet" (= network :ethereum) "Mainnet"
:else (string/capitalize (name network)))) :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 (defn view-internal
[{:keys [theme network status amount container-style on-press] :as args}] [{:keys [theme network status amount container-style on-press] :as args}]
(if (= status :add) (if (= status :add)
@ -62,4 +79,6 @@
:style {:color (colors/theme-colors colors/neutral-50 colors/neutral-40 theme)}} :style {:color (colors/theme-colors colors/neutral-50 colors/neutral-40 theme)}}
(network->text network)]]])) (network->text network)]]]))
(def view (quo.theme/with-theme view-internal)) (def view
(quo.theme/with-theme
(schema/instrument #'view-internal ?schema)))

View File

@ -1,6 +1,7 @@
(ns quo.components.wallet.network-routing.component-spec (ns quo.components.wallet.network-routing.component-spec
(:require [oops.core :as oops] (:require [oops.core :as oops]
[quo.components.wallet.network-routing.view :as network-routing] [quo.components.wallet.network-routing.view :as network-routing]
quo.theme
[reagent.core :as reagent] [reagent.core :as reagent]
[test-helpers.component :as h])) [test-helpers.component :as h]))
@ -11,17 +12,18 @@
:requesting-data? false :requesting-data? false
:on-amount-selected (fn [_new-amount _network-idx] nil)}] :on-amount-selected (fn [_new-amount _network-idx] nil)}]
(h/test "Renders Default" (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/is-truthy (h/get-by-label-text :network-routing)))
(h/test "Renders bars inside" (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 %)) rerender-fn #((oops/oget component "rerender") (reagent/as-element %))
component (h/get-by-label-text :network-routing)] component (h/get-by-label-text :network-routing)]
;; Fires on-layout callback since the total width is required ;; Fires on-layout callback since the total width is required
(h/fire-event :layout component #js {:nativeEvent #js {:layout #js {:width 1000}}}) (h/fire-event :layout component #js {:nativeEvent #js {:layout #js {:width 1000}}})
;; Update props to trigger rerender, otherwise it won't be updated ;; 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 ;; Check number of networks rendered
(->> (js->clj (h/query-all-by-label-text :network-routing-bar)) (->> (js->clj (h/query-all-by-label-text :network-routing-bar))
(count) (count)

View File

@ -8,6 +8,7 @@
[react-native.gesture :as gesture] [react-native.gesture :as gesture]
[react-native.reanimated :as reanimated] [react-native.reanimated :as reanimated]
[reagent.core :as reagent] [reagent.core :as reagent]
[schema.core :as schema]
[utils.number])) [utils.number]))
(def ^:private timeouts (atom {})) (def ^:private timeouts (atom {}))
@ -172,6 +173,22 @@
[rn/view {:style (style/max-limit-bar-background network-name)}] [rn/view {:style (style/max-limit-bar-background network-name)}]
[dashed-line 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 (defn view-internal
[{:keys [networks container-style theme] :as params}] [{:keys [networks container-style theme] :as params}]
(reagent/with-let [total-width (reagent/atom nil)] (reagent/with-let [total-width (reagent/atom nil)]
@ -186,4 +203,6 @@
(doseq [[_ living-timeout] @timeouts] (doseq [[_ living-timeout] @timeouts]
(js/clearTimeout living-timeout))))) (js/clearTimeout living-timeout)))))
(def view (quo.theme/with-theme view-internal)) (def view
(quo.theme/with-theme
(schema/instrument #'view-internal ?schema)))

View File

@ -2,7 +2,19 @@
(:require (:require
[quo.components.wallet.progress-bar.style :as style] [quo.components.wallet.progress-bar.style :as style]
[quo.theme :as quo.theme] [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 (defn- view-internal
[{:keys [full-width?] :as props}] [{:keys [full-width?] :as props}]
@ -12,4 +24,6 @@
(when full-width? (when full-width?
[rn/view {:style (style/progressed-bar props)}])]) [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)))

View File

@ -13,7 +13,7 @@
(h/describe "Wallet: Summary Info" (h/describe "Wallet: Summary Info"
(h/test "Type of `status-account` title renders" (h/test "Type of `status-account` title renders"
(h/render [summary-info/view (h/render-with-theme-provider [summary-info/view
{:type :status-account {:type :status-account
:networks? true :networks? true
:values {:ethereum 150 :values {:ethereum 150
@ -23,7 +23,7 @@
(h/is-truthy (h/get-by-text "Collectibles vault"))) (h/is-truthy (h/get-by-text "Collectibles vault")))
(h/test "Type of `user` title renders" (h/test "Type of `user` title renders"
(h/render [summary-info/view (h/render-with-theme-provider [summary-info/view
{:type :user {:type :user
:networks? true :networks? true
:values {:ethereum 150 :values {:ethereum 150
@ -35,12 +35,13 @@
:customization-color :blue :customization-color :blue
:name "Mark Libot" :name "Mark Libot"
:address "0x0ah...78b" :address "0x0ah...78b"
:status-account (merge status-account-props {:size 16})}}]) :status-account (merge status-account-props
{:size 16})}}])
(h/is-truthy (h/get-by-text "Mark Libot")) (h/is-truthy (h/get-by-text "Mark Libot"))
(h/is-truthy (h/get-by-text "Collectibles vault"))) (h/is-truthy (h/get-by-text "Collectibles vault")))
(h/test "Networks true render" (h/test "Networks true render"
(h/render [summary-info/view (h/render-with-theme-provider [summary-info/view
{:type :status-account {:type :status-account
:networks? true :networks? true
:values {:ethereum 150 :values {:ethereum 150
@ -50,7 +51,7 @@
(h/is-truthy (h/get-by-label-text :networks))) (h/is-truthy (h/get-by-label-text :networks)))
(h/test "Networks false render" (h/test "Networks false render"
(h/render [summary-info/view (h/render-with-theme-provider [summary-info/view
{:type :status-account {:type :status-account
:networks? false :networks? false
:values {:ethereum 150 :values {:ethereum 150

View File

@ -8,7 +8,8 @@
[quo.foundations.colors :as colors] [quo.foundations.colors :as colors]
[quo.foundations.resources :as resources] [quo.foundations.resources :as resources]
[quo.theme :as quo.theme] [quo.theme :as quo.theme]
[react-native.core :as rn])) [react-native.core :as rn]
[schema.core :as schema]))
(defn- network-amount (defn- network-amount
[{:keys [network amount divider? theme]}] [{:keys [network amount divider? theme]}]
@ -51,6 +52,18 @@
:amount (str (:amount arbitrum) " " (or (:token-symbol arbitrum) "ARB")) :amount (str (:amount arbitrum) " " (or (:token-symbol arbitrum) "ARB"))
:theme theme}])])) :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 (defn- view-internal
[{:keys [theme type account-props networks? values]}] [{:keys [theme type account-props networks? values]}]
[rn/view [rn/view
@ -91,4 +104,6 @@
{:style (style/line-divider theme)}] {:style (style/line-divider theme)}]
[networks values theme]])]) [networks values theme]])])
(def view (quo.theme/with-theme view-internal)) (def view
(quo.theme/with-theme
(schema/instrument #'view-internal ?schema)))

View File

@ -2,8 +2,6 @@
(:require [quo.core :as quo] (:require [quo.core :as quo]
[test-helpers.component :as h])) [test-helpers.component :as h]))
(def ^:private theme :light)
(defn- get-test-data (defn- get-test-data
[{:keys [state network] [{:keys [state network]
:or {state :pending network :mainnet}}] :or {state :pending network :mainnet}}]
@ -31,195 +29,206 @@
(h/describe "Transaction Progress" (h/describe "Transaction Progress"
(h/test "component renders without props" (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/is-truthy (h/get-by-label-text :transaction-progress)))
(h/test "component renders when state is pending and network is mainnet" (h/test "component renders when state is pending and network is mainnet"
(h/render-with-theme-provider [quo/transaction-progress (h/render-with-theme-provider
(get-test-data {:network :optimism-arbitrum})] [quo/transaction-progress (get-test-data {:network :optimism-arbitrum})])
theme)
(h/is-truthy (h/get-by-label-text :transaction-progress))) (h/is-truthy (h/get-by-label-text :transaction-progress)))
(h/test "component renders when state is sending and network is optimism-arbitrum" (h/test "component renders when state is sending and network is optimism-arbitrum"
(h/render-with-theme-provider [quo/transaction-progress (h/render-with-theme-provider
[quo/transaction-progress
(get-test-data {:state :sending (get-test-data {:state :sending
:network :optimism-arbitrum})] :network :optimism-arbitrum})])
theme)
(h/is-truthy (h/get-by-label-text :transaction-progress))) (h/is-truthy (h/get-by-label-text :transaction-progress)))
(h/test "component renders when state is confirmed and network is optimism-arbitrum" (h/test "component renders when state is confirmed and network is optimism-arbitrum"
(h/render-with-theme-provider [quo/transaction-progress (h/render-with-theme-provider
[quo/transaction-progress
(get-test-data {:state :confirmed (get-test-data {:state :confirmed
:network :optimism-arbitrum})] :network :optimism-arbitrum})])
theme)
(h/is-truthy (h/get-by-label-text :transaction-progress))) (h/is-truthy (h/get-by-label-text :transaction-progress)))
(h/test "component renders when state is finalising and network is optimism-arbitrum" (h/test "component renders when state is finalising and network is optimism-arbitrum"
(h/render-with-theme-provider [quo/transaction-progress (h/render-with-theme-provider
[quo/transaction-progress
(get-test-data {:state :finalising (get-test-data {:state :finalising
:network :optimism-arbitrum})] :network :optimism-arbitrum})])
theme)
(h/is-truthy (h/get-by-label-text :transaction-progress))) (h/is-truthy (h/get-by-label-text :transaction-progress)))
(h/test "component renders when state is finalized and network is optimism-arbitrum" (h/test "component renders when state is finalized and network is optimism-arbitrum"
(h/render-with-theme-provider [quo/transaction-progress (h/render-with-theme-provider
[quo/transaction-progress
(get-test-data {:state :finalized (get-test-data {:state :finalized
:network :optimism-arbitrum})] :network :optimism-arbitrum})])
theme)
(h/is-truthy (h/get-by-label-text :transaction-progress))) (h/is-truthy (h/get-by-label-text :transaction-progress)))
(h/test "component renders when state is error and network is optimism-arbitrum" (h/test "component renders when state is error and network is optimism-arbitrum"
(h/render-with-theme-provider [quo/transaction-progress (h/render-with-theme-provider
[quo/transaction-progress
(get-test-data {:state :error (get-test-data {:state :error
:network :optimism-arbitrum})] :network :optimism-arbitrum})])
theme)
(h/is-truthy (h/get-by-label-text :transaction-progress))) (h/is-truthy (h/get-by-label-text :transaction-progress)))
(h/test "component renders when state is sending and network is optimism" (h/test "component renders when state is sending and network is optimism"
(h/render-with-theme-provider [quo/transaction-progress (h/render-with-theme-provider
[quo/transaction-progress
(get-test-data {:state :sending (get-test-data {:state :sending
:network :optimism})] :network :optimism})])
theme)
(h/is-truthy (h/get-by-label-text :transaction-progress))) (h/is-truthy (h/get-by-label-text :transaction-progress)))
(h/test "component renders when state is confirmed and network is optimism" (h/test "component renders when state is confirmed and network is optimism"
(h/render-with-theme-provider [quo/transaction-progress (h/render-with-theme-provider
[quo/transaction-progress
(get-test-data {:state :confirmed (get-test-data {:state :confirmed
:network :optimism})] :network :optimism})])
theme)
(h/is-truthy (h/get-by-label-text :transaction-progress))) (h/is-truthy (h/get-by-label-text :transaction-progress)))
(h/test "component renders when state is finalising and network is optimism" (h/test "component renders when state is finalising and network is optimism"
(h/render-with-theme-provider [quo/transaction-progress (h/render-with-theme-provider
[quo/transaction-progress
(get-test-data {:state :finalising (get-test-data {:state :finalising
:network :optimism})] :network :optimism})])
theme)
(h/is-truthy (h/get-by-label-text :transaction-progress))) (h/is-truthy (h/get-by-label-text :transaction-progress)))
(h/test "component renders when state is finalized and network is optimism" (h/test "component renders when state is finalized and network is optimism"
(h/render-with-theme-provider [quo/transaction-progress (h/render-with-theme-provider
[quo/transaction-progress
(get-test-data {:state :finalized (get-test-data {:state :finalized
:network :optimism})] :network :optimism})])
theme)
(h/is-truthy (h/get-by-label-text :transaction-progress))) (h/is-truthy (h/get-by-label-text :transaction-progress)))
(h/test "component renders when state is error and network is optimism" (h/test "component renders when state is error and network is optimism"
(h/render-with-theme-provider [quo/transaction-progress (h/render-with-theme-provider
[quo/transaction-progress
(get-test-data {:state :error (get-test-data {:state :error
:network :optimism})] :network :optimism})])
theme)
(h/is-truthy (h/get-by-label-text :transaction-progress))) (h/is-truthy (h/get-by-label-text :transaction-progress)))
(h/test "component renders when state is sending and network is arbitrum" (h/test "component renders when state is sending and network is arbitrum"
(h/render-with-theme-provider [quo/transaction-progress (h/render-with-theme-provider
[quo/transaction-progress
(get-test-data {:state :sending (get-test-data {:state :sending
:network :arbitrum})] :network :arbitrum})])
theme)
(h/is-truthy (h/get-by-label-text :transaction-progress))) (h/is-truthy (h/get-by-label-text :transaction-progress)))
(h/test "component renders when state is confirmed and network is arbitrum" (h/test "component renders when state is confirmed and network is arbitrum"
(h/render-with-theme-provider [quo/transaction-progress (h/render-with-theme-provider
[quo/transaction-progress
(get-test-data {:state :confirmed (get-test-data {:state :confirmed
:network :arbitrum})] :network :arbitrum})])
theme)
(h/is-truthy (h/get-by-label-text :transaction-progress))) (h/is-truthy (h/get-by-label-text :transaction-progress)))
(h/test "component renders when state is finalising and network is arbitrum" (h/test "component renders when state is finalising and network is arbitrum"
(h/render-with-theme-provider [quo/transaction-progress (h/render-with-theme-provider
[quo/transaction-progress
(get-test-data {:state :finalising (get-test-data {:state :finalising
:network :arbitrum})] :network :arbitrum})])
theme)
(h/is-truthy (h/get-by-label-text :transaction-progress))) (h/is-truthy (h/get-by-label-text :transaction-progress)))
(h/test "component renders when state is finalized and network is arbitrum" (h/test "component renders when state is finalized and network is arbitrum"
(h/render-with-theme-provider [quo/transaction-progress (h/render-with-theme-provider
[quo/transaction-progress
(get-test-data {:state :finalized (get-test-data {:state :finalized
:network :arbitrum})] :network :arbitrum})])
theme)
(h/is-truthy (h/get-by-label-text :transaction-progress))) (h/is-truthy (h/get-by-label-text :transaction-progress)))
(h/test "component renders when state is error and network is arbitrum" (h/test "component renders when state is error and network is arbitrum"
(h/render-with-theme-provider [quo/transaction-progress (h/render-with-theme-provider
[quo/transaction-progress
(get-test-data {:state :error (get-test-data {:state :error
:network :arbitrum})] :network :arbitrum})])
theme)
(h/is-truthy (h/get-by-label-text :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/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/is-truthy (h/get-by-label-text :transaction-progress)))
(h/test "component renders when state is sending and network is mainnet" (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/is-truthy (h/get-by-label-text :transaction-progress)))
(h/test "component renders when state is confirmed and network is mainnet" (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/is-truthy (h/get-by-label-text :transaction-progress)))
(h/test "component renders when state is finalising and network is mainnet" (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/is-truthy (h/get-by-label-text :transaction-progress)))
(h/test "component renders when state is finalized and network is mainnet" (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/is-truthy (h/get-by-label-text :transaction-progress)))
(h/test "component renders when state is error and network is mainnet" (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/is-truthy (h/get-by-label-text :transaction-progress)))
(h/test "mainnet progress box is visible network is mainnet" (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/is-truthy (h/get-by-label-text :mainnet-progress-box)))
(h/test "arbitrum-optimism progress box is visible network is optimism-arbitrum" (h/test "arbitrum-optimism progress box is visible network is optimism-arbitrum"
(h/render-with-theme-provider [quo/transaction-progress (h/render-with-theme-provider
(get-test-data {:network :optimism-arbitrum})] [quo/transaction-progress (get-test-data {:network :optimism-arbitrum})])
theme)
(h/is-truthy (h/get-all-by-label-text :progress-box))) (h/is-truthy (h/get-all-by-label-text :progress-box)))
(h/test "arbitrum progress box is visible network is arbitrum" (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/is-truthy (h/get-all-by-label-text :progress-box)))
(h/test "optimism progress box is visible network is optimism" (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/is-truthy (h/get-all-by-label-text :progress-box)))
(h/test "title is visible network is optimism-arbitrum" (h/test "title is visible network is optimism-arbitrum"
(h/render-with-theme-provider [quo/transaction-progress (h/render-with-theme-provider
(get-test-data {:network :optimism-arbitrum})] [quo/transaction-progress (get-test-data {:network :optimism-arbitrum})])
theme)
(h/is-truthy (h/get-by-text "Title"))) (h/is-truthy (h/get-by-text "Title")))
(h/test "title is visible network is mainnet" (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/is-truthy (h/get-by-text "Title")))
(h/test "title is visible network is optimism" (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/is-truthy (h/get-by-text "Title")))
(h/test "title is visible network is arbitrum" (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/is-truthy (h/get-by-text "Title")))
(h/test "context tag is visible network is optimism-arbitrum" (h/test "context tag is visible network is optimism-arbitrum"
(h/render-with-theme-provider [quo/transaction-progress (h/render-with-theme-provider
(get-test-data {:network :optimism-arbitrum})] [quo/transaction-progress (get-test-data {:network :optimism-arbitrum})])
theme)
(h/is-truthy (h/get-by-label-text :context-tag))) (h/is-truthy (h/get-by-label-text :context-tag)))
(h/test "context tag is visible network is mainnet" (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/is-truthy (h/get-by-label-text :context-tag)))
(h/test "context tag is visible network is optimism" (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/is-truthy (h/get-by-label-text :context-tag)))
(h/test "context tag is visible network is optimism" (h/test "context tag is visible network is optimism"
(h/render-with-theme-provider [quo/transaction-progress (get-test-data {:network :arbitrum})] theme) (h/render-with-theme-provider
(h/is-truthy (h/get-by-label-text :context-tag))) [quo/transaction-progress (get-test-data {:network :arbitrum})])
) (h/is-truthy (h/get-by-label-text :context-tag))))

View File

@ -53,8 +53,10 @@
(rtl/render (reagent/as-element component))) (rtl/render (reagent/as-element component)))
(defn render-with-theme-provider (defn render-with-theme-provider
[component theme] ([component]
(rtl/render (reagent/as-element [quo.theme/provider {:theme theme} component]))) (render-with-theme-provider component :light))
([component theme]
(rtl/render (reagent/as-element [quo.theme/provider {:theme theme} component]))))
(def unmount (def unmount
"Unmount rendered component. "Unmount rendered component.