diff --git a/tests/helpers/debugging.ts b/tests/helpers/debugging.ts index 12f02c7e4f7..353dcab3a30 100644 --- a/tests/helpers/debugging.ts +++ b/tests/helpers/debugging.ts @@ -1,40 +1,37 @@ import "module-alias/register"; import { + activateFirstApplication, + activateSecondApplication, createNewUser, - createNewUserSecondInstance, getUserKey, + launchSecondApplication, saveTestKeys, } from "./commands"; -import { USER_A_INSTANCE, USER_B_INSTANCE } from "./constants"; -import InputBar from "@screenobjects/chats/InputBar"; -import ChatsLayout from "@screenobjects/chats/ChatsLayout"; +import { USER_A_INSTANCE } from "./constants"; +import CreatePinScreen from "@screenobjects/account-creation/CreatePinScreen"; import FriendsScreen from "@screenobjects/friends/FriendsScreen"; -import Messages from "@screenobjects/chats/Messages"; -import MessageGroup from "@screenobjects/chats/MessageGroup"; -import QuickProfile from "@screenobjects/chats/QuickProfile"; import Topbar from "@screenobjects/chats/Topbar"; +import SettingsGeneralScreen from "@screenobjects/settings/SettingsGeneralScreen"; +import SettingsNotificationsScreen from "@screenobjects/settings/SettingsNotificationsScreen"; import SettingsProfileScreen from "@screenobjects/settings/SettingsProfileScreen"; import WelcomeScreen from "@screenobjects/welcome-screen/WelcomeScreen"; -let chatsInputSecondUser = new InputBar(USER_B_INSTANCE); -let chatsLayoutSecondUser = new ChatsLayout(USER_B_INSTANCE); -let chatsMessagesFirstUser = new Messages(USER_A_INSTANCE); -let chatsMessagesSecondUser = new Messages(USER_B_INSTANCE); -let chatsMessageGroupsFirstUser = new MessageGroup(USER_A_INSTANCE); -let chatsQuickProfileFirstUser = new QuickProfile(USER_A_INSTANCE); let chatsTopbarFirstUser = new Topbar(USER_A_INSTANCE); -let chatsTopbarSecondUser = new Topbar(USER_B_INSTANCE); +let createPinFirstUser = new CreatePinScreen(USER_A_INSTANCE); let friendsScreenFirstUser = new FriendsScreen(USER_A_INSTANCE); -let friendsScreenSecondUser = new FriendsScreen(USER_B_INSTANCE); +let settingsGeneralFirstUser = new SettingsGeneralScreen(USER_A_INSTANCE); +let settingsNotificationsFirstUser = new SettingsNotificationsScreen( + USER_A_INSTANCE, +); let settingsProfileFirstUser = new SettingsProfileScreen(USER_A_INSTANCE); -let settingsProfileSecondUser = new SettingsProfileScreen(USER_B_INSTANCE); let welcomeScreenFirstUser = new WelcomeScreen(USER_A_INSTANCE); -let welcomeScreenSecondUser = new WelcomeScreen(USER_B_INSTANCE); export async function setupBeforeCreateGroupTests() { + // Create a new account and go to Settings Profile + await createPinFirstUser.waitForIsShown(true); const usernameA = "ChatUserA"; await createNewUser(usernameA); await welcomeScreenFirstUser.goToSettings(); - await settingsProfileFirstUser.waitForIsShown(true); + await settingsProfileFirstUser.validateSettingsProfileIsShown(); // Click on Copy ID button and assert Toast Notification is displayed await settingsProfileFirstUser.clickOnCopyIDButton(); @@ -48,120 +45,129 @@ export async function setupBeforeCreateGroupTests() { // Grab cache folder and restart await saveTestKeys(usernameA, didkeyA, USER_A_INSTANCE); - await settingsProfileFirstUser.goToFriends(); - await friendsScreenFirstUser.waitForIsShown(true); + // Go to General Settings and reduce Font Size by 0.5 + await settingsProfileFirstUser.goToGeneralSettings(); + + // Wait for toast notification of Profile Updated to not exist + await settingsGeneralFirstUser.waitUntilNotificationIsClosed(); + + // Click on font scaling minus button + await settingsGeneralFirstUser.settingsGeneral.waitForExist(); + await settingsGeneralFirstUser.clickOnFontScalingMinus(); + + // Go to Notifications Settings and disable all notifications + await settingsGeneralFirstUser.goToNotificationsSettings(); + await settingsNotificationsFirstUser.validateSettingsNotificationsIsShown(); + await settingsNotificationsFirstUser.clickOnFriendsNotifications(); + await settingsNotificationsFirstUser.clickOnMessagesNotifications(); + + // Go to Friends Screen + await settingsNotificationsFirstUser.goToFriends(); + await friendsScreenFirstUser.validateFriendsScreenIsShown(); + + // Launch second application + await launchSecondApplication(); + + // Create a new account and go to Settings Profile + await createPinFirstUser.waitForIsShown(true); const usernameB = "ChatUserB"; - await createNewUserSecondInstance(usernameB); - await welcomeScreenSecondUser.goToSettings(); - await settingsProfileSecondUser.waitForIsShown(true); + await createNewUser(usernameB); + await welcomeScreenFirstUser.goToSettings(); + await settingsProfileFirstUser.validateSettingsProfileIsShown(); // Click on Copy ID button and assert Toast Notification is displayed - await settingsProfileSecondUser.clickOnCopyIDButton(); + await settingsProfileFirstUser.clickOnCopyIDButton(); - // Wait for toast notification to be closed - await settingsProfileSecondUser.waitUntilNotificationIsClosed(); + // Wait for toast notification of Copied To Clipboard to not exist + await settingsProfileFirstUser.waitUntilNotificationIsClosed(); // Paste copied DID Key into Status Input - await settingsProfileSecondUser.pasteUserKeyInStatus(); - const didkeyB = await settingsProfileSecondUser.getCopiedDidFromStatusInput(); + await settingsProfileFirstUser.pasteUserKeyInStatus(); + const didkeyB = await settingsProfileFirstUser.getCopiedDidFromStatusInput(); // Grab cache folder and restart - await saveTestKeys(usernameB, didkeyB, USER_B_INSTANCE); + await saveTestKeys(usernameB, didkeyB, USER_A_INSTANCE); + + // Go to General Settings and reduce Font Size by 0.5 + await settingsProfileFirstUser.goToGeneralSettings(); - await settingsProfileSecondUser.goToFriends(); + // Wait for toast notification of Profile Updated to not exist + await settingsGeneralFirstUser.waitUntilNotificationIsClosed(); + + // Click on font scaling minus button + await settingsGeneralFirstUser.settingsGeneral.waitForExist(); + await settingsGeneralFirstUser.clickOnFontScalingMinus(); + + // Go to Notifications Settings and disable all notifications + await settingsGeneralFirstUser.goToNotificationsSettings(); + await settingsNotificationsFirstUser.validateSettingsNotificationsIsShown(); + await settingsNotificationsFirstUser.clickOnFriendsNotifications(); + await settingsNotificationsFirstUser.clickOnMessagesNotifications(); + + // Go to Friends Screen + await settingsNotificationsFirstUser.goToFriends(); + await friendsScreenFirstUser.validateFriendsScreenIsShown(); - // Go to Friends - await friendsScreenSecondUser.waitForIsShown(true); // Obtain did key from Chat User B - const friendDidKey = await getUserKey("ChatUserA", USER_B_INSTANCE); - await friendsScreenSecondUser.enterFriendDidKey(friendDidKey); - await friendsScreenSecondUser.clickOnAddSomeoneButton(); + const friendDidKey = await getUserKey("ChatUserA", USER_A_INSTANCE); + await friendsScreenFirstUser.enterFriendDidKey(friendDidKey); + await friendsScreenFirstUser.clickOnAddSomeoneButton(); // Wait for toast notification to be closed - await friendsScreenSecondUser.waitUntilNotificationIsClosed(); + await friendsScreenFirstUser.waitUntilNotificationIsClosed(); // Validate friend request appears on pending list - await friendsScreenSecondUser.goToPendingFriendsList(); - const pendingList = await friendsScreenSecondUser.getOutgoingList(); - const includesFriendB = await pendingList.includes("ChatUserA"); - await expect(includesFriendB).toEqual(true); - await friendsScreenSecondUser.goToAllFriendsList(); + await friendsScreenFirstUser.hoverOnPendingListButton(); + await friendsScreenFirstUser.goToPendingFriendsList(); + await friendsScreenFirstUser.validateOutgoingListIsShown(); + await friendsScreenFirstUser.validateOutgoingListIsNotEmpty(); + + await friendsScreenFirstUser.goToAllFriendsList(); + await friendsScreenFirstUser.validateAllFriendsListIsShown(); + + // Switch control to User A + await activateFirstApplication(); // With User A - Go to pending requests list, wait for receiving the friend request and accept it + await friendsScreenFirstUser.hoverOnPendingListButton(); await friendsScreenFirstUser.goToPendingFriendsList(); + await friendsScreenFirstUser.validateIncomingListIsShown(); await friendsScreenFirstUser.waitUntilFriendRequestIsReceived(); await friendsScreenFirstUser.acceptIncomingRequest("ChatUserB"); // Validate friend is now on all friends list await friendsScreenFirstUser.goToAllFriendsList(); - const friendsListA = await friendsScreenFirstUser.getAllFriendsList(); - const includesFriendA = await friendsListA.includes("ChatUserB"); - await expect(includesFriendA).toEqual(true); + await friendsScreenFirstUser.validateAllFriendsListIsShown(); + await friendsScreenFirstUser.validateAllFriendsListIsNotEmpty(); + + // Go to Chat with User B + await friendsScreenFirstUser.chatWithFriendButton.click(); + + // Switch control to User B + await activateSecondApplication(); // With User A - Go to pending requests list, wait for receiving the friend request and accept it - await friendsScreenSecondUser.waitUntilUserAcceptedFriendRequest(); + await friendsScreenFirstUser.waitUntilUserAcceptedFriendRequest(); // Validate friend is now on all friends list - await friendsScreenSecondUser.goToAllFriendsList(); - const friendsListB = await friendsScreenSecondUser.getAllFriendsList(); - const includesFriendC = await friendsListB.includes("ChatUserA"); - await expect(includesFriendC).toEqual(true); - await friendsScreenSecondUser.goToMainScreen(); - await welcomeScreenSecondUser.waitForIsShown(true); + await friendsScreenFirstUser.goToAllFriendsList(); + await friendsScreenFirstUser.validateAllFriendsListIsShown(); + await friendsScreenFirstUser.validateAllFriendsListIsNotEmpty(); - // Go to Chat with User B - await friendsScreenFirstUser.chatWithFriendButton.click(); + // Switch control to User A + await activateFirstApplication(); await chatsTopbarFirstUser.validateTopbarExists(); - // Wait until Chat User B is online - await chatsTopbarFirstUser.waitUntilRemoteUserIsOnline(); -} + // Switch control to User B + await activateSecondApplication(); -export async function setupBeforeSidebarTests() { - await setupBeforeCreateGroupTests(); // Go to the current list of All friends and then open a Chat conversation with ChatUserA - await welcomeScreenSecondUser.switchToOtherUserWindow(); - await welcomeScreenSecondUser.goToFriends(); - await friendsScreenSecondUser.waitForIsShown(true); - await friendsScreenSecondUser.chatWithFriendButton.waitForExist(); - await friendsScreenSecondUser.hoverOnChatWithFriendButton("ChatUserA"); - await friendsScreenSecondUser.chatWithFriendButton.click(); - await chatsLayoutSecondUser.waitForIsShown(true); - await chatsTopbarSecondUser.waitUntilRemoteUserIsOnline(); - - // Send message to Chat User B - await chatsInputSecondUser.typeMessageOnInput("Accepted..."); - await chatsInputSecondUser.clickOnSendMessage(); - await chatsMessagesSecondUser.waitForMessageSentToExist("Accepted..."); - await chatsMessagesFirstUser.switchToOtherUserWindow(); - - // With User A - Validate that message was received - await chatsMessagesFirstUser.waitForReceivingMessage("Accepted..."); - - // Open quick profile from remote user - await chatsMessageGroupsFirstUser.openRemoteQuickProfile(); - await chatsQuickProfileFirstUser.waitForIsShown(true); - - // Click on Block Friend from Quick Profile - await chatsQuickProfileFirstUser.clickOnBlockUser(); - - // Welcome Screen should be displayed - await welcomeScreenFirstUser.waitForIsShown(true); - - // Get current list of Blocked friends and ensure that it includes the blocked user - await welcomeScreenFirstUser.goToFriends(); - await friendsScreenFirstUser.goToBlockedList(); - const blockedList = await friendsScreenFirstUser.getBlockedList(); - const includesFriend = await blockedList.includes("ChatUserB"); - await expect(includesFriend).toEqual(true); - await friendsScreenFirstUser.goToAllFriendsList(); - await friendsScreenFirstUser.friendsList.waitForExist(); - await chatsInputSecondUser.switchToOtherUserWindow(); - - // With User B - Go to Friends and wait for User A to remove friendship with User B - await chatsInputSecondUser.goToFriends(); - await friendsScreenSecondUser.waitForIsShown(true); - await friendsScreenSecondUser.waitUntilFriendIsRemoved("ChatUserA"); - await friendsScreenFirstUser.switchToOtherUserWindow(); + await friendsScreenFirstUser.chatWithFriendButton.waitForExist(); + await friendsScreenFirstUser.hoverOnChatWithFriendButton("ChatUserA"); + await friendsScreenFirstUser.chatWithFriendButton.click(); + await chatsTopbarFirstUser.validateTopbarExists(); + + // Switch control to User A + await activateFirstApplication(); } diff --git a/tests/screenobjects/chats/CreateGroupChat.ts b/tests/screenobjects/chats/CreateGroupChat.ts index 0ad4f578df1..291c7c5ea3d 100644 --- a/tests/screenobjects/chats/CreateGroupChat.ts +++ b/tests/screenobjects/chats/CreateGroupChat.ts @@ -1,4 +1,4 @@ -const {keyboard, Key} = require("@nut-tree/nut-js"); +const { keyboard, Key } = require("@nut-tree/nut-js"); import "module-alias/register"; import { getClipboardMacOS } from "@helpers/commands"; import { @@ -177,50 +177,6 @@ export default class CreateGroupChat extends UplinkMainScreen { await createGroupChatButton.click(); } - async getFriendFromListIndicator(username: string) { - const friendLocator = await this.getFriendFromListLocator(username); - const indicator = await friendLocator.$(SELECTORS.FRIEND_INDICATOR); - await indicator.waitForExist(); - return indicator; - } - - async getFriendFromListIndicatorOffline(username: string) { - const friendLocator = await this.getFriendFromListLocator(username); - const indicatorOffline = await friendLocator.$( - SELECTORS.FRIEND_INDICATOR_OFFLINE - ); - await indicatorOffline.waitForExist(); - return indicatorOffline; - } - - async getFriendFromListIndicatorOnline(username: string) { - const friendLocator = await this.getFriendFromListLocator(username); - await driver[this.executor].waitUntil( - async () => { - return await friendLocator.$(SELECTORS.FRIEND_INDICATOR_ONLINE); - }, - { - timeout: 15000, - timeoutMsg: - "Expected indicator online was never displayed on Create Group Users List after 15 seconds", - } - ); - - const indicatorOnline = await friendLocator.$( - SELECTORS.FRIEND_INDICATOR_ONLINE - ); - return indicatorOnline; - } - - async getFriendFromListUserImageProfile(username: string) { - const friendLocator = await this.getFriendFromListLocator(username); - const userImageProfile = await friendLocator.$( - SELECTORS.FRIEND_USER_IMAGE_PROFILE - ); - await userImageProfile.waitForExist(); - return userImageProfile; - } - async getFriendFromListLocator(username: string) { const currentDriver = await this.getCurrentDriver(); let friendLocator; @@ -231,7 +187,7 @@ export default class CreateGroupChat extends UplinkMainScreen { .$( '//XCUIElementTypeGroup[@label="friend-name"]/XCUIElementTypeStaticText[contains(@value, "' + username + - '")]/../..' + '")]/../..', ); } else if (currentDriver === WINDOWS_DRIVER) { friendLocator = await this.instance @@ -240,7 +196,7 @@ export default class CreateGroupChat extends UplinkMainScreen { .$( '//Group[@Name="friend-name"]/Text[contains(@Name, "' + username + - '")]/../..' + '")]/../..', ); } return friendLocator; @@ -253,13 +209,16 @@ export default class CreateGroupChat extends UplinkMainScreen { return userImage; } - async getFriendFromListUserImageWrap(username: string) { - const friendLocator = await this.getFriendFromListLocator(username); - const userImageWrap = await friendLocator.$( - SELECTORS.FRIEND_USER_IMAGE_WRAP - ); - await userImageWrap.waitForExist(); - return userImageWrap; + async getFriendFromListMacOS(username: string) { + const friendLocator = await this.instance + .$(SELECTORS.CREATE_GROUP_CHAT_SECTION) + .$(SELECTORS.FRIENDS_LIST) + .$( + '-ios class chain:**/XCUIElementTypeGroup/XCUIElementTypeStaticText[`value == "' + + username + + '"`]', + ); + return friendLocator; } async getFriendFromListUsername(username: string) { @@ -272,8 +231,14 @@ export default class CreateGroupChat extends UplinkMainScreen { } async selectUserFromList(username: string) { - const userLocator = await this.getFriendFromListUserImage(username); - await userLocator.click(); + const currentDriver = await this.getCurrentDriver(); + if (currentDriver === MACOS_DRIVER) { + const userLocator = await this.getFriendFromListMacOS(username); + await userLocator.click(); + } else { + const userLocator = await this.getFriendFromListUserImage(username); + await userLocator.click(); + } } async typeLongerTextInGroupName() { @@ -349,4 +314,29 @@ export default class CreateGroupChat extends UplinkMainScreen { const createGroupChatSection = await this.createGroupChatSection; await createGroupChatSection.waitForExist(); } + + async validateCreateGroupChatButtonIsShown() { + const createGroupChatButton = await this.createGroupChatButton; + await createGroupChatButton.waitForExist(); + } + + async validateCreateGroupChatFriendsListIsShown() { + const friendsList = await this.friendsList; + await friendsList.waitForExist(); + } + + async validateCreateGroupChatInputErrorIsShown() { + const createGroupInputError = await this.createGroupInputError; + await createGroupInputError.waitForExist(); + } + + async validateCreateGroupChatNameInputIsShown() { + const groupNameInput = await this.groupNameInput; + await groupNameInput.waitForExist(); + } + + async validateCreateGroupChatUserSearchInputIsShown() { + const userSearchInput = await this.userSearchInput; + await userSearchInput.waitForExist(); + } } diff --git a/tests/screenobjects/chats/EditGroup.ts b/tests/screenobjects/chats/EditGroup.ts index e2d43cf1a25..78e232f1a6b 100644 --- a/tests/screenobjects/chats/EditGroup.ts +++ b/tests/screenobjects/chats/EditGroup.ts @@ -15,6 +15,7 @@ const SELECTORS_WINDOWS = { ADD_MEMBERS: '[name="edit-group-add-members"]', ADD_PARTICIPANT_BUTTON: '[name="Add"]', CURRENT_MEMBERS: '[name="edit-group-remove-members"]', + EDIT_GROUP_MODAL: '[name="modal"]', EDIT_GROUP_SECTION: '[name="edit-group"]', FRIENDS_GROUP: '[name="friend-group"]', FRIENDS_LIST: '[name="friends-list"]', @@ -44,6 +45,7 @@ const SELECTORS_MACOS = { ADD_PARTICIPANT_BUTTON: "~Add", CURRENT_MEMBERS: "~edit-group-remove-members", CURRENT_MEMBERS_TEXT: "-ios class chain:**/XCUIElementTypeStaticText", + EDIT_GROUP_MODAL: "~modal", EDIT_GROUP_SECTION: "~edit-group", FRIENDS_GROUP: "~friend-group", FRIENDS_LIST: "~friends-list", @@ -76,36 +78,40 @@ currentOS === WINDOWS_DRIVER export default class EditGroup extends UplinkMainScreen { constructor(executor: string) { - super(executor, SELECTORS.EDIT_GROUP_SECTION); + super(executor, SELECTORS.EDIT_GROUP_MODAL); } get addMembers() { - return this.instance.$(SELECTORS.ADD_MEMBERS); + return this.editGroupSection.$(SELECTORS.ADD_MEMBERS); } get addParticipantButton() { - return this.instance + return this.editGroupSection .$(SELECTORS.EDIT_GROUP_SECTION) .$$(SELECTORS.ADD_PARTICIPANT_BUTTON); } get currentMembers() { - return this.instance.$(SELECTORS.CURRENT_MEMBERS); + return this.editGroupSection.$(SELECTORS.CURRENT_MEMBERS); + } + + get editGroupModal() { + return this.instance.$(SELECTORS.EDIT_GROUP_MODAL); } get editGroupSection() { - return this.instance.$(SELECTORS.EDIT_GROUP_SECTION); + return this.editGroupModal.$(SELECTORS.EDIT_GROUP_SECTION); } get friendsGroup() { - return this.instance + return this.editGroupSection .$(SELECTORS.EDIT_GROUP_SECTION) .$(SELECTORS.FRIENDS_LIST) .$(SELECTORS.FRIENDS_GROUP); } get friendsList() { - return this.instance + return this.editGroupSection .$(SELECTORS.EDIT_GROUP_SECTION) .$(SELECTORS.FRIENDS_LIST); } @@ -125,81 +131,81 @@ export default class EditGroup extends UplinkMainScreen { } get nothingHereText() { - return this.instance + return this.editGroupSection .$(SELECTORS.FRIENDS_LIST) .$(SELECTORS.NOTHING_HERE_TEXT); } get participantUserContainer() { - return this.instance + return this.editGroupSection .$(SELECTORS.FRIENDS_LIST) .$$(SELECTORS.PARTICIPANT_USER_CONTAINER); } get participantUserCreatorBadgeImage() { - return this.instance + return this.editGroupSection .$(SELECTORS.FRIENDS_LIST) .$$(SELECTORS.PARTICIPANT_USER_CONTAINER) .$(SELECTORS.PARTICIPANT_USER_CREATOR_BADGE_IMAGE); } get participantUserCreatorBadgeText() { - return this.instance + return this.editGroupSection .$(SELECTORS.FRIENDS_LIST) .$$(SELECTORS.PARTICIPANT_USER_CONTAINER) .$(SELECTORS.PARTICIPANT_USER_CREATOR_BADGE_TEXT); } get participantUserImage() { - return this.instance + return this.editGroupSection .$(SELECTORS.FRIENDS_LIST) .$$(SELECTORS.PARTICIPANT_USER_CONTAINER) .$(SELECTORS.PARTICIPANT_USER_IMAGE); } get participantUserImageProfile() { - return this.instance + return this.editGroupSection .$(SELECTORS.FRIENDS_LIST) .$$(SELECTORS.PARTICIPANT_USER_CONTAINER) .$(SELECTORS.PARTICIPANT_USER_IMAGE_PROFILE); } get participantUserImageWrap() { - return this.instance + return this.editGroupSection .$(SELECTORS.FRIENDS_LIST) .$$(SELECTORS.PARTICIPANT_USER_CONTAINER) .$(SELECTORS.PARTICIPANT_USER_IMAGE_WRAP); } get participantUserIndicator() { - return this.instance + return this.editGroupSection .$(SELECTORS.FRIENDS_LIST) .$$(SELECTORS.PARTICIPANT_USER_CONTAINER) .$(SELECTORS.PARTICIPANT_USER_INDICATOR); } get participantUserIndicatorOffline() { - return this.instance + return this.editGroupSection .$(SELECTORS.FRIENDS_LIST) .$$(SELECTORS.PARTICIPANT_USER_CONTAINER) .$(SELECTORS.PARTICIPANT_USER_INDICATOR_OFFLINE); } get participantUserIndicatorOnline() { - return this.instance + return this.editGroupSection .$(SELECTORS.FRIENDS_LIST) .$$(SELECTORS.PARTICIPANT_USER_CONTAINER) .$(SELECTORS.PARTICIPANT_USER_INDICATOR_ONLINE); } get participantUserName() { - return this.instance + return this.editGroupSection .$(SELECTORS.FRIENDS_LIST) .$$(SELECTORS.PARTICIPANT_USER_CONTAINER) .$(SELECTORS.PARTICIPANT_USER_NAME); } get participantUserNameText() { - return this.instance + return this.editGroupSection .$(SELECTORS.FRIENDS_LIST) .$$(SELECTORS.PARTICIPANT_USER_CONTAINER) .$(SELECTORS.PARTICIPANT_USER_NAME) @@ -207,17 +213,17 @@ export default class EditGroup extends UplinkMainScreen { } get removeParticipantButton() { - return this.instance + return this.editGroupSection .$(SELECTORS.EDIT_GROUP_SECTION) .$$(SELECTORS.REMOVE_PARTICIPANT_BUTTON); } get topbar() { - return this.instance.$$(SELECTORS.TOPBAR); + return this.editGroupSection.$(SELECTORS.TOPBAR); } get userInput() { - return this.instance.$(SELECTORS.USER_INPUT); + return this.editGroupSection.$(SELECTORS.USER_INPUT); } async clearGroupNameInput() { @@ -247,7 +253,7 @@ export default class EditGroup extends UplinkMainScreen { async clickOnFirstAddButton() { const firstAddButton = await this.instance.$$( - SELECTORS.ADD_PARTICIPANT_BUTTON + SELECTORS.ADD_PARTICIPANT_BUTTON, )[0]; await driver[this.executor].waitUntil( async () => { @@ -257,14 +263,14 @@ export default class EditGroup extends UplinkMainScreen { timeout: 15000, timeoutMsg: "Add friend button from Edit Group was never displayed after 15 seconds", - } + }, ); await firstAddButton.click(); } async clickOnFirstRemoveButton() { const removeParticipantButton = await this.instance.$$( - SELECTORS.REMOVE_PARTICIPANT_BUTTON + SELECTORS.REMOVE_PARTICIPANT_BUTTON, )[0]; await driver[this.executor].waitUntil( async () => { @@ -274,7 +280,7 @@ export default class EditGroup extends UplinkMainScreen { timeout: 15000, timeoutMsg: "Remove friend button from Edit Group was never displayed after 15 seconds", - } + }, ); await removeParticipantButton.click(); } @@ -291,6 +297,7 @@ export default class EditGroup extends UplinkMainScreen { async getParticipantsList() { const participants = await this.instance + .$(SELECTORS.EDIT_GROUP_MODAL) .$(SELECTORS.EDIT_GROUP_SECTION) .$(SELECTORS.FRIENDS_LIST) .$$(SELECTORS.PARTICIPANT_USER_CONTAINER); @@ -310,19 +317,21 @@ export default class EditGroup extends UplinkMainScreen { let locator; if (currentDriver === MACOS_DRIVER) { locator = await this.instance + .$(SELECTORS.EDIT_GROUP_MODAL) .$(SELECTORS.EDIT_GROUP_SECTION) .$( '//XCUIElementTypeGroup[@label="Friend Container"]/XCUIElementTypeGroup/XCUIElementTypeStaticText[contains(@value, "' + participant + - '")]/../..' + '")]/../..', ); } else if (currentDriver === WINDOWS_DRIVER) { locator = await this.instance + .$(SELECTORS.EDIT_GROUP_MODAL) .$(SELECTORS.EDIT_GROUP_SECTION) .$( '//Group[@Name="Friend Container"]/Group/Text[contains(@Name, "' + participant + - '")]/../..' + '")]/../..', ); } return locator; @@ -338,7 +347,7 @@ export default class EditGroup extends UplinkMainScreen { async getParticipantIndicatorOffline(participant: string) { const userLocator = await this.getParticipantContainerLocator(participant); const indicatorOffline = await userLocator.$( - SELECTORS.PARTICIPANT_USER_INDICATOR_OFFLINE + SELECTORS.PARTICIPANT_USER_INDICATOR_OFFLINE, ); await indicatorOffline.waitForExist(); return indicatorOffline; @@ -354,11 +363,11 @@ export default class EditGroup extends UplinkMainScreen { timeout: 15000, timeoutMsg: "Expected indicator online was never displayed on Edit Group Users List after 15 seconds", - } + }, ); const indicatorOnline = await userLocator.$( - SELECTORS.PARTICIPANT_USER_INDICATOR_ONLINE + SELECTORS.PARTICIPANT_USER_INDICATOR_ONLINE, ); return indicatorOnline; } @@ -366,7 +375,7 @@ export default class EditGroup extends UplinkMainScreen { async getParticipantUserCreatorBadgeImage(participant: string) { const userLocator = await this.getParticipantContainerLocator(participant); const badgeImage = await userLocator.$( - SELECTORS.PARTICIPANT_USER_CREATOR_BADGE_IMAGE + SELECTORS.PARTICIPANT_USER_CREATOR_BADGE_IMAGE, ); await badgeImage.waitForExist(); return badgeImage; @@ -375,7 +384,7 @@ export default class EditGroup extends UplinkMainScreen { async getParticipantUserCreatorBadgeText(participant: string) { const userLocator = await this.getParticipantContainerLocator(participant); const badgeText = await userLocator.$( - SELECTORS.PARTICIPANT_USER_CREATOR_BADGE_TEXT + SELECTORS.PARTICIPANT_USER_CREATOR_BADGE_TEXT, ); await badgeText.waitForExist(); return badgeText; @@ -391,7 +400,7 @@ export default class EditGroup extends UplinkMainScreen { async getParticipantUserImageProfile(participant: string) { const userLocator = await this.getParticipantContainerLocator(participant); const userImageProfile = await userLocator.$( - SELECTORS.PARTICIPANT_USER_IMAGE_PROFILE + SELECTORS.PARTICIPANT_USER_IMAGE_PROFILE, ); await userImageProfile.waitForExist(); return userImageProfile; @@ -400,7 +409,7 @@ export default class EditGroup extends UplinkMainScreen { async getParticipantUserImageWrap(participant: string) { const userLocator = await this.getParticipantContainerLocator(participant); const userImageWrap = await userLocator.$( - SELECTORS.PARTICIPANT_USER_IMAGE_WRAP + SELECTORS.PARTICIPANT_USER_IMAGE_WRAP, ); await userImageWrap.waitForExist(); return userImageWrap; @@ -432,6 +441,21 @@ export default class EditGroup extends UplinkMainScreen { await editGroupSection.waitForExist(); } + async validateEditGroupInputErrorIsShown() { + const groupNameInputError = await this.groupNameInputError; + await groupNameInputError.waitForExist(); + } + + async validateEditGroupNameInputIsShown() { + const groupNameInput = await this.groupNameInput; + await groupNameInput.waitForExist(); + } + + async validateEditGroupUserInputIsShown() { + const userInput = await this.userInput; + await userInput.waitForExist(); + } + async validateNothingHereIsDisplayed() { const nothingHereText = await this.nothingHereText; await nothingHereText.waitForExist(); @@ -445,7 +469,7 @@ export default class EditGroup extends UplinkMainScreen { { timeout: 15000, timeoutMsg: "Expected chat layout was never displayed after 15 seconds", - } + }, ); } } diff --git a/tests/screenobjects/chats/Topbar.ts b/tests/screenobjects/chats/Topbar.ts index 3189822055f..de807f80e59 100644 --- a/tests/screenobjects/chats/Topbar.ts +++ b/tests/screenobjects/chats/Topbar.ts @@ -1,7 +1,10 @@ import "module-alias/register"; import UplinkMainScreen from "@screenobjects/UplinkMainScreen"; -import { USER_A_INSTANCE, WINDOWS_DRIVER } from "@helpers/constants"; - +import { + USER_A_INSTANCE, + MACOS_DRIVER, + WINDOWS_DRIVER, +} from "@helpers/constants"; const currentOS = driver[USER_A_INSTANCE].capabilities.automationName; let SELECTORS = {}; @@ -251,7 +254,24 @@ export default class Topbar extends UplinkMainScreen { await browser.pause(1000); } - async editGroup() { + async clickOnTopbarUserImage() { + const topbarUserImage = await this.topbarUserImage; + await topbarUserImage.click(); + } + + async exitEditGroup() { + const currentDriver = await this.getCurrentDriver(); + if (currentDriver === WINDOWS_DRIVER) { + await this.hoverOnEditGroupButton(); + const topbarEditGroup = await this.topbarEditGroup; + await topbarEditGroup.click(); + } else if (currentDriver === MACOS_DRIVER) { + const editGroupModal = await $("~modal"); + await editGroupModal.click(); + } + } + + async openEditGroup() { await this.hoverOnEditGroupButton(); const topbarEditGroup = await this.topbarEditGroup; await topbarEditGroup.click(); diff --git a/tests/specs/reusable-accounts/01-create-accounts-and-friends.spec.ts b/tests/specs/reusable-accounts/01-create-accounts-and-friends.spec.ts index c540fa16b6e..d9d0d41613f 100644 --- a/tests/specs/reusable-accounts/01-create-accounts-and-friends.spec.ts +++ b/tests/specs/reusable-accounts/01-create-accounts-and-friends.spec.ts @@ -7,11 +7,7 @@ import { launchSecondApplication, saveTestKeys, } from "@helpers/commands"; -import { - USER_A_INSTANCE, - MACOS_USER_B_BUNDLE_ID, - WINDOWS_APP, -} from "@helpers/constants"; +import { USER_A_INSTANCE } from "@helpers/constants"; import ChatsLayout from "@screenobjects/chats/ChatsLayout"; import CreatePinScreen from "@screenobjects/account-creation/CreatePinScreen"; import EmojiSelector from "@screenobjects/chats/EmojiSelector"; diff --git a/tests/specs/reusable-accounts/09-group-chats.spec.ts b/tests/specs/reusable-accounts/09-group-chats.spec.ts index 6601679f32a..4b2bfbaf0a8 100644 --- a/tests/specs/reusable-accounts/09-group-chats.spec.ts +++ b/tests/specs/reusable-accounts/09-group-chats.spec.ts @@ -32,9 +32,6 @@ export default async function groupChatTests() { // Click again on create group chat and modal will be closed await chatsTopbarFirstUser.clickOnTopbar(); - await createGroupFirstUser.createGroupChatSection.waitForExist({ - reverse: true, - }); }); it("Chat User A - Create Group Chat Modal contents", async () => { @@ -43,16 +40,16 @@ export default async function groupChatTests() { await createGroupFirstUser.validateCreateGroupChatsIsShown(); // Validate contents - await createGroupFirstUser.createGroupChatButton.waitForExist(); - await createGroupFirstUser.friendsList.waitForExist(); - await createGroupFirstUser.groupNameInput.waitForExist(); - await createGroupFirstUser.userSearchInput.waitForExist(); + await createGroupFirstUser.validateCreateGroupChatButtonIsShown(); + await createGroupFirstUser.validateCreateGroupChatFriendsListIsShown(); + await createGroupFirstUser.validateCreateGroupChatNameInputIsShown(); + await createGroupFirstUser.validateCreateGroupChatUserSearchInputIsShown(); }); it("Chat User A - Attempt to create group chat with alphanumeric chars in name", async () => { // Open modal to create group chat and type alphanumeric chars in name await createGroupFirstUser.typeOnGroupName("@"); - await createGroupFirstUser.createGroupInputError.waitForExist(); + await createGroupFirstUser.validateCreateGroupChatInputErrorIsShown(); const inputErrorText = await createGroupFirstUser.createGroupInputErrorText; await expect(inputErrorText).toHaveTextContaining( "Not allowed character(s): @", @@ -63,7 +60,7 @@ export default async function groupChatTests() { it("Chat User A - Attempt to create group chat with more than 64 chars in name", async () => { // Open modal to create group chat and type more than 64 chars in name await createGroupFirstUser.typeLongerTextInGroupName(); - await createGroupFirstUser.createGroupInputError.waitForExist(); + await createGroupFirstUser.validateCreateGroupChatInputErrorIsShown(); const inputErrorText = await createGroupFirstUser.createGroupInputErrorText; await expect(inputErrorText).toHaveTextContaining( "Maximum of 64 characters exceeded.", diff --git a/tests/specs/reusable-accounts/10-group-chats-edit.spec.ts b/tests/specs/reusable-accounts/10-group-chats-edit.spec.ts index ae009c0b164..2cc9a10be19 100644 --- a/tests/specs/reusable-accounts/10-group-chats-edit.spec.ts +++ b/tests/specs/reusable-accounts/10-group-chats-edit.spec.ts @@ -26,9 +26,9 @@ export default async function groupChatEditTests() { it("Chat User A - Click on Edit Group Chat and close modal", async () => { // Open modal to edit group chat - await chatsTopbarFirstUser.editGroup(); + await chatsTopbarFirstUser.openEditGroup(); await editGroupFirstUser.validateEditGroupIsShown(); - await chatsTopbarFirstUser.editGroup(); + await chatsTopbarFirstUser.exitEditGroup(); }); it("Chat User B - You are not the group creator tooltip is displayed", async () => { @@ -43,17 +43,17 @@ export default async function groupChatEditTests() { it("Edit Group - Group Name Edit - Contents displayed", async () => { // Switch control to first user and then open edit group modal. Validate contents displayed await activateFirstApplication(); - await chatsTopbarFirstUser.editGroup(); + await chatsTopbarFirstUser.openEditGroup(); await editGroupFirstUser.validateEditGroupIsShown(); - await editGroupFirstUser.groupNameInput.waitForExist(); - await editGroupFirstUser.userInput.waitForExist(); + await editGroupFirstUser.validateEditGroupNameInputIsShown(); + await editGroupFirstUser.validateEditGroupUserInputIsShown(); }); it("Edit Group - Attempt to change Group Name for a name containing non-alphanumeric characters", async () => { // Type on group name input an invalid name and validate error message await editGroupFirstUser.typeOnGroupNameInput("@"); - await editGroupFirstUser.groupNameInputError.waitForExist(); + await editGroupFirstUser.validateEditGroupInputErrorIsShown(); const inputErrorText = await editGroupFirstUser.groupNameInputErrorText; await expect(inputErrorText).toHaveTextContaining( @@ -71,7 +71,7 @@ export default async function groupChatEditTests() { ); // Validate error message - await editGroupFirstUser.groupNameInputError.waitForExist(); + await editGroupFirstUser.validateEditGroupInputErrorIsShown(); const inputErrorText = await editGroupFirstUser.groupNameInputErrorText; await expect(inputErrorText).toHaveTextContaining( "Maximum of 64 characters exceeded.", @@ -82,7 +82,7 @@ export default async function groupChatEditTests() { it("Edit Group - Change Group Name for a valid name", async () => { // Type on group name input a valid name and validate group name is changed correctly await editGroupFirstUser.typeOnGroupNameInput("X"); - await chatsTopbarFirstUser.editGroup(); + await chatsTopbarFirstUser.exitEditGroup(); await chatsSidebarFirstUser.waitForGroupToBeCreated("X"); // Validate group name was changed correctly on local side @@ -105,7 +105,7 @@ export default async function groupChatEditTests() { // Switch control to first user and then open edit group modal. Validate contents displayed in add list are correct await activateFirstApplication(); - await chatsTopbarFirstUser.editGroup(); + await chatsTopbarFirstUser.openEditGroup(); await editGroupFirstUser.validateEditGroupIsShown(); await editGroupFirstUser.clickOnAddMembers(); await editGroupFirstUser.validateNothingHereIsDisplayed(); @@ -131,7 +131,7 @@ export default async function groupChatEditTests() { await editGroupFirstUser.typeOnSearchUserInput("ChatUserB"); await editGroupFirstUser.clickOnFirstRemoveButton(); await editGroupFirstUser.validateNothingHereIsDisplayed(); - await chatsTopbarFirstUser.editGroup(); + await chatsTopbarFirstUser.exitEditGroup(); await chatsTopbarFirstUser.validateTopbarExists(); const topbarUserStatus = chatsTopbarFirstUser.topbarUserStatusValue; @@ -148,7 +148,7 @@ export default async function groupChatEditTests() { it("Edit Group - Add Users List - Chat User B appears now in list", async () => { // Switch control to first user and then open edit group modal. Validate contents displayed in add list are correct await activateFirstApplication(); - await chatsTopbarFirstUser.editGroup(); + await chatsTopbarFirstUser.openEditGroup(); await editGroupFirstUser.validateEditGroupIsShown(); await editGroupFirstUser.clickOnAddMembers(); const currentList = await editGroupFirstUser.getParticipantsList(); @@ -167,7 +167,7 @@ export default async function groupChatEditTests() { await editGroupFirstUser.typeOnSearchUserInput("ChatUserB"); await editGroupFirstUser.clickOnFirstAddButton(); await editGroupFirstUser.validateNothingHereIsDisplayed(); - await chatsTopbarFirstUser.editGroup(); + await chatsTopbarFirstUser.exitEditGroup(); await chatsTopbarFirstUser.validateTopbarExists(); // Validate topbar contents has correct number of participants diff --git a/tests/specs/reusable-accounts/11-group-chats-sidebar.spec.ts b/tests/specs/reusable-accounts/11-group-chats-sidebar.spec.ts index 94ae8362f00..8e4f2ae0d7f 100644 --- a/tests/specs/reusable-accounts/11-group-chats-sidebar.spec.ts +++ b/tests/specs/reusable-accounts/11-group-chats-sidebar.spec.ts @@ -134,7 +134,7 @@ export default async function groupChatSidebarTests() { it("Group Chat - Add Chat User B again to the group", async () => { // Go to Edit Group and then add again Chat User B to the group - await chatsTopbarFirstUser.editGroup(); + await chatsTopbarFirstUser.openEditGroup(); await editGroupFirstUser.validateEditGroupIsShown(); await editGroupFirstUser.clickOnAddMembers(); await editGroupFirstUser.typeOnSearchUserInput("ChatUserB"); @@ -142,7 +142,7 @@ export default async function groupChatSidebarTests() { await editGroupFirstUser.validateNothingHereIsDisplayed(); // Validate topbar contents has correct number of participants - await chatsTopbarFirstUser.editGroup(); + await chatsTopbarFirstUser.exitEditGroup(); await chatsTopbarFirstUser.validateTopbarExists(); // Validate topbar contents has correct number of participants diff --git a/tests/suites/Chats/01-Chats.suite.ts b/tests/suites/Chats/01-Chats.suite.ts index 7f9a9095803..e6ee48a4ce7 100644 --- a/tests/suites/Chats/01-Chats.suite.ts +++ b/tests/suites/Chats/01-Chats.suite.ts @@ -23,9 +23,9 @@ describe("MacOS Chats Tests", function () { describe("Chat Topbar Tests", chatTopbarTests.bind(this)); describe("Quick Profile Tests", quickProfileTests.bind(this)); describe("Sidebar Chats Tests", sidebarChatsTests.bind(this)); - xdescribe("Group Chats Tests", groupChatTests.bind(this)); - xdescribe("Group Chats Edit Tests", groupChatEditTests.bind(this)); - xdescribe( + describe("Group Chats Tests", groupChatTests.bind(this)); + describe("Group Chats Edit Tests", groupChatEditTests.bind(this)); + describe( "Group Chats Favorites and Sidebar Tests", groupChatSidebarTests.bind(this), );