/ tst_profile_popup.qml
tst_profile_popup.qml
1 import QtQuick 2.14 2 import QtQuick.Window 2.14 3 import QtTest 1.14 4 5 import "base" 6 import "status-desktop/ui/app/AppLayouts/Chat/components" as DesktopComponents 7 8 9 WindowTestCase { 10 name: "ProfilePopup" 11 when: windowShown 12 13 Helpers { id: helpers } 14 15 /// TODO: add good test data 16 ChatsModelData { 17 id: chatsModel 18 } 19 20 ProfileModelData { 21 id: profileModel 22 } 23 24 Component { 25 id: popupComponent 26 DesktopComponents.ProfilePopup { 27 id: propfile 28 } 29 } 30 31 // Catching editClickedSignal 32 SignalSpy { 33 id: editClickedSpy 34 signalName: "headerImageClicked" 35 } 36 37 /////// 38 39 function test_case1() { 40 var propfilePopup = popupComponent.createObject(window) 41 propfilePopup.openPopup(true, "Test user", "Some author", "", "bla bla test it bitch", "Nickname") 42 mouseClick(propfilePopup.background, propfilePopup.width - 65, 20, Qt.LeftButton) 43 verify(propfilePopup.contentItem.qrCodePopup.visible, "Qr code should be visible") 44 propfilePopup.contentItem.qrCodePopup.close() 45 verify(!propfilePopup.contentItem.qrCodePopup.visible, "Qr code should be visible") 46 propfilePopup.destroy() 47 } 48 49 function test_case2_current_user() { 50 profileModel.profile.pubKey = "current-user" 51 var propfilePopup = popupComponent.createObject(window) 52 wait(2000) 53 propfilePopup.openPopup(true, "Test user", "current-user", "", "bla bla test it bitch", "Nickname") 54 editClickedSpy.target = propfilePopup 55 verify(propfilePopup.isCurrentUser, "User should be current") 56 wait(5000) 57 var editbButton = helpers.getObjectByObjectName(propfilePopup.background, "editAvatarImage") 58 verify(!!editbButton, "object with name \"editAvatarImage\" not found") 59 verify(editbButton.visible, "editAvatarImage should be visible") 60 61 compare(editClickedSpy.count, 0) 62 mouseClick(editbButton, 1, 1, Qt.LeftButton) 63 wait(5000) 64 compare(editClickedSpy.count, 1, "Edit avatar button not clicked") 65 propfilePopup.destroy() 66 } 67 68 function test_case3_not_current_user() { 69 profileModel.profile.pubKey = "another-user" 70 var propfilePopup = popupComponent.createObject(window) 71 wait(2000) 72 propfilePopup.openPopup(true, "Test user", "current-user", "", "bla bla test it bitch", "Nickname") 73 wait(5000) 74 verify(!propfilePopup.isCurrentUser, "User should be is not current") 75 var editbButton = helpers.getObjectByObjectName(propfilePopup.background, "editAvatarImage") 76 verify(!!editbButton, "object with name \"editAvatarImage\" not found") 77 verify(!editbButton.visible, "editAvatarImage should be not visible") 78 propfilePopup.destroy() 79 } 80 } 81