diff --git a/tests/screenobjects/chats/ChatsSidebar.ts b/tests/screenobjects/chats/ChatsSidebar.ts index 89a3b4a74c..3beb25c957 100644 --- a/tests/screenobjects/chats/ChatsSidebar.ts +++ b/tests/screenobjects/chats/ChatsSidebar.ts @@ -282,9 +282,13 @@ class ChatsSidebar extends UplinkMainScreen { // Validations or assertions - async validateLastMessageDisplayed(message: string) { - const sidebarStatusValue = await this.sidebarChatsUserStatusValue; - await sidebarStatusValue.waitUntil( + async validateLastMessageDisplayed(message: string, username: string) { + const sidebarUserLocator = + await this.getExistingElementByAriaLabel(username); + const sidebarStatusValue = await sidebarUserLocator + ?.$(SELECTORS.SIDEBAR_CHATS_USER_STATUS) + .$(SELECTORS.SIDEBAR_CHATS_USER_STATUS_VALUE); + await sidebarStatusValue?.waitUntil( async () => { return (await sidebarStatusValue.getText()) === message; }, @@ -296,20 +300,28 @@ class ChatsSidebar extends UplinkMainScreen { ); } - async validateLastMessageTimeAgo() { - const timeAgo = await this.sidebarChatsUserBadgeTimeAgoValue; + async validateLastMessageTimeAgo(username: string) { + const sidebarUserLocator = + await this.getExistingElementByAriaLabel(username); + const timeAgo = await sidebarUserLocator + ?.$(SELECTORS.SIDEBAR_CHATS_USER_BADGE_TIME_AGO) + .$(SELECTORS.SIDEBAR_CHATS_USER_BADGE_TIME_AGO_VALUE); await expect(timeAgo).toHaveTextContaining( /(?:\d{1,2}\s+(?:second|minute)s?\s+ago|now)$/, ); } - async validateNoUnreadMessages() { - await this.sidebarChatsUserBadge.waitForExist({ - reverse: true, - timeout: 15000, - timeoutMsg: - "Expected badge number of unread messages is still displayed after 15 seconds", - }); + async validateNoUnreadMessages(username: string) { + const sidebarUserLocator = + await this.getExistingElementByAriaLabel(username); + await sidebarUserLocator + ?.$(SELECTORS.SIDEBAR_CHATS_USER_BADGE) + .waitForExist({ + reverse: true, + timeout: 15000, + timeoutMsg: + "Expected badge number of unread messages is still displayed after 15 seconds", + }); } async validateNoSidebarChatsAreDisplayed() { @@ -348,14 +360,22 @@ class ChatsSidebar extends UplinkMainScreen { ); } - async validateNumberOfUnreadMessages(badgeNumber: string) { - const unreadMessages = await this.sidebarChatsUserBadgeNumberValue; - await expect(unreadMessages).toHaveTextContaining(badgeNumber); + async validateNumberOfUnreadMessages(badgeNumber: string, username: string) { + const sidebarUserLocator = + await this.getExistingElementByAriaLabel(username); + const badgeNumberDisplayed = await sidebarUserLocator + ?.$(SELECTORS.SIDEBAR_CHATS_USER_BADGE_NUMBER) + .$(SELECTORS.SIDEBAR_CHATS_USER_BADGE_NUMBER_VALUE); + await expect(badgeNumberDisplayed).toHaveTextContaining(badgeNumber); } - async validateUsernameDisplayed(username: string) { - const usernameDisplayed = await this.sidebarChatsUserNameValue; - await expect(usernameDisplayed).toHaveTextContaining(username); + async validateUsernameIsDisplayed(username: string) { + const sidebarUserLocator = + await this.getExistingElementByAriaLabel(username); + const usernameDisplayed = await sidebarUserLocator + ?.$(SELECTORS.SIDEBAR_CHATS_USER_NAME) + .$(SELECTORS.SIDEBAR_CHATS_USER_NAME_VALUE); + await expect(usernameDisplayed).toHaveText(username); } async validateSidebarChatsIsShown() { diff --git a/tests/specs/reusable-accounts/08-sidebar-chats.spec.ts b/tests/specs/reusable-accounts/08-sidebar-chats.spec.ts index 7ac5dd3902..0e9961b778 100644 --- a/tests/specs/reusable-accounts/08-sidebar-chats.spec.ts +++ b/tests/specs/reusable-accounts/08-sidebar-chats.spec.ts @@ -46,7 +46,7 @@ export default async function sidebarChatsTests() { await MessageLocal.waitForMessageSentToExist("__hello__"); // Validate last message on Sidebar is not formatted with markdown - await ChatsSidebar.validateLastMessageDisplayed("__hello__"); + await ChatsSidebar.validateLastMessageDisplayed("__hello__", "ChatUserA"); }); it("Chat User A - Wait until Chat User B accepts friend request and sends a message", async () => { @@ -68,25 +68,25 @@ export default async function sidebarChatsTests() { it("Chat User A - Sidebar - Any active chats user has created should appear in Sidebar", async () => { // Validate Sidebar shows Username - await ChatsSidebar.validateUsernameDisplayed("ChatUserB"); + await ChatsSidebar.validateUsernameIsDisplayed("ChatUserB"); // Validate number of unread messages is displayed on sidebar - await ChatsSidebar.validateNumberOfUnreadMessages("1"); + await ChatsSidebar.validateNumberOfUnreadMessages("1", "ChatUserB"); // Validate time ago displayed on sidebar - await ChatsSidebar.validateLastMessageTimeAgo(); + await ChatsSidebar.validateLastMessageTimeAgo("ChatUserB"); }); it("Sidebar - Message preview on Sidebar should not display the message with markdown", async () => { // Validate last message contents on Sidebar displays hello __hello__ without applying the markdown - await ChatsSidebar.validateLastMessageDisplayed("__hello__"); + await ChatsSidebar.validateLastMessageDisplayed("__hello__", "ChatUserB"); }); it("Chat User A - Sidebar - Context Menu - Clear Unreads", async () => { // Open context menu and right click on Clear Unreads await ChatsSidebar.openContextMenuOnSidebar("ChatUserB"); await ContextMenuSidebar.selectChatsClearUnreads(); - await ChatsSidebar.validateNoUnreadMessages(); + await ChatsSidebar.validateNoUnreadMessages("ChatUserB"); }); it("Chat User A - Sidebar - Context Menu - Hide chat", async () => { 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 b7dec75aa5..feaa642dbc 100644 --- a/tests/specs/reusable-accounts/11-group-chats-sidebar.spec.ts +++ b/tests/specs/reusable-accounts/11-group-chats-sidebar.spec.ts @@ -48,12 +48,8 @@ export default async function groupChatSidebarTests() { it("Group Chats Testing - Go to another chat conversation", async () => { // Go to another chat conversation - await Topbar.goToFriends(); - await FriendsScreen.validateFriendsScreenIsShown(); - await FriendsScreen.validateChatWithFriendButtonIsShown(); - await FriendsScreen.hoverOnChatWithFriendButton("ChatUserB"); - await FriendsScreen.clickOnChatWithFriend(); - await Topbar.validateTopbarExists(); + await ChatsSidebar.goToSidebarChat("ChatUserB"); + await Topbar.validateTopbarUserName("ChatUserB"); }); it("Group Chat - Send message to the group with User B", async () => { @@ -70,24 +66,23 @@ export default async function groupChatSidebarTests() { await activateFirstApplication(); // Validate Sidebar shows Group Name - await ChatsSidebar.goToSidebarGroupChat("renamed"); - await ChatsSidebar.validateUsernameDisplayed("renamed"); + await ChatsSidebar.validateUsernameIsDisplayed("renamed"); // Validate last message content from group is displayed on sidebar - await ChatsSidebar.validateLastMessageDisplayed("HelloGroup"); + await ChatsSidebar.validateLastMessageDisplayed("HelloGroup", "renamed"); // Validate number of unread messages from the group is displayed on sidebar - await ChatsSidebar.validateNumberOfUnreadMessages("1"); + await ChatsSidebar.validateNumberOfUnreadMessages("1", "renamed"); // Validate time ago is displayed on sidebar for group chat - await ChatsSidebar.validateLastMessageTimeAgo(); + await ChatsSidebar.validateLastMessageTimeAgo("renamed"); }); it("Group Chat - Sidebar - Context Menu - Clear Unreads", async () => { // Open context menu on group chat and select Clear Unreads await ChatsSidebar.openContextMenuOnGroupChat("renamed"); await ContextMenuSidebar.selectChatsClearUnreads(); - await ChatsSidebar.validateNoUnreadMessages(); + await ChatsSidebar.validateNoUnreadMessages("renamed"); }); it("Group Chat - Sidebar - Context Menu - Hide chat", async () => {