2021-09-28 20:47:01 +00:00
|
|
|
import QtQuick 2.14
|
|
|
|
import QtQuick.Window 2.14
|
|
|
|
import QtTest 1.14
|
|
|
|
|
2021-10-01 08:37:08 +00:00
|
|
|
import "base"
|
2021-09-28 20:47:01 +00:00
|
|
|
import "status-desktop/ui/app/AppLayouts/Chat/components" as DesktopComponents
|
|
|
|
|
|
|
|
|
2021-10-08 11:55:05 +00:00
|
|
|
WindowTestCase {
|
2021-09-28 20:47:01 +00:00
|
|
|
name: "ProfilePopup"
|
|
|
|
when: windowShown
|
|
|
|
|
2021-10-01 08:37:08 +00:00
|
|
|
Helpers { id: helpers }
|
|
|
|
|
2021-09-28 20:47:01 +00:00
|
|
|
/// TODO: add good test data
|
2021-10-08 11:55:05 +00:00
|
|
|
ChatsModelData {
|
2021-09-28 20:47:01 +00:00
|
|
|
id: chatsModel
|
|
|
|
}
|
|
|
|
|
2021-10-08 11:55:05 +00:00
|
|
|
ProfileModelData {
|
2021-09-28 20:47:01 +00:00
|
|
|
id: profileModel
|
|
|
|
}
|
|
|
|
|
2021-10-08 11:55:05 +00:00
|
|
|
Component {
|
|
|
|
id: popupComponent
|
2021-09-28 20:47:01 +00:00
|
|
|
DesktopComponents.ProfilePopup {
|
2021-10-08 11:55:05 +00:00
|
|
|
id: propfile
|
2021-09-28 20:47:01 +00:00
|
|
|
}
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2021-09-28 20:47:01 +00:00
|
|
|
///////
|
|
|
|
|
|
|
|
function test_case1() {
|
2021-10-08 11:55:05 +00:00
|
|
|
var propfilePopup = popupComponent.createObject(window)
|
2021-09-28 20:47:01 +00:00
|
|
|
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-09-28 20:47:01 +00:00
|
|
|
}
|
|
|
|
|
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)
|
2021-09-28 20:47:01 +00:00
|
|
|
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()
|
2021-09-28 20:47:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|