diff --git a/playwright/PageObjects/ChatsMain.ts b/playwright/PageObjects/ChatsMain.ts index 85e51ecf..4ea34ffc 100644 --- a/playwright/PageObjects/ChatsMain.ts +++ b/playwright/PageObjects/ChatsMain.ts @@ -20,15 +20,11 @@ export class ChatsMainPage extends MainPage { readonly buttonMarketplace: Locator; readonly chatEncryptedMessage: Locator; readonly chatEncryptedMessageText: Locator; - readonly chatPreview: Locator; - readonly chatPreviewLastMessage: Locator; - readonly chatPreviewName: Locator; - readonly chatPreviewPicture: Locator; - readonly chatPreviewTimestamp: Locator; readonly chatbar: Locator; readonly chatbarInput: Locator; readonly chatbarInputContainer: Locator; readonly chatTopbarProfilePicture: Locator; + readonly chatTopbarProfilePictureImage: Locator; readonly chatTopbarProfileStatusIndicator: Locator; readonly chatTopbarStatus: Locator; readonly chatTopbarUsername: Locator; @@ -114,11 +110,6 @@ export class ChatsMainPage extends MainPage { this.buttonMarketplace = page.getByTestId("button-marketplace"); this.chatEncryptedMessage = page.getByTestId("chat-encrypted-notice"); this.chatEncryptedMessageText = page.getByTestId("chat-encrypted-text"); - this.chatPreview = page.getByTestId("chat-preview"); - this.chatPreviewLastMessage = page.getByTestId("chat-preview-last-message"); - this.chatPreviewName = page.getByTestId("chat-preview-name"); - this.chatPreviewPicture = page.getByTestId("chat-preview-picture"); - this.chatPreviewTimestamp = page.getByTestId("chat-preview-timestamp"); this.chatbar = page.getByTestId("chatbar"); this.chatbarInput = page .locator('[data-cy="chatbar-input"]') @@ -130,6 +121,8 @@ export class ChatsMainPage extends MainPage { this.chatTopbarProfilePicture = page.getByTestId( "chat-topbar-profile-picture", ); + this.chatTopbarProfilePictureImage = + this.chatTopbarProfilePicture.locator("img"); this.chatTopbarProfileStatusIndicator = this.chatTopbarProfilePicture.getByTestId("status-indicator"); this.chatTopbarStatus = page.getByTestId("chat-topbar-status"); diff --git a/playwright/PageObjects/MainPage.ts b/playwright/PageObjects/MainPage.ts index 6ec37e39..3c5d039d 100644 --- a/playwright/PageObjects/MainPage.ts +++ b/playwright/PageObjects/MainPage.ts @@ -16,6 +16,13 @@ export default class MainPage { readonly buttonSidebarChats: Locator; readonly buttonSidebarFiles: Locator; readonly buttonWallet: Locator; + readonly chatPreview: Locator; + readonly chatPreviewLastMessage: Locator; + readonly chatPreviewName: Locator; + readonly chatPreviewPicture: Locator; + readonly chatPreviewPictureImage: Locator; + readonly chatPreviewStatusIndicator: Locator; + readonly chatPreviewTimestamp: Locator; readonly favoriteCircle: Locator; readonly favoriteProfilePicture: Locator; readonly favoriteProfileStatusIndicator: Locator; @@ -41,6 +48,14 @@ export default class MainPage { this.buttonSidebarChats = page.getByTestId("button-sidebar-chats"); this.buttonSidebarFiles = page.getByTestId("button-sidebar-files"); this.buttonWallet = page.getByTestId("button-Wallet"); + this.chatPreview = page.getByTestId("chat-preview"); + this.chatPreviewLastMessage = page.getByTestId("chat-preview-last-message"); + this.chatPreviewName = page.getByTestId("chat-preview-name"); + this.chatPreviewPicture = page.getByTestId("chat-preview-picture"); + this.chatPreviewPictureImage = this.chatPreviewPicture.locator("img"); + this.chatPreviewStatusIndicator = + this.chatPreview.getByTestId("status-indicator"); + this.chatPreviewTimestamp = page.getByTestId("chat-preview-timestamp"); this.favoriteCircle = page.getByTestId("favorite-circle"); this.favoriteProfilePicture = page.getByTestId("favorite-profile-picture"); this.favoriteProfileStatusIndicator = @@ -140,6 +155,13 @@ export default class MainPage { return svgString.replace(/(width|height)="\d+"/g, ""); } + async openContextMenuOnChatPreview(chatName: string) { + await this.page + .getByTestId("chat-preview-name") + .filter({ hasText: chatName }) + .click({ button: "right" }); + } + async visitOtherSite(url: string) { await this.page.goto(url); } @@ -159,6 +181,10 @@ export default class MainPage { }); } + async validateNoFavoritesAreVisible() { + await this.favoriteCircle.waitFor({ state: "detached" }); + } + async validatePseudoElementContent( selector: string, expectedContent: string, diff --git a/playwright/specs/03-friends-two-instances.spec.ts b/playwright/specs/03-friends-two-instances.spec.ts index 8c76dfef..e02615a5 100644 --- a/playwright/specs/03-friends-two-instances.spec.ts +++ b/playwright/specs/03-friends-two-instances.spec.ts @@ -333,7 +333,7 @@ test.describe("Friends tests", () => { await friendsScreenFirst.validateNoIncomingRequestsExist(); }); - test.afterAll(async ({ page1, page2 }) => { + test.afterEach(async ({ page1, page2 }) => { await page1.close(); await page2.close(); }); diff --git a/playwright/specs/05-chats-sidebar.spec.ts b/playwright/specs/05-chats-sidebar.spec.ts index bb014b3a..d25ee26f 100644 --- a/playwright/specs/05-chats-sidebar.spec.ts +++ b/playwright/specs/05-chats-sidebar.spec.ts @@ -153,69 +153,4 @@ test.describe("Chats Sidebar Tests", () => { "rgb(77, 77, 255) 0px 0px 0px 1px", ); }); - - /* - // Cannot be automated until app is wired - test.skip("C11 - ProfilePicFrame should display for any friends that have one", async ({ - page, - }) => { - // Test code for C11 - }); - - // Cannot be automated until app is wired - test.skip("C12 - Favorites should appear on left side of Sidebar", async ({ - page, - }) => { - // Test code for C12 - }); - - // Cannot be automated until app is wired - test.skip("C13 - Number of members in group should appear on that chat in both Sidebar and Favorites", async ({ - page, - }) => { - // Test code for C13 - }); - - // Cannot be automated until app is wired - test.skip("C14 - Clicking a favorite should take you to that chat", async ({ - page, - }) => { - // Test code for C14 - }); - - // Cannot be automated until app is wired - test.skip("C15 - Right clicking a chat in sidebar should open context menu", async ({ - page, - }) => { - // Test code for C15 - }); - - // Cannot be automated until app is wired - test.skip("C16 - Context menu should display: Favorite, Hide, Mark as read", async ({ - page, - }) => { - // Test code for C16 - }); - - // Cannot be automated until app is wired - test.skip("C17 - Timestamp of most recent message sent or received in chat should be displayed in the sidebar", async ({ - page, - }) => { - // Test code for C17 - }); - - // Cannot be automated until app is wired - test.skip("C18 - Typing indicator should be displayed around users profile picture when they are typing (this applies to favorites as well)", async ({ - page, - }) => { - // Test code for C18 - }); - - // Cannot be automated until app is wired - test.skip("C19 - After selecting Hide chat chat should no longer be displayed in sidebar", async ({ - page, - }) => { - // Test code for C19 - }); - */ }); diff --git a/playwright/specs/22-chats-tests.spec.ts b/playwright/specs/22-chats-tests.spec.ts index 2c1e2f1c..1ae51255 100644 --- a/playwright/specs/22-chats-tests.spec.ts +++ b/playwright/specs/22-chats-tests.spec.ts @@ -13,18 +13,12 @@ test.describe("Chats Tests - Two instances", () => { authNewAccountSecond, chatsMainPageFirst, chatsMainPageSecond, - context1, - context2, createOrImportFirst, createOrImportSecond, loginPinPageFirst, loginPinPageSecond, saveRecoverySeedFirst, saveRecoverySeedSecond, - friendsScreenFirst, - friendsScreenSecond, - page1, - page2, }) => { // Start browser one await createOrImportFirst.navigateTo(); @@ -50,7 +44,6 @@ test.describe("Chats Tests - Two instances", () => { // B1 - User should land on this page after logging in - Validated during account creation tests // B2 - Clicking "Add Friends" should navigate you to Friends page - await page1.waitForURL("/chat"); await chatsMainPageFirst.buttonAddFriends.click(); // Now with the second user, click on Create New Account @@ -71,70 +64,59 @@ test.describe("Chats Tests - Two instances", () => { // B1 - User should land on this page after logging in - Validated during account creation tests // B2 - Clicking "Add Friends" should navigate you to Friends page - await page2.waitForURL("/chat"); await chatsMainPageSecond.buttonAddFriends.click(); - - // Grant clipboard permissions, Copy DID and save it into a constant - await context1.grantPermissions(["clipboard-read", "clipboard-write"]); - await friendsScreenFirst.copyDIDFromContextMenu(); - const handle = await page1.evaluateHandle(() => - navigator.clipboard.readText(), - ); - const didKeyFirstUser = await handle.jsonValue(); - - // Grant clipboard permissions, Copy DID and save it into a constant - await context2.grantPermissions(["clipboard-read", "clipboard-write"]); - await friendsScreenSecond.copyDIDFromContextMenu(); - const handleTwo = await page2.evaluateHandle(() => - navigator.clipboard.readText(), - ); - const didKeySecondUser = await handleTwo.jsonValue(); - - // Now, add the first user as a friend - await friendsScreenSecond.addFriend(didKeyFirstUser); - await friendsScreenSecond.validateToastRequestSent(); - await friendsScreenFirst.waitForToastNotificationToDisappear(); - await friendsScreenSecond.waitForToastNotificationToDisappear(); - - // With First User, go to requests list and accept friend request - await friendsScreenFirst.goToRequestList(); - await friendsScreenFirst.validateIncomingRequestExists(); - await friendsScreenFirst.acceptFriendRequest( - usernameTwo, - didKeySecondUser, - ); - - // With First User, go to All Friends - await friendsScreenFirst.goToAllFriendsList(); - - // With Second User, go to All Friends and click on Remove Friend button - await friendsScreenSecond.goToRequestList(); - await friendsScreenSecond.goToAllFriendsList(); - - // Validate Friend List is displayed for letter "C" - await friendsScreenSecond.validateFriendListIsDisplayed("C"); - let currentFriendsSecondUser = - await friendsScreenSecond.getListOfCurrentFriends(); - expect(currentFriendsSecondUser).toEqual([username]); }, ); test("B1 to B6, B16 and B17, B35 to B37 - Landing to Chats Page elements and basic send/receive text message flow", async ({ chatsMainPageFirst, chatsMainPageSecond, + context1, + context2, friendsScreenFirst, friendsScreenSecond, page1, page2, }) => { - // With first user, go to chat conversation with remote user + // Grant clipboard permissions, Copy DID and save it into a constant + await context1.grantPermissions(["clipboard-read", "clipboard-write"]); + await friendsScreenFirst.copyDIDFromContextMenu(); + const handle = await page1.evaluateHandle(() => + navigator.clipboard.readText(), + ); + const didKeyFirstUser = await handle.jsonValue(); + + // Grant clipboard permissions, Copy DID and save it into a constant + await context2.grantPermissions(["clipboard-read", "clipboard-write"]); + await friendsScreenSecond.copyDIDFromContextMenu(); + const handleTwo = await page2.evaluateHandle(() => + navigator.clipboard.readText(), + ); + const didKeySecondUser = await handleTwo.jsonValue(); + + // Now, add the first user as a friend + await friendsScreenSecond.addFriend(didKeyFirstUser); + + // Toast Notification with Your request is making it's way! should appear after sending a friend request + await friendsScreenSecond.validateToastRequestSent(); + await friendsScreenSecond.waitForToastNotificationToDisappear(); + await friendsScreenFirst.waitForToastNotificationToDisappear(); + + // With First User, go to requests list and accept friend request + await friendsScreenFirst.goToRequestList(); + await friendsScreenFirst.validateIncomingRequestExists(); + await friendsScreenFirst.acceptFriendRequest(usernameTwo, didKeySecondUser); + + // With First User, go to All Friends and click on Chat Button + await friendsScreenFirst.goToAllFriendsList(); await friendsScreenFirst.chatWithFriend(usernameTwo); - // With second user, go to chat conversation with remote user and send a message + // With Second User, go to All Friends and click on Chat Button + await friendsScreenSecond.goToRequestList(); + await friendsScreenSecond.goToAllFriendsList(); await friendsScreenSecond.chatWithFriend(username); // B3 - Messages are secured by end-to-end encryption, sent over a peer-to-peer network should be displayed at the top of every chat - await page2.waitForURL("/chat"); await expect(chatsMainPageSecond.chatEncryptedMessage).toBeVisible(); await expect(chatsMainPageSecond.chatEncryptedMessageText).toHaveText( "Messages are secured by end-to-end encryption, sent over a peer-to-peer network.", @@ -188,7 +170,6 @@ test.describe("Chats Tests - Two instances", () => { ); // Validate message is displayed on remote user - await page1.waitForURL("/chat"); await chatsMainPageFirst.validateMessageIsReceived( "Hello from the second user", ); @@ -229,11 +210,50 @@ test.describe("Chats Tests - Two instances", () => { test("B7, B57, B58 - Favorites tests", async ({ chatsMainPageFirst, + context1, + context2, filesPageFirst, friendsScreenFirst, friendsScreenSecond, page1, + page2, }) => { + // Grant clipboard permissions, Copy DID and save it into a constant + await context1.grantPermissions(["clipboard-read", "clipboard-write"]); + await friendsScreenFirst.copyDIDFromContextMenu(); + const handle = await page1.evaluateHandle(() => + navigator.clipboard.readText(), + ); + const didKeyFirstUser = await handle.jsonValue(); + + // Grant clipboard permissions, Copy DID and save it into a constant + await context2.grantPermissions(["clipboard-read", "clipboard-write"]); + await friendsScreenSecond.copyDIDFromContextMenu(); + const handleTwo = await page2.evaluateHandle(() => + navigator.clipboard.readText(), + ); + const didKeySecondUser = await handleTwo.jsonValue(); + + // Now, add the first user as a friend + await friendsScreenSecond.addFriend(didKeyFirstUser); + + // Toast Notification with Your request is making it's way! should appear after sending a friend request + await friendsScreenSecond.validateToastRequestSent(); + await friendsScreenSecond.waitForToastNotificationToDisappear(); + await friendsScreenFirst.waitForToastNotificationToDisappear(); + + // With First User, go to requests list and accept friend request + await friendsScreenFirst.goToRequestList(); + await friendsScreenFirst.validateIncomingRequestExists(); + await friendsScreenFirst.acceptFriendRequest(usernameTwo, didKeySecondUser); + + // With First User, go to All Friends and click on Chat Button + await friendsScreenFirst.goToAllFriendsList(); + + // With Second User, go to All Friends and click on Chat Button + await friendsScreenSecond.goToRequestList(); + await friendsScreenSecond.goToAllFriendsList(); + // With first user, go to chat conversation with remote user await friendsScreenFirst.chatWithFriend(usernameTwo); @@ -254,23 +274,140 @@ test.describe("Chats Tests - Two instances", () => { "color(srgb 0.371765 0.371765 1)", ); - // Favorite Circle should be displayed on left + // C12 - Favorites should appear on left side of Sidebar await expect(chatsMainPageFirst.favoriteCircle).toBeVisible(); await expect(chatsMainPageFirst.favoriteProfilePicture).toBeVisible(); - await expect( - chatsMainPageFirst.favoriteProfileStatusIndicator, - ).toBeVisible(); + await expect(chatsMainPageFirst.favoriteProfileStatusIndicator).toHaveClass( + /.*\bonline\b.*/, + ); // B57 - User can go to Conversation with remote user by clicking on Favorites Circle + // C14 - Clicking a favorite should take you to that chat await chatsMainPageFirst.goToFiles(); - await page1.waitForURL("/files"); await filesPageFirst.favoriteProfilePicture.click(); - await page1.waitForURL("/chat"); await expect(chatsMainPageFirst.chatTopbarUsername).toHaveText(usernameTwo); // B58 - User can remove Favorites and these will not be displayed on Slimbar await chatsMainPageFirst.buttonChatFavorite.click(); - await chatsMainPageFirst.favoriteCircle.waitFor({ state: "detached" }); + await chatsMainPageFirst.validateNoFavoritesAreVisible(); + }); + + test("C11, C12, C16, C17 and C19 - Chat Sidebar tests", async ({ + chatsMainPageFirst, + chatsMainPageSecond, + context1, + context2, + friendsScreenFirst, + friendsScreenSecond, + page1, + page2, + }) => { + // Testing timestamp with Clock API + await page1.clock.install(); + + // Grant clipboard permissions, Copy DID and save it into a constant + await context1.grantPermissions(["clipboard-read", "clipboard-write"]); + await friendsScreenFirst.copyDIDFromContextMenu(); + const handle = await page1.evaluateHandle(() => + navigator.clipboard.readText(), + ); + const didKeyFirstUser = await handle.jsonValue(); + + // Grant clipboard permissions, Copy DID and save it into a constant + await context2.grantPermissions(["clipboard-read", "clipboard-write"]); + await friendsScreenSecond.copyDIDFromContextMenu(); + const handleTwo = await page2.evaluateHandle(() => + navigator.clipboard.readText(), + ); + const didKeySecondUser = await handleTwo.jsonValue(); + + // Now, add the first user as a friend + await friendsScreenSecond.addFriend(didKeyFirstUser); + + // Toast Notification with Your request is making it's way! should appear after sending a friend request + await friendsScreenSecond.validateToastRequestSent(); + await friendsScreenSecond.waitForToastNotificationToDisappear(); + await friendsScreenFirst.waitForToastNotificationToDisappear(); + + // With First User, go to requests list and accept friend request + await friendsScreenFirst.goToRequestList(); + await friendsScreenFirst.validateIncomingRequestExists(); + await friendsScreenFirst.acceptFriendRequest(usernameTwo, didKeySecondUser); + + // With First User, go to All Friends and click on Chat Button + await friendsScreenFirst.goToAllFriendsList(); + + // With Second User, go to All Friends and click on Chat Button + await friendsScreenSecond.goToRequestList(); + await friendsScreenSecond.goToAllFriendsList(); + + // With first user, go to chat conversation with remote user + await friendsScreenFirst.chatWithFriend(usernameTwo); + + // With second user, go to chat conversation with remote user and send a message + await friendsScreenSecond.chatWithFriend(username); + + // Validate chat preview is displayed on sidebar - Default values when no messages have been sent + // C11 - ProfilePicFrame should display for any friends that have one + const chatPreviewImageURL = + await chatsMainPageFirst.chatPreviewPictureImage.getAttribute("src"); + const topbarImageURL = + await chatsMainPageFirst.chatTopbarProfilePictureImage.getAttribute( + "src", + ); + await expect(chatsMainPageFirst.chatPreview).toBeVisible(); + await expect(chatsMainPageFirst.chatPreviewPicture).toBeVisible(); + await expect(chatsMainPageFirst.chatPreviewName).toHaveText(usernameTwo); + await expect(chatsMainPageFirst.chatPreviewStatusIndicator).toHaveClass( + /.*\bonline\b.*/, + ); + await expect(chatsMainPageFirst.chatPreviewLastMessage).toHaveText( + "No messages sent yet.", + ); + expect(chatPreviewImageURL).toEqual(topbarImageURL); + + // Send a message from user two to first user + await chatsMainPageSecond.sendMessage("Hello from the second user"); + await chatsMainPageSecond.validateMessageIsSent( + "Hello from the second user", + ); + + // Validate message is displayed on remote user + await chatsMainPageFirst.validateMessageIsReceived( + "Hello from the second user", + ); + + // Validate Chat Sidebar is updated with most recent message on both sides local and remote + await expect(chatsMainPageFirst.chatPreviewLastMessage).toHaveText( + "Hello from the second user", + ); + await expect(chatsMainPageSecond.chatPreviewLastMessage).toHaveText( + "Hello from the second user", + ); + + // C15 - Right clicking a chat in sidebar should open context menu + // C16 - Context menu should display: Favorite, Hide, Mark as read + await chatsMainPageFirst.openContextMenuOnChatPreview(usernameTwo); + + // C12 - Favorites should appear on left side of Sidebar when selecting from Context Menu - Favorite + await chatsMainPageFirst.contextMenuOptionFavorite.click(); + await expect(chatsMainPageFirst.favoriteCircle).toBeVisible(); + await expect(chatsMainPageFirst.favoriteProfilePicture).toBeVisible(); + await expect(chatsMainPageFirst.favoriteProfileStatusIndicator).toHaveClass( + /.*\bonline\b.*/, + ); + + // Unfavorite user from Context Menu and validate remote user is removed from favorites + await chatsMainPageFirst.openContextMenuOnChatPreview(usernameTwo); + await chatsMainPageFirst.contextMenuOptionFavorite.click(); + await chatsMainPageFirst.validateNoFavoritesAreVisible(); + + // C17 - Timestamp of most recent message sent or received in chat should be displayed in the sidebar - Not working correctly + // Fast forward clock for 30 minutes and validate message was sent 30 minutes ago + // await page1.clock.fastForward("30:00"); + // await page1.getByText("30 minutes ago").waitFor({ state: "visible" }); + + // C19 - After selecting Hide chat chat should no longer be displayed in sidebar }); test.skip("B8 to B14 - Quick Profile tests", async ({ page }) => { @@ -287,15 +424,16 @@ test.describe("Chats Tests - Two instances", () => { test.skip("B15 and B26 to B34 - Group Chats Tests", async ({ page }) => { // Group chats not implemented yet // B15 - Clicking Groups button should display group members of the chat - // B26 - Clicking the X next to a friend in the GroupMembers Modal should remove friend from groupchat", async ({ - // B27 - Clicking the Settings button should open the Group Chat Settings", async ({ - // B28 - Highlighted border should appear after clicking into the GroupName input box in GroupChat Settings", async ({ - // B29 - User can change name of the group", async ({ page }) => { - // B30 - Highlighted border should appear after clicking into the GroupDescription input box in GroupChat Settings", async ({ - // B31 - User should be able to edit the description of the group", async ({ - // B32 - User can toggle on/off Add Members", async ({ page }) => { - // B33 - User can toggle on/off ChangePhoto", async ({ page }) => { - // B34 - User can toggle on/off Change Details", async ({ + // B26 - Clicking the X next to a friend in the GroupMembers Modal should remove friend from groupchat + // B27 - Clicking the Settings button should open the Group Chat Settings + // B28 - Highlighted border should appear after clicking into the GroupName input box in GroupChat Settings + // B29 - User can change name of the group + // B30 - Highlighted border should appear after clicking into the GroupDescription input box in GroupChat Settings + // B31 - User should be able to edit the description of the group + // B32 - User can toggle on/off Add Members + // B33 - User can toggle on/off ChangePhoto + // B34 - User can toggle on/off Change Details + // C13 - Number of members in group should appear on that chat in both Sidebar and Favorites }); test.skip("B18 and B19, B23 to B25 - Chats Context Menu tests", async ({ @@ -337,6 +475,7 @@ test.describe("Chats Tests - Two instances", () => { test.skip("B48 - Typing indicator tests", async ({ page }) => { // B48 - The chat typing indicator should be displayed when user is typing + // C18 - Typing indicator should be displayed around users profile picture when they are typing (this applies to favorites as well) }); test.skip("B49 - Scroll to bottom button tests", async ({ page }) => { @@ -363,11 +502,49 @@ test.describe("Chats Tests - Two instances", () => { test("B56 - Chats Tests - Multiple messages testing", async ({ chatsMainPageFirst, chatsMainPageSecond, + context1, + context2, friendsScreenFirst, friendsScreenSecond, page1, page2, }) => { + // Grant clipboard permissions, Copy DID and save it into a constant + await context1.grantPermissions(["clipboard-read", "clipboard-write"]); + await friendsScreenFirst.copyDIDFromContextMenu(); + const handle = await page1.evaluateHandle(() => + navigator.clipboard.readText(), + ); + const didKeyFirstUser = await handle.jsonValue(); + + // Grant clipboard permissions, Copy DID and save it into a constant + await context2.grantPermissions(["clipboard-read", "clipboard-write"]); + await friendsScreenSecond.copyDIDFromContextMenu(); + const handleTwo = await page2.evaluateHandle(() => + navigator.clipboard.readText(), + ); + const didKeySecondUser = await handleTwo.jsonValue(); + + // Now, add the first user as a friend + await friendsScreenSecond.addFriend(didKeyFirstUser); + + // Toast Notification with Your request is making it's way! should appear after sending a friend request + await friendsScreenSecond.validateToastRequestSent(); + await friendsScreenSecond.waitForToastNotificationToDisappear(); + await friendsScreenFirst.waitForToastNotificationToDisappear(); + + // With First User, go to requests list and accept friend request + await friendsScreenFirst.goToRequestList(); + await friendsScreenFirst.validateIncomingRequestExists(); + await friendsScreenFirst.acceptFriendRequest(usernameTwo, didKeySecondUser); + + // With First User, go to All Friends and click on Chat Button + await friendsScreenFirst.goToAllFriendsList(); + + // With Second User, go to All Friends and click on Chat Button + await friendsScreenSecond.goToRequestList(); + await friendsScreenSecond.goToAllFriendsList(); + // With first user, go to chat conversation with remote user await friendsScreenFirst.chatWithFriend(usernameTwo); @@ -375,8 +552,6 @@ test.describe("Chats Tests - Two instances", () => { await friendsScreenSecond.chatWithFriend(username); // Validate second user is in chats page and send 20 messages - await page2.waitForURL("/chat"); - await page1.waitForURL("/chat"); for (let i = 0; i < 20; i++) { const randomSentence = faker.lorem.sentence(3); await chatsMainPageSecond.sendMessage(randomSentence); @@ -388,4 +563,9 @@ test.describe("Chats Tests - Two instances", () => { ); } }); + + test.afterEach(async ({ page1, page2 }) => { + await page1.close(); + await page2.close(); + }); });