Skip to content

Commit

Permalink
Merge pull request #589 from Satellite-im/luis/fixes-chats
Browse files Browse the repository at this point in the history
test(add): add test for scroll to bottom button
  • Loading branch information
luisecm authored Jan 11, 2024
2 parents 03f6ca1 + eb67418 commit c8f4e11
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
8 changes: 8 additions & 0 deletions tests/helpers/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
12 changes: 12 additions & 0 deletions tests/screenobjects/chats/ChatsLayout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: "<Text>",
Expand All @@ -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",
Expand All @@ -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);
}
Expand All @@ -61,6 +68,11 @@ export default class ChatsLayout extends UplinkMainScreen {
.$(SELECTORS.TYPING_INDICATOR_TEXT_VALUE);
}

async clickOnScrollToBottom() {
await this.scrollToBottomButton.waitForDisplayed();
await this.scrollToBottomButton.click();
}

async validateChatLayoutIsShown() {
await this.chatLayout.waitForExist();
}
Expand Down
21 changes: 19 additions & 2 deletions tests/specs/reusable-accounts/05-message-attachments.spec.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -9,9 +10,11 @@ import Topbar from "@screenobjects/chats/Topbar";
import {
launchFirstApplication,
launchSecondApplication,
scrollUp,
} 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();
Expand Down Expand Up @@ -179,11 +182,25 @@ 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("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 () => {
// 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();

// 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 () => {
// Validate text from message containing attachment
const textMessage = await messageLocal.getLastMessageSentText();
await expect(textMessage).toHaveTextContaining("Attached2");
Expand Down

0 comments on commit c8f4e11

Please sign in to comment.