Add test for edit avatar issue

This commit is contained in:
B.Melnik 2021-10-08 14:55:05 +03:00
parent 7289c8b782
commit 57cc80304c
No known key found for this signature in database
GPG Key ID: 4A9B2E42E3BD4727
8 changed files with 105 additions and 49 deletions

3
.gitmodules vendored
View File

@ -1,6 +1,3 @@
[submodule "StatusQ"]
path = StatusQ
url = https://github.com/status-im/StatusQ
[submodule "status-desktop"]
path = status-desktop
url = https://github.com/status-im/status-desktop.git

14
base/ChatsModelData.qml Normal file
View File

@ -0,0 +1,14 @@
import QtQuick 2.14
QtObject {
id: chatsModel
property var ensView: QtObject {
function isEnsVerified(author) {
return true;
}
}
function alias(author) {
return "some alias"
}
}

View File

@ -27,6 +27,23 @@ QtObject {
return null
}
function getObjectByObjectName(parent, objectName) {
for (var idx in parent.children) {
var child = parent.children[idx]
if (child.objectName === objectName) {
return child;
} else {
var res = getObjectByObjectName(child, objectName)
if (!!res) {
return res;
}
}
}
return null;
}
function findChildByClassName(item, className) {
for (var idx in item.children) {
let child = item.children[idx]

24
base/ProfileModelData.qml Normal file
View File

@ -0,0 +1,24 @@
import QtQuick 2.14
QtObject {
id: profileModel
property var contacts: QtObject {
function isContactBlocked(author) {
return false;
}
function isAdded(author) {
return true
}
}
property var profile: QtObject {
property string pubKey: "Some author"
}
function qrCode(author) {
return ""
}
property var ens: ({preferredUserName: "preffered User name"})
}

View File

@ -23,8 +23,7 @@ public slots:
void qmlEngineAvailable(QQmlEngine *engine)
{
engine->rootContext()->setContextProperty("myContextProperty", QVariant(true));
qDebug() << "StatusQ Path: " << QString(PWD(PROJECT_PATH));
engine->addImportPath(QString(PWD(PROJECT_PATH)) + "/StatusQ/src");
engine->addImportPath(QString(PWD(PROJECT_PATH)) + "/status-desktop/ui/StatusQ/src");
engine->addImportPath(QString(PWD(PROJECT_PATH)) + "/status-desktop/ui/imports");
}
};

@ -1 +1 @@
Subproject commit 4b73d6849025c8272c3fc882855f73a0d113ced6
Subproject commit abf2a46dc99353704e1432ad79990174ffd5cd6c

View File

@ -6,55 +6,34 @@ import "base"
import "status-desktop/ui/app/AppLayouts/Chat/components" as DesktopComponents
TestCase {
WindowTestCase {
name: "ProfilePopup"
when: windowShown
Helpers { id: helpers }
/// TODO: add good test data
QtObject {
ChatsModelData {
id: chatsModel
property var ensView: QtObject {
function isEnsVerified(author) {
return true;
}
}
function alias(author) {
return "some alias"
}
}
QtObject {
ProfileModelData {
id: profileModel
property var contacts: QtObject {
function isContactBlocked(author) {
return false;
}
function isAdded(author) {
return true
}
}
property var profile: QtObject {
property string pubKey: "Some author"
}
function qrCode(author) {
return ""
}
}
Window {
id: window
width: 800
height: 600
Component {
id: popupComponent
DesktopComponents.ProfilePopup {
id: propfilePopup
id: propfile
}
}
// Catching editClickedSignal
SignalSpy {
id: editClickedSpy
signalName: "editAvatarButtonClicked"
}
///////
function initTestCase() {
@ -62,24 +41,49 @@ TestCase {
}
function cleanupTestCase() {
window.close()
}
function test_case1() {
var propfilePopup = popupComponent.createObject(window)
propfilePopup.openPopup(true, "Test user", "Some author", "", "bla bla test it bitch", "Nickname")
wait(2000) // for show how its works
mouseClick(propfilePopup.background, propfilePopup.width - 65, 20, Qt.LeftButton)
verify(helpers.checkIfItemExists(propfilePopup.background, propfilePopup.width - 65, 20, "StatusFlatRoundButton"))
wait(2000) // for show how its works
verify(propfilePopup.contentItem.qrCodePopup.visible, "Qr code should be visible")
propfilePopup.contentItem.qrCodePopup.close()
verify(!propfilePopup.contentItem.qrCodePopup.visible, "Qr code should be visible")
propfilePopup.destroy()
}
function test_case2() {
mouseClick(propfilePopup.background, propfilePopup.width - 25, 20, Qt.LeftButton)
function test_case2CurrentUser() {
profileModel.profile.pubKey = "current-user"
var propfilePopup = popupComponent.createObject(window)
wait(2000)
verify(!propfilePopup.visible, "Profile popup should be invisible")
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)
var editbButton = helpers.getObjectByObjectName(propfilePopup.background, "editAvatarButton")
verify(!!editbButton, "object with name \"editAvatarButton\" not found")
verify(editbButton.visible, "editAvatarButton should be visible")
compare(editClickedSpy.count, 0)
mouseClick(editbButton, 1, 1, Qt.LeftButton)
wait(5000)
compare(editClickedSpy.count, 1, "Edit avatar button not clicked")
propfilePopup.destroy()
}
function test_case3NotCurrentUser() {
profileModel.profile.pubKey = "another-user"
var propfilePopup = popupComponent.createObject(window)
wait(2000)
propfilePopup.openPopup(true, "Test user", "current-user", "", "bla bla test it bitch", "Nickname")
wait(5000)
verify(!propfilePopup.isCurrentUser, "User should be is not current")
var editbButton = helpers.getObjectByObjectName(propfilePopup.background, "editAvatarButton")
verify(!!editbButton, "object with name \"editAvatarButton\" not found")
verify(!editbButton.visible, "editAvatarButton should be not visible")
propfilePopup.destroy()
}
}

View File

@ -7,13 +7,14 @@ DESTDIR += $${PWD}/bin
DEFINES += PROJECT_PATH=\"$${PWD}\"
DISTFILES += \
base/ChatsModelData.qml \
base/Helpers.qml \
base/ProfileModelData.qml \
base/WindowTestCase.qml \
tst_Modals.qml \
tst_initialtest.qml
DISTFILES += $$files("StatusQ/src/*", true)
DISTFILES += $$files("status-desktop/ui/app/*", true)
DISTFILES += $$files("status-desktop/ui/*", true)
SOURCES += \
main.cpp \