You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
session-desktop/integration_test/page-objects/conversation.page.js

122 lines
5.3 KiB
JavaScript

Integration tests (#975) * add first integration test Session Checking window title Checking window count Can restore from seed * FIXME torevert once found why this crash on app close * [test] add join valid open group test * [test] validate cannot join two times the same open group * [test] move common things to common.js * [test] move tests to separate files * [test] clean * [test] add send message to open group test * [test] lint * [test] rename hooks -> common * [test] add 15s delay before considering test as slow * upgrade electron 8.0.3 and spectron 10.0.0 * [test] signin from seed: validate pubkey * Replace spellchecker in favor of typo-js * [test] refactor common calls to common.js * [test] add two different pubkey, mnemonic and displayname * [test] FIXME unsafe eval needed for now * [test] add: add friends test * [test] working multi instance tests * [test] FIXME disable snodeproxy * [test] update yarn.lock * [test] make tests more robust with restart from scratch each test * [test] add link of two devices test and hard rm of apps before start (rm -r) * remove unused file * [test] lint * [test] add registration from generated pubkey test * [test] add beginning of network stub * [test] stub "token" endpoint * [test] add test of one message on pub group pull * [test] add starting port randomize. looks to help for some bad start with multi instance * [test] add stub for one to one chats (sessions) * [test] clean code * [test] finish add friend test and stub snode server * [test] stub calls during link device test * [test] add a flag to show some logs on stubbed snode * [test] finish link of two device test. check both pubkey matches * [test] add and use function to wrap erase+start+login+stub app * [test] add method to login as friend and closed group test&messages * Revert "[test] FIXME unsafe eval needed for now" This reverts commit de5322fdae6cdab8e3b9bd9a52b7d172c9bc2d26. * [test] apply review * [test] fix lint * [test] fix existing test with new spectron version * [test] fix lint * [test] refactor page objects * [test] add delete account test * [test] add unlink of two device test * [test] make tiny waitForExists -> isExisting * [test] add checks of link new device buttons * upgrade fs-extra@9.0.0 * address pr review * [test] fix spell_check test Co-authored-by: Josh Perez <60019601+josh-signal@users.noreply.github.com>
5 years ago
const commonPage = require('./common.page');
module.exports = {
// conversation view
sessionLoader: commonPage.divWithClass('session-loader'),
leftPaneOverlay: commonPage.divWithClass('module-left-pane-overlay'),
sendMessageTextarea: commonPage.textAreaWithPlaceholder('Type your message'),
sendFriendRequestTextarea: commonPage.textAreaWithPlaceholder(
'Send your first message'
),
existingSendMessageText: textMessage =>
`//*[contains(@class, "module-message__text--outgoing")and .//span[contains(@class, "text-selectable")][contains(string(), '${textMessage}')]]`,
existingFriendRequestText: textMessage =>
`//*[contains(@class, "module-message-friend-request__container")and .//span[contains(@class, "text-selectable")][contains(string(), '${textMessage}')]]`,
existingReceivedMessageText: textMessage =>
`//*[contains(@class, "module-message__text--incoming")and .//span[contains(@class, "text-selectable")][contains(string(), '${textMessage}')]]`,
// conversations
conversationButtonSection:
'//*[contains(@class,"session-icon-button") and .//*[contains(@class, "chatBubble")]]',
retrySendButton: commonPage.divWithClassAndText(
'module-friend-request__buttonContainer--outgoing',
'Retry Send'
),
headerTitleMembers: number =>
commonPage.spanWithClassAndText(
'module-conversation-header__title-text',
`${number} members`
),
// channels
globeButtonSection:
'//*[contains(@class,"session-icon-button") and .//*[contains(@class, "globe")]]',
joinOpenGroupButton: commonPage.divRoleButtonWithText('Join Open Group'),
openGroupInputUrl: commonPage.textAreaWithPlaceholder('chat.getsession.org'),
sessionToastJoinOpenGroupSuccess: commonPage.toastWithText(
'Successfully connected to new open group server'
),
sessionToastJoinOpenGroupAlreadyExist: commonPage.toastWithText(
'You are already connected to this public channel'
),
rowOpenGroupConversationName: groupName =>
commonPage.spanWithClassAndText(
'module-conversation__user__profile-number',
groupName
),
// closed group
createClosedGroupButton: commonPage.divRoleButtonWithText(
'Create Closed Group'
),
closedGroupNameTextarea: commonPage.textAreaWithPlaceholder(
'Enter a group name'
),
createClosedGroupMemberItem: commonPage.divWithClass('session-member-item'),
createClosedGroupMemberItemSelected: commonPage.divWithClass(
'session-member-item selected'
),
validateCreationClosedGroupButton: commonPage.divRoleButtonWithText(
'Create Closed Group'
),
sessionToastGroupCreatedSuccess: commonPage.toastWithText(
'Group created successfully'
),
headerTitleGroupName: groupname =>
commonPage.spanWithClassAndText(
'module-contact-name__profile-name',
groupname
),
// contacts
contactsButtonSection:
'//*[contains(@class,"session-icon-button") and .//*[contains(@class, "users")]]',
addContactButton: commonPage.divRoleButtonWithText('Add Contact'),
sessionIDInput: commonPage.textAreaWithPlaceholder('Enter a Session ID'),
nextButton: commonPage.divRoleButtonWithText('Next'),
oneNotificationFriendRequestLeft:
'//*[contains(@class,"session-icon-button") and .//*[contains(@class, "users")] and .//*[contains(@class, "notification-count") and contains(string(), "1")] ]',
oneNotificationFriendRequestTop:
'//*[contains(@class,"contact-notification-count-bubble") and contains(string(), "1")]',
friendRequestFromUser: (displayName, pubkey) =>
`//*[contains(@class,"module-left-pane__list-popup") and .//*[contains(@class, "module-conversation__user") and .//*[contains(string(), "${displayName}")] and .//*[contains(string(), "(...${pubkey.substring(
60
)})")]]]`,
acceptFriendRequestButton:
'//*[contains(@role, "button")][contains(@class, "session-button")][contains(string(), "Accept")]',
acceptedFriendRequestMessage:
'//*[contains(@class, "module-friend-request__title")][contains(string(), "Friend request accepted")]',
// settings
settingsButtonSection:
'//*[contains(@class,"session-icon-button") and .//*[contains(@class, "gear")]]',
deviceSettingsRow:
'//*[contains(@class, "left-pane-setting-category-list-item")][contains(string(), "Devices")]',
descriptionDeleteAccount: commonPage.spanWithClassAndText(
'session-confirm-main-message',
'Are you sure you want to delete your account?'
),
validateDeleteAccount: commonPage.divRoleButtonDangerWithText('OK'),
// device pairing
noPairedDeviceMessage:
'//*[contains(@class, "session-settings-item__title")][contains(string(), "No paired devices")]',
linkDeviceButton: commonPage.divRoleButtonWithText('Link New Device'),
linkDeviceButtonDisabled: commonPage.divRoleButtonWithTextDisabled(
'Link New Device'
),
devicePairingDialog: '//*[contains(@class,"device-pairing-dialog")]',
qrImageDiv: commonPage.divWithClass('qr-image'),
allowPairingButton: commonPage.divRoleButtonWithText('Allow Pairing'),
okButton: commonPage.divRoleButtonWithText('OK'),
devicePairedDescription: secretWords =>
commonPage.divWithClassAndText(
'session-settings-item__description',
secretWords
),
unpairDeviceButton: commonPage.divRoleButtonDangerWithText('Unpair Device'),
deleteAccountButton: commonPage.divRoleButtonDangerWithText('Delete Account'),
validateUnpairDevice: commonPage.divRoleButtonDangerWithText('Unpair'),
};