-
Notifications
You must be signed in to change notification settings - Fork 984
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No ability to enter/paste assets exceeds the users's balance #18526 #18599
Changes from 4 commits
a911fc5
58889ad
cd7832e
3a2ad0d
b81e265
ffe2400
12a975b
b01cb21
cc23a08
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,60 +100,4 @@ | |
(.then (fn [] | ||
(h/is-truthy (h/get-by-label-text :button-one)) | ||
(h/fire-event :press (h/get-by-label-text :button-one)) | ||
(h/was-called on-confirm)))))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why are we deleting all these tests? 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because the tests were covering the input of more than limit which were reset to the limit. Now, when entering more than limit, nothing should happen except for changing the style. |
||
|
||
(h/test "Try to fill more than limit" | ||
(h/setup-subs sub-mocks) | ||
(h/render [input-amount/view | ||
{:crypto-decimals 10 | ||
:limit-crypto 286}]) | ||
|
||
(h/fire-event :press (h/query-by-label-text :keyboard-key-2)) | ||
(h/fire-event :press (h/query-by-label-text :keyboard-key-9)) | ||
(h/fire-event :press (h/query-by-label-text :keyboard-key-5)) | ||
|
||
(-> (h/wait-for #(h/is-truthy (h/get-by-text "$290.00"))) | ||
(.then (fn [] | ||
(h/fire-event :press (h/query-by-label-text :keyboard-key-backspace)) | ||
(h/fire-event :press (h/query-by-label-text :keyboard-key-8)) | ||
(h/fire-event :press (h/query-by-label-text :keyboard-key-5)) | ||
(h/wait-for #(h/get-by-text "$2850.00")))))) | ||
|
||
(h/test "Try to fill more than limit" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this test should still work but the check should be updated 👍 . There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same thing here |
||
(h/setup-subs sub-mocks) | ||
(h/render [input-amount/view | ||
{:crypto-decimals 10 | ||
:limit-crypto 286 | ||
:on-confirm #()}]) | ||
|
||
(h/fire-event :press (h/query-by-label-text :keyboard-key-2)) | ||
(h/fire-event :press (h/query-by-label-text :keyboard-key-9)) | ||
(h/fire-event :press (h/query-by-label-text :keyboard-key-5)) | ||
|
||
(-> (h/wait-for #(h/get-by-text "$290.00")) | ||
(.then (fn [] | ||
(h/fire-event :press (h/query-by-label-text :keyboard-key-backspace)) | ||
(h/fire-event :press (h/query-by-label-text :keyboard-key-8)) | ||
(h/fire-event :press (h/query-by-label-text :keyboard-key-5)) | ||
(h/wait-for #(h/get-by-text "$2850.00")))))) | ||
|
||
(h/test "Switch from crypto to fiat and check limit" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this seems like a valid test case still There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, when the input was more than the limit and a switch was happening, the input was changing to the limit. Now, nothing should happen except for the style changing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
(h/setup-subs sub-mocks) | ||
(h/render [input-amount/view | ||
{:crypto-decimals 2 | ||
:limit-crypto 250 | ||
:on-confirm #()}]) | ||
|
||
(h/fire-event :press (h/query-by-label-text :keyboard-key-2)) | ||
(h/fire-event :press (h/query-by-label-text :keyboard-key-0)) | ||
(-> (h/wait-for #(h/get-by-text "$200.00")) | ||
(.then (fn [] | ||
(h/fire-event :press (h/query-by-label-text :reorder)) | ||
(h/wait-for #(h/get-by-text "2.00 ETH")))) | ||
(.then (fn [] | ||
(h/fire-event :press (h/query-by-label-text :keyboard-key-5)) | ||
(h/fire-event :press (h/query-by-label-text :keyboard-key-5)) | ||
(h/wait-for #(h/get-by-text "20.50 ETH")))) | ||
(.then (fn [] | ||
(h/fire-event :press (h/query-by-label-text :keyboard-key-5)) | ||
(h/wait-for #(h/get-by-text "20.50 ETH"))))))) | ||
(h/was-called on-confirm))))))) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,12 @@ | |
(>= (js/parseFloat balance) input-value))) | ||
(map first))) | ||
|
||
(defn- reset-input-error | ||
[new-value prev-value input-error] | ||
(if (> new-value prev-value) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can be
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
(reset! input-error true) | ||
(reset! input-error false))) | ||
|
||
(defn- f-view-internal | ||
;; crypto-decimals and limit-crypto args are needed for component tests only | ||
[{:keys [crypto-decimals limit-crypto]}] | ||
|
@@ -75,6 +81,7 @@ | |
limit-fiat (.toFixed (* (:total-balance token) conversion-rate) 2) | ||
crypto-decimals (or crypto-decimals (utils/get-crypto-decimals-count token)) | ||
input-value (reagent/atom "") | ||
input-error (reagent/atom false) | ||
current-limit (reagent/atom {:amount limit-crypto | ||
:currency token-symbol}) | ||
handle-swap (fn [crypto?] | ||
|
@@ -84,27 +91,30 @@ | |
:currency token-symbol} | ||
{:amount limit-fiat | ||
:currency currency})) | ||
(when (> num-value (:amount @current-limit)) | ||
(reset! input-value "")))) | ||
(reset-input-error num-value | ||
(:amount @current-limit) | ||
input-error))) | ||
handle-keyboard-press (fn [v] | ||
(let [current-value @input-value | ||
new-value (make-new-input current-value v) | ||
num-value (or (parse-double new-value) 0)] | ||
(when (and (not loading-suggested-routes?) | ||
(<= num-value (:amount @current-limit))) | ||
(let [current-value @input-value | ||
new-value (make-new-input current-value v) | ||
num-value (or (parse-double new-value) 0) | ||
current-limit-amount (:amount @current-limit)] | ||
(when (not loading-suggested-routes?) | ||
(reset! input-value new-value) | ||
(reset-input-error num-value current-limit-amount input-error) | ||
(reagent/flush)))) | ||
handle-delete (fn [_] | ||
(when-not loading-suggested-routes? | ||
(swap! input-value #(subs % 0 (dec (count %)))) | ||
(reagent/flush))) | ||
(let [current-limit-amount (:amount @current-limit)] | ||
(swap! input-value #(subs % 0 (dec (count %)))) | ||
(reset-input-error @input-value current-limit-amount input-error) | ||
(reagent/flush)))) | ||
handle-on-change (fn [v] | ||
(when (valid-input? @input-value v) | ||
(let [num-value (or (parse-double v) 0) | ||
current-limit-amount (:amount @current-limit)] | ||
(if (> num-value current-limit-amount) | ||
(reset! input-value (str current-limit-amount)) | ||
(reset! input-value v)) | ||
(reset! input-value v) | ||
(reset-input-error num-value current-limit-amount input-error) | ||
(reagent/flush))))] | ||
(fn [{:keys [on-confirm] | ||
:or {on-confirm #(rf/dispatch [:wallet/send-select-amount | ||
|
@@ -145,6 +155,7 @@ | |
:token token-symbol | ||
:currency currency | ||
:crypto-decimals crypto-decimals | ||
:error @input-error | ||
:networks (:networks token) | ||
:title (i18n/label :t/send-limit {:limit limit-label}) | ||
:conversion conversion-rate | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be
error?
??There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done