mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-26 13:36:04 +00:00
fix(TokenSelector): Duplicate plain token entries
- filter out plain tokens from the adaptor's if already present in the output model - add a corresponding regression test Fixes #15412
This commit is contained in:
parent
a18056c7d1
commit
464af7a04d
@ -46,6 +46,14 @@ SplitView {
|
|||||||
image: "https://etherscan.io/token/images/horizonstate2_28.png"
|
image: "https://etherscan.io/token/images/horizonstate2_28.png"
|
||||||
communityId: ""
|
communityId: ""
|
||||||
}
|
}
|
||||||
|
// DAI should be filtered out
|
||||||
|
ListElement {
|
||||||
|
key: "DAI"
|
||||||
|
name: "Dai Stablecoin"
|
||||||
|
symbol: "DAI"
|
||||||
|
image: ""
|
||||||
|
communityId: ""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
|
@ -22,6 +22,14 @@ Item {
|
|||||||
image: "https://cryptologos.cc/logos/aave-aave-logo.png"
|
image: "https://cryptologos.cc/logos/aave-aave-logo.png"
|
||||||
communityId: ""
|
communityId: ""
|
||||||
}
|
}
|
||||||
|
// DAI should be filtered out
|
||||||
|
ListElement {
|
||||||
|
key: "DAI"
|
||||||
|
name: "Dai Stablecoin"
|
||||||
|
symbol: "DAI"
|
||||||
|
image: ""
|
||||||
|
communityId: ""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
@ -133,5 +141,16 @@ Item {
|
|||||||
// should have ~45.90 balance
|
// should have ~45.90 balance
|
||||||
fuzzyCompare(delegate.currencyBalance, 45.90, 0.01)
|
fuzzyCompare(delegate.currencyBalance, 45.90, 0.01)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function test_duplicatePlainTokens() {
|
||||||
|
verify(!!controlUnderTest)
|
||||||
|
|
||||||
|
controlUnderTest.showAllTokens = true
|
||||||
|
const searchText = "DAI"
|
||||||
|
controlUnderTest.searchString = searchText
|
||||||
|
|
||||||
|
// search yields 1 result
|
||||||
|
tryCompare(controlUnderTest.outputAssetsModel, "count", 1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,6 +106,21 @@ QObject {
|
|||||||
roleName: "communityId"
|
roleName: "communityId"
|
||||||
value: ""
|
value: ""
|
||||||
enabled: !root.showCommunityAssets
|
enabled: !root.showCommunityAssets
|
||||||
|
},
|
||||||
|
// duplicate tokens filter
|
||||||
|
FastExpressionFilter {
|
||||||
|
function hasDuplicateKey(tokensKey) {
|
||||||
|
return ModelUtils.indexOf(assetsObjectProxyModel, "tokensKey", tokensKey) > -1
|
||||||
|
}
|
||||||
|
|
||||||
|
expression: {
|
||||||
|
if (model.which_model === "plain_tokens_model") {
|
||||||
|
return !hasDuplicateKey(model.tokensKey)
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
expectedRoles: ["which_model", "tokensKey"]
|
||||||
|
enabled: root.showAllTokens
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user