fix(wallet)_: Temporarily disable Max Amount button pending #15709

- This commit temporarily disables the MaxAmount button in the `SwapInputPanel` and `SendModal` components.
     - The MaxAmount button will be reintroduced with the correct behavior in issue #15709 for the 2.31 release.

closes: #15710
This commit is contained in:
belalshehab 2024-07-25 02:20:27 +03:00 committed by Belal Shehab
parent db77654274
commit 1aa2221834
4 changed files with 30 additions and 18 deletions

View File

@ -274,7 +274,9 @@ Item {
verify(!maxTagButton.text.endsWith("ETH"))
}
// FIXME: This should be enabled after #15709 is resolved
function test_clickingMaxButton() {
skip("maxTabButton is diabled")
controlUnderTest = createTemporaryObject(componentUnderTest, root, {tokenKey: "ETH"})
verify(!!controlUnderTest)
waitForRendering(controlUnderTest)
@ -355,21 +357,24 @@ Item {
waitForRendering(controlUnderTest)
verify(maxTagButton.visible)
// FIXME: maxTagButton should be enabled after #15709 is resolved
verify(!maxTagButton.enabled)
verify(!maxTagButton.text.endsWith(modelItemToTest.symbol))
tryCompare(maxTagButton, "type", modelItemToTest.currentBalance === 0 ? StatusBaseButton.Type.Danger : StatusBaseButton.Type.Normal)
// check input value and state
mouseClick(maxTagButton)
waitForRendering(amountToSendInput)
tryCompare(amountToSendInput.input, "text", modelItemToTest.currentBalance === 0 ? "" : maxTagButton.maxSafeValueAsString)
compare(controlUnderTest.value, maxTagButton.maxSafeValue)
verify(modelItemToTest.currentBalance === 0 ? !controlUnderTest.valueValid : controlUnderTest.valueValid)
const marketPrice = !!amountToSendInput.selectedHolding ? amountToSendInput.selectedHolding.marketDetails.currencyPrice.amount : 0
compare(bottomItemText.text, d.adaptor.formatCurrencyAmount(
maxTagButton.maxSafeValue * marketPrice,
d.adaptor.currencyStore.currentCurrency))
if (maxTagButton.enabled) {
mouseClick(maxTagButton)
waitForRendering(amountToSendInput)
tryCompare(amountToSendInput.input, "text", modelItemToTest.currentBalance === 0 ? "" : maxTagButton.maxSafeValueAsString)
compare(controlUnderTest.value, maxTagButton.maxSafeValue)
verify(modelItemToTest.currentBalance === 0 ? !controlUnderTest.valueValid : controlUnderTest.valueValid)
const marketPrice = !!amountToSendInput.selectedHolding ? amountToSendInput.selectedHolding.marketDetails.currencyPrice.amount : 0
compare(bottomItemText.text, d.adaptor.formatCurrencyAmount(
maxTagButton.maxSafeValue * marketPrice,
d.adaptor.currencyStore.currentCurrency))
}
amountToSendInput.input.input.edit.clear()
}
}

View File

@ -1178,6 +1178,8 @@ Item {
// check states for the pay input selector
verify(maxTagButton.visible)
// FIXME: maxTagButton should be enabled after #15709 is resolved
verify(!maxTagButton.enabled);
let maxPossibleValue = WalletUtils.calculateMaxSafeSendAmount(expectedToken.currentBalance, expectedToken.symbol)
let truncmaxPossibleValue = Math.trunc(maxPossibleValue*100)/100
compare(maxTagButton.text, qsTr("Max. %1").arg(truncmaxPossibleValue === 0 ? Qt.locale().zeroDigit
@ -1189,15 +1191,16 @@ Item {
compare(amountToSendInput.input.placeholderText, LocaleUtils.numberToLocaleString(0))
tryCompare(bottomItemText, "text", root.swapAdaptor.currencyStore.formatCurrencyAmount(valueToExchange * expectedToken.marketDetails.currencyPrice.amount, root.swapAdaptor.currencyStore.currentCurrency))
// click on max button
mouseClick(maxTagButton)
waitForItemPolished(payPanel)
verify(amountToSendInput.interactive)
verify(amountToSendInput.input.input.edit.cursorVisible)
tryCompare(amountToSendInput.input, "text", maxPossibleValue === 0 ? "" : maxPossibleValue.toLocaleString(Qt.locale(), 'f', -128))
tryCompare(bottomItemText, "text", root.swapAdaptor.currencyStore.formatCurrencyAmount(maxPossibleValue * expectedToken.marketDetails.currencyPrice.amount, root.swapAdaptor.currencyStore.currentCurrency))
if (maxTagButton.enabled) {
// click on max button
mouseClick(maxTagButton)
waitForItemPolished(payPanel)
verify(amountToSendInput.interactive)
verify(amountToSendInput.input.input.edit.cursorVisible)
tryCompare(amountToSendInput.input, "text", maxPossibleValue === 0 ? "" : maxPossibleValue.toLocaleString(Qt.locale(), 'f', -128))
tryCompare(bottomItemText, "text", root.swapAdaptor.currencyStore.formatCurrencyAmount(maxPossibleValue * expectedToken.marketDetails.currencyPrice.amount, root.swapAdaptor.currencyStore.currentCurrency))
}
closeAndVerfyModal()
}

View File

@ -276,6 +276,8 @@ Control {
{ noSymbol: !amountToSendInput.inputIsFiat })
visible: d.isSelectedHoldingValidAsset && root.swapSide === SwapInputPanel.SwapSide.Pay
// FIXME: This should be enabled after #15709 is resolved
enabled: false
onClicked: {
if (maxSafeValue)

View File

@ -427,6 +427,8 @@ StatusDialog {
Layout.alignment: Qt.AlignVCenter | Qt.AlignRight
visible: d.isSelectedHoldingValidAsset && !d.isCollectiblesTransfer
// FIXME: This should be enabled after #15709 is resolved
enabled: false
onClicked: {
if (maxSafeValue > 0) {