Skip to content

Commit

Permalink
fix(@desktop/sugnup): Profile omage chosen during signup sould be sav…
Browse files Browse the repository at this point in the history
…ed for the user and squish test for the same

fixes #6861
  • Loading branch information
Khushboo-dev-cpp committed Aug 24, 2022
1 parent b23414e commit 8eb328b
Show file tree
Hide file tree
Showing 30 changed files with 172 additions and 466 deletions.
4 changes: 2 additions & 2 deletions src/app/modules/startup/module.nim
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,10 @@ method onNodeLogin*[T](self: Module[T], error: string) =
quit() # quit the app

if error.len == 0:
self.controller.cleanTmpData()
self.delegate.userLoggedIn()
if currStateObj.flowType() != FlowType.AppLogin:
self.controller.storeIdentityImage()
self.controller.cleanTmpData()
else:
self.view.setAppState(AppState.StartupState)
if currStateObj.flowType() == FlowType.AppLogin:
Expand Down Expand Up @@ -300,4 +300,4 @@ method onSharedKeycarModuleFlowTerminated*[T](self: Module[T], lastStepInTheCurr
self.keycardSharedModule = nil
if lastStepInTheCurrentFlow:
self.controller.cleanTmpData()
self.view.setCurrentStartupState(newWelcomeState(FlowType.General, nil))
self.view.setCurrentStartupState(newWelcomeState(FlowType.General, nil))
Binary file added test/ui-test/fixtures/images/doggo.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions test/ui-test/src/drivers/SquishDriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
# The default minimum timeout to find ui object
_MIN_WAIT_OBJ_TIMEOUT = 500

_SEARCH_IMAGES_PATH = "../shared/searchImages/"

# Waits for the given object is loaded, visible and enabled.
# It returns a tuple: True in case it is found. Otherwise, false. And the object itself.
Expand Down Expand Up @@ -297,3 +298,7 @@ def verify_not_found(realNameVarName: str, message: str, timeoutMSec: int = 500)
test.fail(message, f'Unexpected: the object "{realNameVarName}" was found.')
except LookupError as err:
test.passes(message, f'Expected: the object "{realNameVarName}" was not found. Exception: {str(err)}.')

def grabScreenshot_and_save(obj, imageName:str, delay:int = 0):
img = object.grabScreenshot(obj, {"delay": delay})
img.save(_SEARCH_IMAGES_PATH + imageName + ".png")
3 changes: 3 additions & 0 deletions test/ui-test/src/drivers/SquishDriverVerification.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,6 @@ def log(text: str):

def verify_screenshot(vp: str):
test.vp(vp)

def imagePresent(imageName: str, tolerant: bool = True, threshold: int = 99.5, minScale: int = 50, maxScale: int = 200, multiscale: bool = True):
test.imagePresent(imageName, {"tolerant": tolerant, "threshold": threshold, "minScale": minScale, "maxScale": maxScale, "multiscale": multiscale})
3 changes: 1 addition & 2 deletions test/ui-test/src/screens/StatusMainScreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@
import time

class MainScreenComponents(Enum):
STATUS_ICON = "mainWindow_statusIcon_StatusIcon_2"
PUBLIC_CHAT_ICON = "mainWindow_public_chat_icon_StatusIcon"
CHAT_NAVBAR_ICON = "navBarListView_Chat_navbar_StatusNavBarTabButton"
COMMUNITY_PORTAL_BUTTON = "navBarListView_Communities_Portal_navbar_StatusNavBarTabButton"
JOIN_PUBLIC_CHAT = "join_public_chat_StatusMenuItemDelegate"
SETTINGS_BUTTON = "settings_navbar_settings_icon_StatusIcon"
SETTINGS_BUTTON = "navBarListView_Settings_navbar_StatusNavBarTabButton"
WALLET_BUTTON = "wallet_navbar_wallet_icon_StatusIcon"
START_CHAT_BTN = "mainWindow_startChat"
CHAT_LIST = "chatList_Repeater"
Expand Down
76 changes: 75 additions & 1 deletion test/ui-test/src/screens/StatusWelcomeScreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from drivers.SquishDriver import *
from drivers.SquishDriverVerification import *
from common.SeedUtils import *
from screens.StatusMainScreen import MainScreenComponents


class AgreementPopUp(Enum):
Expand All @@ -36,7 +37,9 @@ class SignUpComponents(Enum):
CONFIRM_PSW_AGAIN_INPUT: str = "onboarding_confirmPswAgain_Input"
FINALIZE_PSW_BUTTON: str = "onboarding_finalise_password_button"
PASSWORD_PREFERENCE: str = "mainWindow_I_prefer_to_use_my_password_StatusBaseText"

PROFILE_IMAGE_CROP_WORKFLOW_ITEM: str = "mainWindow_WelcomeScreen_Image_Crop_Workflow_Item"
PROFILE_IMAGE_CROPPER_ACCEPT_BUTTON: str = "mainWindow_WelcomeScreen_Image_Cropper_Accept_Button"
WELCOME_SCREEN_USER_PROFILE_IMAGE: str = "mainWindow_WelcomeScreen_User_Profile_Image"

class SeedPhraseComponents(Enum):
IMPORT_A_SEED_TEXT: str = "import_a_seed_phrase_StatusBaseText"
Expand All @@ -58,6 +61,20 @@ class PasswordStrengthPossibilities(Enum):
NUMBERS_SYMBOLS_LOWER_UPPER_GOOD = "numbers_symbols_lower_upper_good"
NUMBERS_SYMBOLS_LOWER_UPPER_GREAT = "numbers_symbols_lower_upper_great"

class MainScreen(Enum):
SETTINGS_BUTTON = "settings_navbar_settings_icon_StatusIcon"

class UserContextStatusMenu(Enum):
USER_CONTEXT_MENU_VIEW_MY_PROFILE_BUTTON: str = "userContextMenu_ViewMyProfile_Action"

class MyProfileModal(Enum):
MY_PROFILE_MODAL_USER_IMAGE: str = "myProfileModal_UserImage"

class LoginView(Enum):
LOGIN_VIEW_USER_IMAGE: str = "loginView_userImage"
PASSWORD_INPUT = "loginView_passwordInput"
SUBMIT_BTN = "loginView_submitBtn"

class StatusWelcomeScreen:

def __init__(self):
Expand Down Expand Up @@ -99,6 +116,7 @@ def input_username_and_password_and_finalize_sign_up(self, username: str, passwo
def input_username(self, username: str):
type(SignUpComponents.USERNAME_INPUT.value, username)
click_obj_by_name(SignUpComponents.DETAILS_NEXT_BUTTON.value)

# There is another page with the same Next button
click_obj_by_name(SignUpComponents.DETAILS_NEXT_BUTTON.value)

Expand Down Expand Up @@ -152,4 +170,60 @@ def validate_password_strength(self, strength: str):
verify_screenshot("VP-PWStrength-numbers_symbols_lower_upper_great")

# TODO: Get screenshots in Linux

def input_profile_image(self, profileImageUrl: str):
workflow = get_obj(SignUpComponents.PROFILE_IMAGE_CROP_WORKFLOW_ITEM.value)
workflow.cropImage(profileImageUrl)
click_obj_by_name(SignUpComponents.PROFILE_IMAGE_CROPPER_ACCEPT_BUTTON.value)

def input_username_and_grab_profile_image_sreenshot(self, username: str):
type(SignUpComponents.USERNAME_INPUT.value, username)
click_obj_by_name(SignUpComponents.DETAILS_NEXT_BUTTON.value)

# take a screenshot of the profile image to compare it later with the main screen
profileIcon = wait_and_get_obj(SignUpComponents.WELCOME_SCREEN_USER_PROFILE_IMAGE.value)
grabScreenshot_and_save(profileIcon, "profiletestimage", 200)

# There is another page with the same Next button
click_obj_by_name(SignUpComponents.DETAILS_NEXT_BUTTON.value)

def input_username_profileImage_password_and_finalize_sign_up(self, profileImageUrl: str, username: str, password: str):
self.input_profile_image(profileImageUrl)

self.input_username_and_grab_profile_image_sreenshot(username)

self.input_password(password)

self.input_confirmation_password(password)

if sys.platform == "darwin":
click_obj_by_name(SignUpComponents.PASSWORD_PREFERENCE.value)

def profile_modal_image_is_updated(self):
click_obj_by_name(MainScreenComponents.PROFILE_NAVBAR_BUTTON.value)
click_obj_by_name(UserContextStatusMenu.USER_CONTEXT_MENU_VIEW_MY_PROFILE_BUTTON.value)
imagePresent("profiletestimage", True, 97, 95, 100, True)

def profile_settings_image_is_updated(self):
# first time clicking on settings button closes the my profile modal
click_obj_by_name(MainScreen.SETTINGS_BUTTON.value)
click_obj_by_name(MainScreen.SETTINGS_BUTTON.value)
imagePresent("profiletestimage", True, 97, 100, 183, True)

def grab_screenshot(self):
# take a screenshot of the profile image to compare it later with the main screen
loginUserName = wait_and_get_obj(LoginView.LOGIN_VIEW_USER_IMAGE.value)
grabScreenshot_and_save(loginUserName, "loginUserName", 200)

def profile_image_is_updated(self):
profileNavBarButton = wait_and_get_obj(MainScreenComponents.PROFILE_NAVBAR_BUTTON.value)
imagePresent("loginUserName", True, 98, 85, 100, True)

click_obj(profileNavBarButton)
imagePresent("loginUserName", True, 99, 95, 100, True)

def enter_password(self, password):
click_obj_by_name(LoginView.PASSWORD_INPUT.value)
type(LoginView.PASSWORD_INPUT.value, password)
click_obj_by_name(LoginView.SUBMIT_BTN.value)

15 changes: 14 additions & 1 deletion test/ui-test/src/utils/FileManager.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from remotesystem import RemoteSystem
from drivers.SquishDriverVerification import *

import os
import os.path as path
import shutil
import distutils.dir_util


def erase_directory(dir: str):
directory = path.abspath(path.join(__file__, dir))
if (os.path.isdir(directory)):
Expand All @@ -27,3 +29,14 @@ def copy_directory(src: str, dst: str):
distutils.dir_util.copy_tree(src, dst)
except OSError:
os.remove(dst)

def delete_created_searchImage(fileName: str):
try:
remoteOS = RemoteSystem()
verify(remoteOS.deleteFile(fileName), "screenshot file was not deleted" + fileName)
verify(not remoteOS.exists(fileName), "screenshot file was not deleted" + fileName)
except Exception as e:
verify_failure("RemoteSystem error" + str(e))



2 changes: 2 additions & 0 deletions test/ui-test/testSuites/global_shared/scripts/bdd_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ def hook(context):
context.userData = {}
context.userData["aut_name"] = _status_desktop_app_name
context.userData["status_data_folder_path"] = _status_data_folder_path
context.userData["fixtures_root"] = os.path.join(os.path.dirname(__file__), "../../../fixtures/")
context.userData["search_images"] = os.path.join(os.path.dirname(__file__), "../shared/searchImages/")

@OnScenarioEnd
def hook(context):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
mainWindow_ScrollView = {"container": statusDesktop_mainWindow, "type": "StatusScrollView", "unnamed": 1, "visible": True}
mainWindow_ScrollView_2 = {"container": statusDesktop_mainWindow, "occurrence": 2, "type": "StatusScrollView", "unnamed": 1, "visible": True}
mainWindow_ProfileNavBarButton = {"container": statusDesktop_mainWindow, "objectName": "statusProfileNavBarTabButton", "type": "StatusNavBarTabButton", "visible": True}
settings_navbar_settings_icon_StatusIcon = {"container": mainWindow_navBarListView_ListView, "objectName": "settings-icon", "type": "StatusIcon", "visible": True}

# User Status Profile Menu
userContextMenu_ViewMyProfile_Action = {"container": statusDesktop_mainWindow_overlay, "objectName": "userStatusViewMyProfileAction", "type": "StatusMenuItemDelegate", "visible": True}

# popups
close_popup_StatusFlatRoundButton = {"container": statusDesktop_mainWindow_overlay, "id": "closeButton", "type": "StatusFlatRoundButton", "unnamed": 1, "visible": True}
Expand All @@ -18,4 +22,3 @@
chatList_Repeater = {"container": statusDesktop_mainWindow, "objectName": "chatListItems", "type": "Repeater"}
mainWindow_startChat = {"checkable": True, "container": statusDesktop_mainWindow, "objectName": "startChatButton", "type": "StatusIconTabButton"}
join_public_chat_StatusMenuItemDelegate = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "enabled": True, "text": "Join public chat", "type": "StatusMenuItemDelegate", "unnamed": 1, "visible": True}
mainWindow_statusIcon_StatusIcon_2 = {"container": statusDesktop_mainWindow, "id": "statusIcon", "source": "qrc:/StatusQ/src/assets/img/icons/public-chat.svg", "type": "StatusIcon", "unnamed": 1, "visible": True}
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
loginView_main = {"container": statusDesktop_mainWindow, "type": "LoginView", "visible": True}
loginView_errMsgLabel = {"container": statusDesktop_mainWindow, "objectName": "loginPassworkInputValidationErrorText", "type": "StatusBaseText", "visible": True}
accountsView_accountListPanel = {"container": statusDesktop_mainWindow, "type": "ListView", "visible": True} # This probably is missing an objectName
loginView_userImage = {"container": statusDesktop_mainWindow, "objectName": "loginViewUserImage", "type": "UserImage", "visible": True}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
onboarding_DetailsView_NextButton = {"container": statusDesktop_mainWindow, "objectName": "onboardingDetailsViewNextButton", "type": "StatusButton"}
mainWindow_I_prefer_to_use_my_password_StatusBaseText = {"container": statusDesktop_mainWindow, "objectName": "touchIdIPreferToUseMyPasswordText", "type": "StatusBaseText"}
mainWindow_Ok_got_it_StatusBaseText = {"container": statusDesktop_mainWindow, "type": "StatusButton", "objectName": "allowNotificationsOnboardingOkButton", "visible": True}
mainWindow_WelcomeScreen_User_Profile_Image = {"container": statusDesktop_mainWindow, "type": "StatusSmartIdenticon", "objectName": "welcomeScreenUserProfileImage"}
mainWindow_WelcomeScreen_Image_Crop_Workflow_Item= {"container": statusDesktop_mainWindow, "type": "Item", "objectName": "imageCropWorkflow"}
mainWindow_WelcomeScreen_Image_Cropper_Accept_Button= {"container": statusDesktop_mainWindow, "type": "StatusButton", "objectName": "imageCropperAcceptButton"}

# Seed phrase form:
import_a_seed_phrase_StatusBaseText = {"container": statusDesktop_mainWindow, "text": "Import a seed phrase", "type": "StatusBaseText", "unnamed": 1, "visible": True}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
from objectmaphelper import *

from scripts.onboarding_names import *
from scripts.login_names import *
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,33 @@ def step(context, seed_phrase):
def step(context):
_welcomeScreen.seed_phrase_visible()

@When("the user logs in with password |any|")
def step(context, password: str):
_welcomeScreen.enter_password(password)

@Then("the user is online")
def step(context):
_mainScreen.user_is_online()

@When("the user signs up with profileImage |any|, username |any| and password |any|")
def step(context, profileImageUrl, username, password):
_welcomeScreen.input_username_profileImage_password_and_finalize_sign_up("file:///"+context.userData["fixtures_root"]+"images/"+profileImageUrl, username, password)

@Then("my profile modal has the updated profile image")
def step(context):
_welcomeScreen.profile_modal_image_is_updated()

@Then("the profile setting has the updated profile image")
def step(context):
_welcomeScreen.profile_settings_image_is_updated()

@When("a screenshot of the profileImage is taken")
def step(context):
_welcomeScreen.grab_screenshot()

@Then("the profile navigation bar has the updated profile image")
def step(context):
_welcomeScreen.profile_image_is_updated()
delete_created_searchImage(context.userData["search_images"] +"profiletestimage.png")
delete_created_searchImage(context.userData["search_images"]+"loginUserName.png")

Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,15 @@ Feature: Status Desktop Sign Up
Scenario: After Signing up the Profile state should be online
Given A first time user lands on the status desktop and generates new key
When user signs up with username tester123 and password TesTEr16843/!@00
Then the user is online
Then the user is online

Scenario: User signs up with a profile image

Given A first time user lands on the status desktop and generates new key
When the user signs up with profileImage doggo.jpeg, username tester123 and password TesTEr16843/!@00
Then my profile modal has the updated profile image
And the profile setting has the updated profile image
When the user restarts the app
And a screenshot of the profileImage is taken
And the user logs in with password TesTEr16843/!@00
Then the profile navigation bar has the updated profile image
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from sections.chat_names import *
from sections.community_names import *
from sections.community_portal_names import *
from sections.login_names import *
from scripts.login_names import *
from sections.search_names import *
from sections.settings_names import *
from sections.wallet_names import *
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class SettingsSubsection(Enum):

# Main:
navBarListView_Settings_navbar_StatusNavBarTabButton = {"checkable": True, "container": mainWindow_navBarListView_ListView, "objectName": "Settings-navbar", "type": "StatusNavBarTabButton", "visible": True}
settings_navbar_settings_icon_StatusIcon = {"container": navBarListView_Settings_navbar_StatusNavBarTabButton, "objectName": "settings-icon", "type": "StatusIcon", "visible": True}
settingsSave_StatusButton = {"container": statusDesktop_mainWindow, "objectName": "settingsDirtyToastMessageSaveButton", "type": "StatusButton", "visible": True}
settings_Sidebar_ENS_Item = {"container": mainWindow_ScrollView, "objectName": "ENS usernames-MainMenu", "type": "StatusNavigationListItem"}

Expand Down Expand Up @@ -101,6 +100,9 @@ class SettingsSubsection(Enum):
languageView_language_ListView = {"container": languageView_language_StatusListPicker, "type": "ListView", "unnamed": 1}
languageView_language_StatusInput = {"container": languageView_language_ListView, "type": "StatusInput", "unnamed": 1}

# My Profile Modal
myProfileModal_UserImage = {"container": statusDesktop_mainWindow_overlay, "objectName": "myProfileModalUserImage", "type": "UserImage", "visible": True}

# Backup seed phrase:
backup_seed_phrase_popup_Acknowledgements_havePen_checkbox = {"container": statusDesktop_mainWindow_overlay, "objectName": "Acknowledgements_havePen", "type": "StatusCheckBox", "checkable": True, "visible": True}
backup_seed_phrase_popup_Acknowledgements_writeDown_checkbox = {"container": statusDesktop_mainWindow_overlay, "objectName": "Acknowledgements_writeDown", "type": "StatusCheckBox", "checkable": True, "visible": True}
Expand Down
1 change: 1 addition & 0 deletions ui/app/AppLayouts/Onboarding/views/InsertDetailsView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ Item {
StatusSmartIdenticon {
anchors.left: parent.left
id: userImage
objectName: "welcomeScreenUserProfileImage"
image {
width: 86
height: 86
Expand Down
1 change: 1 addition & 0 deletions ui/app/AppLayouts/Onboarding/views/LoginView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ Item {

UserImage {
id: userImage
objectName: "loginViewUserImage"
image: root.startupStore.selectedLoginAccount.thumbnailImage
name: root.startupStore.selectedLoginAccount.username
colorId: root.startupStore.selectedLoginAccount.colorId
Expand Down
Loading

0 comments on commit 8eb328b

Please sign in to comment.