2023-11-09 11:21:56 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtTest 1.15
|
|
|
|
|
2024-01-16 16:22:05 +00:00
|
|
|
import StatusQ 0.1
|
|
|
|
import StatusQ.Models 0.1
|
|
|
|
|
2023-11-09 11:21:56 +00:00
|
|
|
import AppLayouts.Wallet.panels 1.0
|
|
|
|
|
|
|
|
import Models 1.0
|
2024-01-11 13:59:13 +00:00
|
|
|
import utils 1.0
|
2023-11-09 11:21:56 +00:00
|
|
|
|
|
|
|
Item {
|
|
|
|
id: root
|
|
|
|
width: 600
|
2024-01-26 15:39:42 +00:00
|
|
|
height: 2000
|
2023-11-09 11:21:56 +00:00
|
|
|
|
|
|
|
ManageCollectiblesModel {
|
|
|
|
id: collectiblesModel
|
|
|
|
}
|
|
|
|
|
2024-01-16 16:22:05 +00:00
|
|
|
RolesRenamingModel {
|
|
|
|
id: renamedModel
|
|
|
|
sourceModel: collectiblesModel
|
|
|
|
mapping: [
|
|
|
|
RoleRename {
|
|
|
|
from: "uid"
|
|
|
|
to: "symbol"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2023-11-09 11:21:56 +00:00
|
|
|
Component {
|
|
|
|
id: componentUnderTest
|
|
|
|
ManageCollectiblesPanel {
|
|
|
|
width: 500
|
2024-01-31 10:41:19 +00:00
|
|
|
height: contentHeight
|
2024-01-16 16:22:05 +00:00
|
|
|
controller: ManageTokensController {
|
|
|
|
sourceModel: renamedModel
|
|
|
|
settingsKey: "WalletCollectibles"
|
|
|
|
onCommunityTokenGroupHidden: (communityName) => Global.displayToastMessage(
|
|
|
|
qsTr("%1 community collectibles successfully hidden").arg(communityName), "", "checkmark-circle",
|
|
|
|
false, Constants.ephemeralNotificationType.success, "")
|
|
|
|
}
|
2023-11-09 11:21:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-11 13:59:13 +00:00
|
|
|
SignalSpy {
|
|
|
|
id: notificationSpy
|
|
|
|
target: Global
|
|
|
|
signalName: "displayToastMessage"
|
|
|
|
}
|
|
|
|
|
2023-11-09 11:21:56 +00:00
|
|
|
TestCase {
|
|
|
|
name: "ManageCollectiblesPanel"
|
|
|
|
when: windowShown
|
|
|
|
|
|
|
|
property ManageCollectiblesPanel controlUnderTest: null
|
|
|
|
|
|
|
|
function findDelegateIndexWithTitle(listview, title) {
|
2024-01-26 15:39:42 +00:00
|
|
|
waitForRendering(listview)
|
2023-11-09 11:21:56 +00:00
|
|
|
const count = listview.count
|
|
|
|
for (let i = 0; i < count; i++) {
|
|
|
|
const item = listview.itemAtIndex(i)
|
|
|
|
if (!!item && item.visible && item.title === title)
|
|
|
|
return i
|
|
|
|
}
|
|
|
|
return -1
|
|
|
|
}
|
|
|
|
|
|
|
|
function findDelegateMenuAction(listview, index, actionName, isGroup=false) {
|
|
|
|
const token = findChild(listview, "manageTokens%2Delegate-%1".arg(index).arg(isGroup ? "Group" : ""))
|
|
|
|
verify(!!token)
|
|
|
|
const delegateBtn = findChild(token, "btnManageTokenMenu-%1".arg(index))
|
|
|
|
verify(!!delegateBtn)
|
2024-01-26 15:39:42 +00:00
|
|
|
|
|
|
|
waitForItemPolished(delegateBtn)
|
2023-11-09 11:21:56 +00:00
|
|
|
mouseClick(delegateBtn)
|
|
|
|
const btnMenuLoader = findChild(delegateBtn, "manageTokensContextMenuLoader")
|
|
|
|
verify(!!btnMenuLoader)
|
2024-01-26 15:39:42 +00:00
|
|
|
|
2023-11-09 11:21:56 +00:00
|
|
|
tryCompare(btnMenuLoader, "active", true)
|
|
|
|
const btnMenu = btnMenuLoader.item
|
|
|
|
verify(!!btnMenu)
|
|
|
|
verify(btnMenu.open)
|
|
|
|
return findChild(btnMenu, actionName)
|
|
|
|
}
|
|
|
|
|
|
|
|
function triggerDelegateMenuAction(listview, index, actionName, isGroup=false) {
|
|
|
|
const action = findDelegateMenuAction(listview, index, actionName, isGroup)
|
|
|
|
verify(!!action)
|
|
|
|
action.trigger()
|
|
|
|
}
|
|
|
|
|
|
|
|
function init() {
|
|
|
|
controlUnderTest = createTemporaryObject(componentUnderTest, root)
|
2024-01-11 13:59:13 +00:00
|
|
|
notificationSpy.clear()
|
2023-11-09 11:21:56 +00:00
|
|
|
}
|
|
|
|
|
2024-01-26 15:39:42 +00:00
|
|
|
function cleanup() {
|
|
|
|
controlUnderTest.clearSettings()
|
|
|
|
}
|
|
|
|
|
2024-01-19 09:53:32 +00:00
|
|
|
function test_showHideSingleToken() {
|
2024-01-26 15:39:42 +00:00
|
|
|
waitForItemPolished(controlUnderTest)
|
2023-11-09 11:21:56 +00:00
|
|
|
verify(!controlUnderTest.dirty)
|
|
|
|
|
2024-01-26 15:39:42 +00:00
|
|
|
const lvOther = findChild(controlUnderTest, "otherTokensListView")
|
|
|
|
verify(!!lvOther)
|
2023-11-09 11:21:56 +00:00
|
|
|
|
2024-01-26 15:39:42 +00:00
|
|
|
tryCompare(lvOther, "count", 7)
|
|
|
|
const delegate0 = findChild(lvOther, "manageTokensDelegate-0")
|
2023-11-09 11:21:56 +00:00
|
|
|
verify(!!delegate0)
|
|
|
|
const title = delegate0.title
|
2024-01-11 13:59:13 +00:00
|
|
|
tryCompare(notificationSpy, "count", 0)
|
2024-01-26 15:39:42 +00:00
|
|
|
triggerDelegateMenuAction(lvOther, 0, "miHideCollectionToken")
|
2024-01-11 13:59:13 +00:00
|
|
|
// verify the signal to show the notification toast got fired
|
|
|
|
tryCompare(notificationSpy, "count", 1)
|
2023-11-09 11:21:56 +00:00
|
|
|
|
2024-01-16 16:22:05 +00:00
|
|
|
// verify we now have -1 regular tokens after the "hide" operation
|
2024-01-26 15:39:42 +00:00
|
|
|
tryCompare(lvOther, "count", 6)
|
2023-11-09 11:21:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function test_showHideCommunityGroup() {
|
|
|
|
verify(!controlUnderTest.dirty)
|
|
|
|
|
2024-01-26 15:39:42 +00:00
|
|
|
const communityHeader = findChild(controlUnderTest, "communityHeader")
|
|
|
|
verify(!!communityHeader)
|
|
|
|
const switchArrangeByCommunity = findChild(communityHeader, "switch")
|
2023-11-09 11:21:56 +00:00
|
|
|
verify(!!switchArrangeByCommunity)
|
2024-01-26 15:39:42 +00:00
|
|
|
|
|
|
|
waitForRendering(switchArrangeByCommunity)
|
|
|
|
mouseClick(switchArrangeByCommunity)
|
|
|
|
tryCompare(switchArrangeByCommunity, "checked", true)
|
|
|
|
|
|
|
|
tryCompare(controlUnderTest.controller, "arrangeByCommunity", true)
|
|
|
|
|
|
|
|
waitForRendering(controlUnderTest)
|
|
|
|
const lvCommunity = findChild(controlUnderTest, "communityTokensListView")
|
|
|
|
verify(!!lvCommunity)
|
2023-11-09 11:21:56 +00:00
|
|
|
|
|
|
|
// verify we have 2 community collectible groups
|
2024-02-13 11:12:01 +00:00
|
|
|
tryCompare(lvCommunity, "count", 4)
|
2024-01-11 13:59:13 +00:00
|
|
|
tryCompare(notificationSpy, "count", 0)
|
2024-01-26 15:39:42 +00:00
|
|
|
triggerDelegateMenuAction(lvCommunity, 0, "miHideTokenGroup", true)
|
2024-01-11 13:59:13 +00:00
|
|
|
// verify the signal to show the notification toast got fired
|
|
|
|
tryCompare(notificationSpy, "count", 1)
|
2023-11-09 11:21:56 +00:00
|
|
|
|
|
|
|
// verify we have one less group
|
2024-01-26 15:39:42 +00:00
|
|
|
waitForItemPolished(lvCommunity)
|
2024-02-13 11:12:01 +00:00
|
|
|
tryCompare(lvCommunity, "count", 3)
|
2023-11-09 11:21:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function test_dnd() {
|
|
|
|
verify(!controlUnderTest.dirty)
|
|
|
|
|
2024-01-26 15:39:42 +00:00
|
|
|
const lvOther = findChild(controlUnderTest, "otherTokensListView")
|
|
|
|
verify(!!lvOther)
|
|
|
|
verify(lvOther.count !== 0)
|
2023-11-09 11:21:56 +00:00
|
|
|
|
2024-01-26 15:39:42 +00:00
|
|
|
const delegate0 = findChild(lvOther, "manageTokensDelegate-0")
|
2023-11-09 11:21:56 +00:00
|
|
|
verify(!!delegate0)
|
|
|
|
const title0 = delegate0.title
|
|
|
|
verify(!!title0)
|
2024-01-26 15:39:42 +00:00
|
|
|
const delegate1 = findChild(lvOther, "manageTokensDelegate-1")
|
|
|
|
const title1 = delegate1.title
|
2023-11-09 11:21:56 +00:00
|
|
|
verify(!!title1)
|
|
|
|
|
2024-01-26 15:39:42 +00:00
|
|
|
waitForRendering(delegate1)
|
|
|
|
|
|
|
|
// DND one item up
|
|
|
|
mouseDrag(delegate1, delegate1.width/2, delegate1.height/2, 0, -delegate1.height)
|
2023-11-09 11:21:56 +00:00
|
|
|
|
|
|
|
// cross compare the titles
|
2024-01-26 15:39:42 +00:00
|
|
|
tryCompare(findChild(lvOther, "manageTokensDelegate-0"), "title", title1)
|
|
|
|
tryCompare(findChild(lvOther, "manageTokensDelegate-1"), "title", title0)
|
2023-11-09 11:21:56 +00:00
|
|
|
verify(controlUnderTest.dirty)
|
|
|
|
}
|
|
|
|
|
|
|
|
function test_group_dnd() {
|
|
|
|
verify(!controlUnderTest.dirty)
|
|
|
|
|
2024-01-26 15:39:42 +00:00
|
|
|
const communityHeader = findChild(controlUnderTest, "communityHeader")
|
|
|
|
verify(!!communityHeader)
|
|
|
|
const switchArrangeByCommunity = findChild(communityHeader, "switch")
|
2023-11-09 11:21:56 +00:00
|
|
|
verify(!!switchArrangeByCommunity)
|
2024-01-26 15:39:42 +00:00
|
|
|
|
|
|
|
waitForItemPolished(switchArrangeByCommunity)
|
2023-11-09 11:21:56 +00:00
|
|
|
mouseClick(switchArrangeByCommunity)
|
|
|
|
|
2024-01-26 15:39:42 +00:00
|
|
|
const lvCommunity = findChild(controlUnderTest, "communityTokensListView")
|
|
|
|
verify(!!lvCommunity)
|
|
|
|
waitForItemPolished(lvCommunity)
|
2024-02-13 11:12:01 +00:00
|
|
|
tryCompare(lvCommunity, "count", 4)
|
2023-11-09 11:21:56 +00:00
|
|
|
|
2024-01-26 15:39:42 +00:00
|
|
|
const group0 = findChild(lvCommunity, "manageTokensGroupDelegate-0")
|
2023-11-09 11:21:56 +00:00
|
|
|
const title0 = group0.title
|
|
|
|
verify(!!title0)
|
2024-01-26 15:39:42 +00:00
|
|
|
const group1 = findChild(lvCommunity, "manageTokensGroupDelegate-1")
|
|
|
|
const title1 = group1.title
|
2023-11-09 11:21:56 +00:00
|
|
|
verify(!!title1)
|
|
|
|
verify(title0 !== title1)
|
|
|
|
|
2024-01-26 15:39:42 +00:00
|
|
|
waitForRendering(group1)
|
|
|
|
|
|
|
|
mouseDrag(group1, group1.width/2, group1.height/2, 0, -group1.height)
|
2023-11-09 11:21:56 +00:00
|
|
|
|
|
|
|
// cross compare the titles
|
2024-01-26 15:39:42 +00:00
|
|
|
tryCompare(findChild(lvCommunity, "manageTokensGroupDelegate-0"), "title", title1)
|
|
|
|
tryCompare(findChild(lvCommunity, "manageTokensGroupDelegate-1"), "title", title0)
|
2023-11-09 11:21:56 +00:00
|
|
|
|
|
|
|
verify(controlUnderTest.dirty)
|
|
|
|
}
|
|
|
|
|
|
|
|
function test_group_move_hide_show_community_token() {
|
|
|
|
verify(!controlUnderTest.dirty)
|
|
|
|
const titleToTest = "Bearz"
|
|
|
|
|
2024-01-26 15:39:42 +00:00
|
|
|
const communityHeader = findChild(controlUnderTest, "communityHeader")
|
|
|
|
verify(!!communityHeader)
|
|
|
|
const switchArrangeByCommunity = findChild(communityHeader, "switch")
|
2023-11-09 11:21:56 +00:00
|
|
|
verify(!!switchArrangeByCommunity)
|
2024-01-26 15:39:42 +00:00
|
|
|
waitForRendering(switchArrangeByCommunity)
|
2023-11-09 11:21:56 +00:00
|
|
|
mouseClick(switchArrangeByCommunity)
|
|
|
|
|
2024-01-26 15:39:42 +00:00
|
|
|
const lvCommunity = findChild(controlUnderTest, "communityTokensListView")
|
|
|
|
verify(!!lvCommunity)
|
|
|
|
waitForItemPolished(lvCommunity)
|
2024-02-13 11:12:01 +00:00
|
|
|
tryCompare(lvCommunity, "count", 4)
|
2023-11-09 11:21:56 +00:00
|
|
|
|
|
|
|
// get the "Bearz" group at index 1
|
2024-01-26 15:39:42 +00:00
|
|
|
var bearzGroupTokenDelegate = findChild(lvCommunity, "manageTokensGroupDelegate-1")
|
2023-11-09 11:21:56 +00:00
|
|
|
const bearzTitle = bearzGroupTokenDelegate.title
|
|
|
|
compare(bearzTitle, titleToTest)
|
|
|
|
verify(!!bearzGroupTokenDelegate)
|
|
|
|
waitForItemPolished(bearzGroupTokenDelegate)
|
|
|
|
|
|
|
|
// now move the Bearz group up so that it's first (ends up at index 0)
|
2024-01-26 15:39:42 +00:00
|
|
|
waitForItemPolished(lvCommunity)
|
|
|
|
triggerDelegateMenuAction(lvCommunity, 1, "miMoveUp", true)
|
2023-11-09 11:21:56 +00:00
|
|
|
verify(controlUnderTest.dirty)
|
2024-01-26 15:39:42 +00:00
|
|
|
bearzGroupTokenDelegate = findChild(lvCommunity, "manageTokensGroupDelegate-0")
|
2023-11-09 11:21:56 +00:00
|
|
|
verify(!!bearzGroupTokenDelegate)
|
|
|
|
|
|
|
|
// finally verify that the Bearz group is still at top
|
2024-01-26 15:39:42 +00:00
|
|
|
waitForItemPolished(lvCommunity)
|
|
|
|
tryCompare(findChild(lvCommunity, "manageTokensGroupDelegate-0"), "title", titleToTest)
|
2023-11-09 11:21:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function test_moveOperations() {
|
|
|
|
verify(!controlUnderTest.dirty)
|
|
|
|
|
2024-01-26 15:39:42 +00:00
|
|
|
const lvOther = findChild(controlUnderTest, "otherTokensListView")
|
|
|
|
verify(!!lvOther)
|
|
|
|
verify(lvOther.count !== 0)
|
2023-11-09 11:21:56 +00:00
|
|
|
|
2024-01-26 15:39:42 +00:00
|
|
|
var delegate0 = findChild(lvOther, "manageTokensDelegate-0")
|
2023-11-09 11:21:56 +00:00
|
|
|
verify(!!delegate0)
|
|
|
|
const title = delegate0.title
|
|
|
|
|
|
|
|
// verify moveUp and moveToTop is not available for the first item
|
2024-01-26 15:39:42 +00:00
|
|
|
const moveUpAction = findDelegateMenuAction(lvOther, 0, "miMoveUp")
|
2023-11-09 11:21:56 +00:00
|
|
|
tryCompare(moveUpAction, "enabled", false)
|
2024-01-26 15:39:42 +00:00
|
|
|
const moveTopAction = findDelegateMenuAction(lvOther, 0, "miMoveToTop")
|
2023-11-09 11:21:56 +00:00
|
|
|
tryCompare(moveTopAction, "enabled", false)
|
|
|
|
|
|
|
|
// trigger move to bottom
|
2024-01-26 15:39:42 +00:00
|
|
|
waitForItemPolished(lvOther)
|
|
|
|
triggerDelegateMenuAction(lvOther, 0, "miMoveToBottom")
|
2023-11-09 11:21:56 +00:00
|
|
|
verify(controlUnderTest.dirty)
|
|
|
|
|
|
|
|
// verify the previous first and current last are actually the same item
|
2024-01-26 15:39:42 +00:00
|
|
|
const delegateN = findChild(lvOther, "manageTokensDelegate-%1".arg(lvOther.count-1))
|
2023-11-09 11:21:56 +00:00
|
|
|
verify(!!delegateN)
|
|
|
|
const titleN = delegateN.title
|
|
|
|
compare(title, titleN)
|
|
|
|
|
|
|
|
// verify move down and to bottom is not available for the last item
|
2024-01-26 15:39:42 +00:00
|
|
|
const moveDownAction = findDelegateMenuAction(lvOther, lvOther.count-1, "miMoveDown")
|
2023-11-09 11:21:56 +00:00
|
|
|
tryCompare(moveDownAction, "enabled", false)
|
2024-01-26 15:39:42 +00:00
|
|
|
const moveBottomAction = findDelegateMenuAction(lvOther, lvOther.count-1, "miMoveToBottom")
|
2023-11-09 11:21:56 +00:00
|
|
|
tryCompare(moveBottomAction, "enabled", false)
|
|
|
|
|
|
|
|
// trigger move to top and verify we got the same title (item) again
|
2024-01-26 15:39:42 +00:00
|
|
|
triggerDelegateMenuAction(lvOther, lvOther.count-1, "miMoveToTop")
|
|
|
|
waitForItemPolished(lvOther)
|
|
|
|
tryCompare(findChild(lvOther, "manageTokensDelegate-0"), "title", title)
|
2023-11-09 11:21:56 +00:00
|
|
|
|
|
|
|
// trigger move down and verify we got the same title (item) again
|
2024-01-26 15:39:42 +00:00
|
|
|
triggerDelegateMenuAction(lvOther, 0, "miMoveDown")
|
|
|
|
tryCompare(findChild(lvOther, "manageTokensDelegate-1"), "title", title)
|
2023-11-09 11:21:56 +00:00
|
|
|
|
|
|
|
// trigger move up and verify we got the same title (item) again
|
2024-01-26 15:39:42 +00:00
|
|
|
triggerDelegateMenuAction(lvOther, 1, "miMoveUp")
|
|
|
|
tryCompare(findChild(lvOther, "manageTokensDelegate-0"), "title", title)
|
2023-11-09 11:21:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function test_saveLoad() {
|
|
|
|
verify(!controlUnderTest.dirty)
|
|
|
|
const titleToTest = "Big Kitty"
|
|
|
|
|
2024-01-26 15:39:42 +00:00
|
|
|
let lvOther = findChild(controlUnderTest, "otherTokensListView")
|
|
|
|
verify(!!lvOther)
|
|
|
|
const bigKittyIndex = findDelegateIndexWithTitle(lvOther, titleToTest)
|
2023-11-09 11:21:56 +00:00
|
|
|
verify(bigKittyIndex !== -1)
|
2024-01-26 15:39:42 +00:00
|
|
|
const title0 = findChild(lvOther, "manageTokensDelegate-0").title
|
2023-11-09 11:21:56 +00:00
|
|
|
verify(!!title0)
|
|
|
|
verify(title0 !== titleToTest)
|
|
|
|
|
|
|
|
// trigger move to top and verify we got the correct title
|
2024-01-26 15:39:42 +00:00
|
|
|
triggerDelegateMenuAction(lvOther, bigKittyIndex, "miMoveToTop")
|
|
|
|
waitForItemPolished(lvOther)
|
|
|
|
tryCompare(findChild(lvOther, "manageTokensDelegate-0"), "title", titleToTest)
|
2023-11-09 11:21:56 +00:00
|
|
|
|
|
|
|
// save
|
|
|
|
verify(controlUnderTest.dirty)
|
|
|
|
controlUnderTest.saveSettings()
|
|
|
|
verify(!controlUnderTest.dirty)
|
|
|
|
|
|
|
|
// load the settings and check BigKitty is still on top
|
|
|
|
controlUnderTest.revert()
|
|
|
|
verify(!controlUnderTest.dirty)
|
2024-01-26 15:39:42 +00:00
|
|
|
lvOther = findChild(controlUnderTest, "otherTokensListView")
|
|
|
|
verify(!!lvOther)
|
|
|
|
waitForItemPolished(lvOther)
|
|
|
|
tryVerify(() => lvOther.count > 0)
|
|
|
|
const topItem = findChild(lvOther, "manageTokensDelegate-0")
|
2024-01-19 09:53:32 +00:00
|
|
|
verify(!!topItem)
|
|
|
|
tryCompare(topItem, "title", titleToTest)
|
2023-11-09 11:21:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|