Skip to content

Commit

Permalink
Fix component tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ibrkhalil committed May 3, 2024
1 parent 5bde748 commit d55e54c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@
(fn []
(h/setup-subs
{:wallet/scanned-address nil
:wallet/lowercased-addresses #{"0x12E838Ae1f769147b12956485dc56e57138f3AC8"
"0x22E838Ae1f769147b12956485dc56e57138f3AC8"}
:wallet/lowercased-addresses #{"0x12e838ae1f769147b12956485dc56e57138f3ac8"
"0x22e838ae1f769147b12956485dc56e57138f3ac8"}
:alert-banners/top-margin 0
:wallet/watch-address-activity-state nil
:profile/customization-color :blue
:get-screen-params {:title :t/add-address-to-watch
:wallet/currently-added-address {:title :t/add-address-to-watch
:description :t/enter-eth
:input-title :t/eth-or-ens
:confirm-screen
:screen/wallet.confirm-address
:screen :screen/wallet.add-address
:confirm-screen :screen/wallet.confirm-address
:ens? false
:confirm-screen-props
{:button-label :t/add-watched-address
:address-type :t/watched-address
:placeholder
:t/default-watched-address-placeholder}
:placeholder :t/default-watched-address-placeholder}
:adding-address-purpose :watch}})))

(h/test "validation messages show for already used addressed"
(h/render [add-address-to-watch/view])
(h/render-with-theme-provider [add-address-to-watch/view] :dark)
(h/is-falsy (h/query-by-label-text :error-message))
(h/fire-event :change-text
(h/get-by-label-text :add-address-to-watch)
Expand All @@ -39,7 +39,7 @@
(h/is-truthy (h/get-by-translation-text :t/address-already-in-use))))))

(h/test "validation messages show for invalid address"
(h/render [add-address-to-watch/view])
(h/render-with-theme-provider [add-address-to-watch/view] :dark)
(h/is-falsy (h/query-by-label-text :error-message))
(h/fire-event :change-text (h/get-by-label-text :add-address-to-watch) "0x12E838Ae1f769147b")
(-> (h/wait-for #(h/get-by-translation-text :t/invalid-address))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,20 @@
(h/setup-restorable-re-frame)

(h/test "Create Account button is disabled while no account name exists"
(h/setup-subs {:wallet/watch-only-accounts []
:get-screen-params {:address "0xmock-address"
:title :t/add-address-to-watch
:description :t/enter-eth
:input-title :t/eth-or-ens
:confirm-screen :screen/wallet.confirm-address
:confirm-screen-props
{:button-label :t/add-watched-address
:address-type :t/watched-address
:placeholder
:t/default-watched-address-placeholder}
:adding-address-purpose :watch}})
(h/render [confirm-address/view])
(h/setup-subs {:wallet/watch-only-accounts []
:alert-banners/top-margin 0
:wallet/currently-added-address {:address "0xmock-address"
:title :t/add-address-to-watch
:description :t/enter-eth
:ens? false
:input-title :t/eth-or-ens
:screen :screen/wallet.add-address
:confirm-screen :screen/wallet.confirm-address
:confirm-screen-props
{:button-label :t/add-watched-address
:address-type :t/watched-address
:placeholder :t/default-watched-address-placeholder}
:adding-address-purpose :watch}})
(h/render-with-theme-provider [confirm-address/view] :dark)
(h/is-truthy (h/get-by-text "0xmock-address"))
(h/is-disabled (h/get-by-label-text :confirm-button-label))))
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@
{:keys [placeholder
address-type
button-label]} :confirm-screen-props} (rf/sub [:wallet/currently-added-address])
placeholder (when placeholder
(i18n/label placeholder))
placeholder (i18n/label placeholder)
[account-name on-change-name] (rn/use-state "")
[account-color on-change-color] (rn/use-state (rand-nth colors/account-colors))
[account-emoji on-change-emoji] (rn/use-state (emoji-picker.utils/random-emoji))]
Expand All @@ -77,7 +76,7 @@
:on-change-emoji on-change-emoji
:watch-only? true
:top-left-icon :i/arrow-left
:bottom-action-label (or button-label :t/account-created)
:bottom-action-label button-label
:bottom-action-props {:customization-color account-color
:disabled? (string/blank? account-name)
:accessibility-label :confirm-button-label
Expand All @@ -94,8 +93,7 @@
:right-icon :i/advanced
:icon-right? true
:emoji account-emoji
:title (when address-type
(i18n/label address-type))
:title (i18n/label address-type)
:subtitle address
:status :default
:size :default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,7 @@
(i18n/label :t/continue)]}
[quo/page-top
{:container-style style/header-container
:title (when title
(i18n/label title))
:title (i18n/label title)
:description :text
:description-text (when description
(i18n/label description))}]
Expand Down

0 comments on commit d55e54c

Please sign in to comment.