diff --git a/.gitmodules b/.gitmodules index a2abc31..2a180cf 100644 --- a/.gitmodules +++ b/.gitmodules @@ -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 diff --git a/base/ChatsModelData.qml b/base/ChatsModelData.qml new file mode 100644 index 0000000..39c50c4 --- /dev/null +++ b/base/ChatsModelData.qml @@ -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" + } +} diff --git a/base/Helpers.qml b/base/Helpers.qml index 5029f27..b38fb71 100644 --- a/base/Helpers.qml +++ b/base/Helpers.qml @@ -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] diff --git a/base/ProfileModelData.qml b/base/ProfileModelData.qml new file mode 100644 index 0000000..3674759 --- /dev/null +++ b/base/ProfileModelData.qml @@ -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"}) +} diff --git a/setup.h b/setup.h index 1221bc9..5101860 100644 --- a/setup.h +++ b/setup.h @@ -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"); } }; diff --git a/status-desktop b/status-desktop index 4b73d68..abf2a46 160000 --- a/status-desktop +++ b/status-desktop @@ -1 +1 @@ -Subproject commit 4b73d6849025c8272c3fc882855f73a0d113ced6 +Subproject commit abf2a46dc99353704e1432ad79990174ffd5cd6c diff --git a/tst_Modals.qml b/tst_Modals.qml index ae70b77..d44dac2 100644 --- a/tst_Modals.qml +++ b/tst_Modals.qml @@ -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() } } diff --git a/ui-tests.pro b/ui-tests.pro index e363fc3..a3101b1 100644 --- a/ui-tests.pro +++ b/ui-tests.pro @@ -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 \