fix(@desktop/wallet): fix for Swap Input parameters reset when balances are reloaded

fixes #15785
This commit is contained in:
Khushboo Mehta 2024-07-31 15:02:10 +02:00 committed by Khushboo-dev-cpp
parent b67ea6643a
commit 27aaa97ebd
4 changed files with 37 additions and 11 deletions

View File

@ -479,5 +479,40 @@ Item {
compare(controlUnderTest.selectedHoldingId, tokenKeyToTest)
compare(controlUnderTest.amountEnteredGreaterThanBalance, false)
}
function test_if_values_not_reset_on_modelReset() {
const tokenKeyToTest = "ETH"
let numberTestedString = "1.0001"
let modelItemToTest = ModelUtils.getByKey(d.tokenSelectorAdaptor.outputAssetsModel, "tokensKey", tokenKeyToTest)
controlUnderTest = createTemporaryObject(componentUnderTest, root, {
swapSide: SwapInputPanel.SwapSide.Pay,
tokenKey: tokenKeyToTest,
tokenAmount: numberTestedString
})
verify(!!controlUnderTest)
waitForRendering(controlUnderTest)
const amountToSendInput = findChild(controlUnderTest, "amountToSendInput")
verify(!!amountToSendInput)
let numberTested = LocaleUtils.numberFromLocaleString(numberTestedString, amountToSendInput.input.locale)
compare(amountToSendInput.input.text, numberTestedString)
compare(controlUnderTest.value, numberTested)
compare(controlUnderTest.rawValue, AmountsArithmetic.fromNumber(amountToSendInput.input.text, modelItemToTest.decimals).toString())
compare(controlUnderTest.valueValid, true)
compare(controlUnderTest.selectedHoldingId, tokenKeyToTest)
compare(controlUnderTest.amountEnteredGreaterThanBalance, false)
d.tokenSelectorAdaptor.assetsModel.modelReset()
compare(amountToSendInput.input.text, numberTestedString)
compare(controlUnderTest.value, numberTested)
compare(controlUnderTest.rawValue, AmountsArithmetic.fromNumber(amountToSendInput.input.text, modelItemToTest.decimals).toString())
compare(controlUnderTest.valueValid, true)
compare(controlUnderTest.selectedHoldingId, tokenKeyToTest)
compare(controlUnderTest.amountEnteredGreaterThanBalance, false)
}
}
}

View File

@ -1064,6 +1064,7 @@ Item {
const receivePanel = findChild(controlUnderTest, "receivePanel")
verify(!!receivePanel)
waitForRendering(receivePanel)
const amountToSendInput = findChild(receivePanel, "amountToSendInput")
verify(!!amountToSendInput)
const bottomItemText = findChild(receivePanel, "bottomItemText")

View File

@ -188,6 +188,7 @@ QObject {
ConcatModel {
id: concatModel
propagateResets: true
sources: [
SourceModel {
model: renamedTokensBySymbolModel

View File

@ -122,17 +122,6 @@ Control {
}
}
/* TODO: remove after https://github.com/status-im/status-desktop/issues/15604 is
implemented as this is hack to set token values correctly when model is reset */
Connections {
target: holdingSelector.model
function onRowsInserted() {
if(!!tokenKey) {
root.reevaluateSelectedId()
}
}
}
background: Shape {
id: shape