desktop-ui-tests/tst_profile_popup.qml

82 lines
2.7 KiB
QML
Raw Normal View History

import QtQuick 2.14
import QtQuick.Window 2.14
import QtTest 1.14
2021-10-01 08:37:08 +00:00
import "base"
import "status-desktop/ui/app/AppLayouts/Chat/components" as DesktopComponents
2021-10-08 11:55:05 +00:00
WindowTestCase {
name: "ProfilePopup"
when: windowShown
2021-10-01 08:37:08 +00:00
Helpers { id: helpers }
/// TODO: add good test data
2021-10-08 11:55:05 +00:00
ChatsModelData {
id: chatsModel
}
2021-10-08 11:55:05 +00:00
ProfileModelData {
id: profileModel
}
2021-10-08 11:55:05 +00:00
Component {
id: popupComponent
DesktopComponents.ProfilePopup {
2021-10-08 11:55:05 +00:00
id: propfile
}
}
2021-10-08 11:55:05 +00:00
// Catching editClickedSignal
SignalSpy {
id: editClickedSpy
2021-10-15 08:10:55 +00:00
signalName: "headerImageClicked"
2021-10-08 11:55:05 +00:00
}
///////
function test_case1() {
2021-10-08 11:55:05 +00:00
var propfilePopup = popupComponent.createObject(window)
propfilePopup.openPopup(true, "Test user", "Some author", "", "bla bla test it bitch", "Nickname")
mouseClick(propfilePopup.background, propfilePopup.width - 65, 20, Qt.LeftButton)
verify(propfilePopup.contentItem.qrCodePopup.visible, "Qr code should be visible")
propfilePopup.contentItem.qrCodePopup.close()
verify(!propfilePopup.contentItem.qrCodePopup.visible, "Qr code should be visible")
2021-10-08 11:55:05 +00:00
propfilePopup.destroy()
}
2021-10-15 08:10:55 +00:00
function test_case2_current_user() {
2021-10-08 11:55:05 +00:00
profileModel.profile.pubKey = "current-user"
var propfilePopup = popupComponent.createObject(window)
wait(2000)
propfilePopup.openPopup(true, "Test user", "current-user", "", "bla bla test it bitch", "Nickname")
editClickedSpy.target = propfilePopup
verify(propfilePopup.isCurrentUser, "User should be current")
wait(5000)
2021-10-15 08:10:55 +00:00
var editbButton = helpers.getObjectByObjectName(propfilePopup.background, "editAvatarImage")
verify(!!editbButton, "object with name \"editAvatarImage\" not found")
verify(editbButton.visible, "editAvatarImage should be visible")
2021-10-08 11:55:05 +00:00
compare(editClickedSpy.count, 0)
mouseClick(editbButton, 1, 1, Qt.LeftButton)
wait(5000)
compare(editClickedSpy.count, 1, "Edit avatar button not clicked")
propfilePopup.destroy()
}
2021-10-15 08:10:55 +00:00
function test_case3_not_current_user() {
2021-10-08 11:55:05 +00:00
profileModel.profile.pubKey = "another-user"
var propfilePopup = popupComponent.createObject(window)
wait(2000)
2021-10-08 11:55:05 +00:00
propfilePopup.openPopup(true, "Test user", "current-user", "", "bla bla test it bitch", "Nickname")
wait(5000)
verify(!propfilePopup.isCurrentUser, "User should be is not current")
2021-10-15 08:10:55 +00:00
var editbButton = helpers.getObjectByObjectName(propfilePopup.background, "editAvatarImage")
verify(!!editbButton, "object with name \"editAvatarImage\" not found")
verify(!editbButton.visible, "editAvatarImage should be not visible")
2021-10-08 11:55:05 +00:00
propfilePopup.destroy()
}
}