From c23886adb396bd09112fad8e0fd05cd5a9cb3a4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Carden=CC=83a?= <35935591+luisecm@users.noreply.github.com> Date: Wed, 10 Jan 2024 16:26:37 -0600 Subject: [PATCH 1/2] test(add): add test for scroll to bottom button --- tests/screenobjects/chats/ChatsLayout.ts | 12 ++++++++++++ .../reusable-accounts/05-message-attachments.spec.ts | 9 +++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/tests/screenobjects/chats/ChatsLayout.ts b/tests/screenobjects/chats/ChatsLayout.ts index d68578730e..bad7fe74bb 100644 --- a/tests/screenobjects/chats/ChatsLayout.ts +++ b/tests/screenobjects/chats/ChatsLayout.ts @@ -11,6 +11,7 @@ const SELECTORS_COMMON = { const SELECTORS_WINDOWS = { ENCRYPTED_MESSAGES: '[name="messages-secured-alert"]', ENCRYPTED_MESSAGES_TEXT: "//Group/Text", + SCROLL_TO_BOTTOM: '//Text[@value="Scroll to bottom"]', TYPING_INDICATOR: '[name="message-typing-indicator"]', TYPING_INDICATOR_TEXT: '[name="typing-message"]', TYPING_INDICATOR_TEXT_VALUE: "", @@ -19,6 +20,8 @@ const SELECTORS_WINDOWS = { const SELECTORS_MACOS = { ENCRYPTED_MESSAGES: "~messages-secured-alert", ENCRYPTED_MESSAGES_TEXT: "-ios class chain:**/XCUIElementTypeStaticText", + SCROLL_TO_BOTTOM: + '-ios class chain:**/XCUIElementTypeStaticText[`value == "Scroll to bottom"`]', TYPING_INDICATOR: "~message-typing-indicator", TYPING_INDICATOR_TEXT: "~typing-message", TYPING_INDICATOR_TEXT_VALUE: "-ios class chain:**/XCUIElementTypeStaticText", @@ -45,6 +48,10 @@ export default class ChatsLayout extends UplinkMainScreen { return $(SELECTORS.ENCRYPTED_MESSAGES).$(SELECTORS.ENCRYPTED_MESSAGES_TEXT); } + get scrollToBottomButton() { + return this.chatLayout.$(SELECTORS.SCROLL_TO_BOTTOM); + } + get typingIndicator() { return $(SELECTORS.CHAT_LAYOUT).$(SELECTORS.TYPING_INDICATOR); } @@ -61,6 +68,11 @@ export default class ChatsLayout extends UplinkMainScreen { .$(SELECTORS.TYPING_INDICATOR_TEXT_VALUE); } + async clickOnScrollToBottom() { + const scrollToBottomButton = await this.scrollToBottomButton; + await scrollToBottomButton.click(); + } + async validateChatLayoutIsShown() { await this.chatLayout.waitForExist(); } diff --git a/tests/specs/reusable-accounts/05-message-attachments.spec.ts b/tests/specs/reusable-accounts/05-message-attachments.spec.ts index 40c5699018..a4d8739c56 100644 --- a/tests/specs/reusable-accounts/05-message-attachments.spec.ts +++ b/tests/specs/reusable-accounts/05-message-attachments.spec.ts @@ -1,4 +1,5 @@ require("module-alias/register"); +import ChatsLayout from "@screenobjects/chats/ChatsLayout"; import ComposeAttachment from "@screenobjects/chats/ComposeAttachment"; import FilesScreen from "@screenobjects/files/FilesScreen"; import InputBar from "@screenobjects/chats/InputBar"; @@ -12,6 +13,7 @@ import { } from "@helpers/commands"; const chatsAttachment = new ComposeAttachment(); const chatsInput = new InputBar(); +const chatsLayout = new ChatsLayout(); const chatsTopbar = new Topbar(); const filesScreen = new FilesScreen(); const messageLocal = new MessageLocal(); @@ -181,9 +183,12 @@ export default async function messageAttachmentsTests() { await messageLocal.waitForMessageSentToExist("Attached2"); }); - it("Send Files on Chats - Message Sent With Attachment - Attachment Contents", async () => { - await messageLocal.chatMessageFileEmbedLocal.waitForExist(); + it("User can scroll to bottom of chat conversation", async () => { + await chatsLayout.clickOnScrollToBottom(); + await messageLocal.chatMessageFileEmbedLocal.waitForDisplayed(); + }); + it("Send Files on Chats - Message Sent With Attachment - Attachment Contents", async () => { // Validate text from message containing attachment const textMessage = await messageLocal.getLastMessageSentText(); await expect(textMessage).toHaveTextContaining("Attached2"); From eb67418c64c2d50931930a03d0cdd0362f6bc7d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Carden=CC=83a?= <35935591+luisecm@users.noreply.github.com> Date: Thu, 11 Jan 2024 09:24:37 -0600 Subject: [PATCH 2/2] chore(appium): adding methods for scroll up and down on tests --- tests/helpers/commands.ts | 8 ++++++++ tests/screenobjects/chats/ChatsLayout.ts | 4 ++-- .../05-message-attachments.spec.ts | 14 +++++++++++++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/tests/helpers/commands.ts b/tests/helpers/commands.ts index df4e89b711..3c95fc5df3 100644 --- a/tests/helpers/commands.ts +++ b/tests/helpers/commands.ts @@ -310,6 +310,14 @@ export async function hoverOnMacOS(locator: WebdriverIO.Element) { ]); } +export async function scrollUp(deltaX: number) { + await mouse.scrollUp(deltaX); +} + +export async function scrollDown(deltaX: number) { + await mouse.scrollDown(deltaX); +} + export async function saveFileOnMacOS(filename: string) { // Wait for Save Dialog to be displayed const savePanel = await $("~save-panel"); diff --git a/tests/screenobjects/chats/ChatsLayout.ts b/tests/screenobjects/chats/ChatsLayout.ts index bad7fe74bb..1aaf4ac365 100644 --- a/tests/screenobjects/chats/ChatsLayout.ts +++ b/tests/screenobjects/chats/ChatsLayout.ts @@ -69,8 +69,8 @@ export default class ChatsLayout extends UplinkMainScreen { } async clickOnScrollToBottom() { - const scrollToBottomButton = await this.scrollToBottomButton; - await scrollToBottomButton.click(); + await this.scrollToBottomButton.waitForDisplayed(); + await this.scrollToBottomButton.click(); } async validateChatLayoutIsShown() { diff --git a/tests/specs/reusable-accounts/05-message-attachments.spec.ts b/tests/specs/reusable-accounts/05-message-attachments.spec.ts index a4d8739c56..bfb54b3e78 100644 --- a/tests/specs/reusable-accounts/05-message-attachments.spec.ts +++ b/tests/specs/reusable-accounts/05-message-attachments.spec.ts @@ -10,6 +10,7 @@ import Topbar from "@screenobjects/chats/Topbar"; import { launchFirstApplication, launchSecondApplication, + scrollUp, } from "@helpers/commands"; const chatsAttachment = new ComposeAttachment(); const chatsInput = new InputBar(); @@ -181,11 +182,22 @@ export default async function messageAttachmentsTests() { await chatsInput.typeMessageOnInput("Attached2"); await chatsInput.pressEnterKeyOnInputBar(); await messageLocal.waitForMessageSentToExist("Attached2"); + + // Click on last file sent timestamp to move cursor into chat conversation + const timestamp = await messageLocal.getLastMessageSentFileName(); + await timestamp.click(); }); it("User can scroll to bottom of chat conversation", async () => { + // Scroll up 1000 px to ensure that the scroll to bottom button is displayed + await scrollUp(1000); + + // Click on Scroll to Bottom button await chatsLayout.clickOnScrollToBottom(); - await messageLocal.chatMessageFileEmbedLocal.waitForDisplayed(); + + // Validate that last message is displayed again screen + const lastMessage = await messageLocal.chatMessageFileEmbedLocal; + await lastMessage.waitForDisplayed(); }); it("Send Files on Chats - Message Sent With Attachment - Attachment Contents", async () => {