From 1aa22218347862e5bed274226025f00ae946e738 Mon Sep 17 00:00:00 2001 From: belalshehab Date: Thu, 25 Jul 2024 02:20:27 +0300 Subject: [PATCH] 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 --- .../qmlTests/tests/tst_SwapInputPanel.qml | 25 +++++++++++-------- storybook/qmlTests/tests/tst_SwapModal.qml | 19 ++++++++------ .../Wallet/panels/SwapInputPanel.qml | 2 ++ ui/imports/shared/popups/send/SendModal.qml | 2 ++ 4 files changed, 30 insertions(+), 18 deletions(-) diff --git a/storybook/qmlTests/tests/tst_SwapInputPanel.qml b/storybook/qmlTests/tests/tst_SwapInputPanel.qml index e2c63a4ca8..9d8eff6d1d 100644 --- a/storybook/qmlTests/tests/tst_SwapInputPanel.qml +++ b/storybook/qmlTests/tests/tst_SwapInputPanel.qml @@ -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() } } diff --git a/storybook/qmlTests/tests/tst_SwapModal.qml b/storybook/qmlTests/tests/tst_SwapModal.qml index 5399729137..c5e4b4df0b 100644 --- a/storybook/qmlTests/tests/tst_SwapModal.qml +++ b/storybook/qmlTests/tests/tst_SwapModal.qml @@ -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() } diff --git a/ui/app/AppLayouts/Wallet/panels/SwapInputPanel.qml b/ui/app/AppLayouts/Wallet/panels/SwapInputPanel.qml index 5b4840bd68..a98dd4cdd8 100644 --- a/ui/app/AppLayouts/Wallet/panels/SwapInputPanel.qml +++ b/ui/app/AppLayouts/Wallet/panels/SwapInputPanel.qml @@ -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) diff --git a/ui/imports/shared/popups/send/SendModal.qml b/ui/imports/shared/popups/send/SendModal.qml index 01ff74d631..ae743741b9 100644 --- a/ui/imports/shared/popups/send/SendModal.qml +++ b/ui/imports/shared/popups/send/SendModal.qml @@ -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) {