diff --git a/tests/screenobjects/chats/InputBar.ts b/tests/screenobjects/chats/InputBar.ts index 7da5f932cc..7bd58b42a6 100644 --- a/tests/screenobjects/chats/InputBar.ts +++ b/tests/screenobjects/chats/InputBar.ts @@ -1,5 +1,6 @@ require("module-alias/register"); import { faker } from "@faker-js/faker"; +import { keyboard } from "@nut-tree/nut-js"; import { MACOS_DRIVER, WINDOWS_DRIVER } from "@helpers/constants"; import { keyboardShiftEnter, @@ -7,6 +8,7 @@ import { getUplinkWindowHandle, selectFileOnMacos, selectFileOnWindows, + setClipboardValue, } from "@helpers/commands"; import UplinkMainScreen from "@screenobjects/UplinkMainScreen"; let SELECTORS = {}; @@ -216,7 +218,7 @@ export default class InputBar extends UplinkMainScreen { await this.typeCodeOnInputBar(language, codeToType); } else { await keyboardShiftEnter(); - await inputText.addValue(codeToType); + await keyboard.type(codeToType); let inputTextValueCode = await inputText.getText(); inputTextValueCode += " "; if (inputTextValueCode.includes(codeToType) === false) { diff --git a/tests/screenobjects/chats/MessageLocal.ts b/tests/screenobjects/chats/MessageLocal.ts index f068625abf..330248b33d 100644 --- a/tests/screenobjects/chats/MessageLocal.ts +++ b/tests/screenobjects/chats/MessageLocal.ts @@ -16,9 +16,10 @@ const SELECTORS_COMMON = {}; const SELECTORS_WINDOWS = { CHAT_MESSAGE_CODE_COPY_BUTTON: '[name="Copy"]', + CHAT_MESSAGE_CODE_LANGUAGE_GROUP: "//Group[2]/Group", CHAT_MESSAGE_CODE_LANGUAGE: "", CHAT_MESSAGE_CODE_MESSAGES: "", - CHAT_MESSAGE_CODE_PANE: "", + CHAT_MESSAGE_CODE_PANE: "//Group[1]/Group", CHAT_MESSAGE_FILE_BUTTON: '[name="attachment-button"]', CHAT_MESSAGE_FILE_EMBED: '[name="file-embed"]', CHAT_MESSAGE_FILE_ICON: '[name="file-icon"]', @@ -45,10 +46,12 @@ const SELECTORS_WINDOWS = { const SELECTORS_MACOS = { CHAT_MESSAGE_CODE_COPY_BUTTON: "-ios class chain:**/XCUIElementTypeButton", - CHAT_MESSAGE_CODE_LANGUAGE: - "//XCUIElementTypeGroup/XCUIElementTypeGroup/XCUIElementTypeStaticText", + CHAT_MESSAGE_CODE_LANGUAGE: "-ios class chain:**/XCUIElementTypeStaticText", + CHAT_MESSAGE_CODE_LANGUAGE_GROUP: + "-ios class chain:**/XCUIElementTypeGroup[2]/XCUIElementTypeGroup", CHAT_MESSAGE_CODE_MESSAGES: "-ios class chain:**/XCUIElementTypeStaticText", - CHAT_MESSAGE_CODE_PANE: "-ios class chain:**/XCUIElementTypeGroup", + CHAT_MESSAGE_CODE_PANE: + "-ios class chain:**/XCUIElementTypeGroup[1]/XCUIElementTypeGroup", CHAT_MESSAGE_FILE_BUTTON: "~attachment-button", CHAT_MESSAGE_FILE_EMBED: "~file-embed", CHAT_MESSAGE_FILE_ICON: "~file-icon", @@ -225,14 +228,12 @@ export default class MessageLocal extends UplinkMainScreen { let codeMessageLocator: string = ""; if (currentDriver === MACOS_DRIVER) { codeMessageLocator = - '//XCUIElementTypeGroup[(@label, "message-local")]//XCUIElementTypeStaticText[(@value, "' + + '//XCUIElementTypeGroup[contains(@label, "message-text-```' + expectedLanguage + '")]'; } else if (currentDriver === WINDOWS_DRIVER) { codeMessageLocator = - '//Group[(@Name, "message-local")]//Text[contains(@Name, "' + - expectedLanguage + - '")]'; + '//Group[contains(@Name, "message-text-```' + expectedLanguage + '")]'; } const codeMessage = await $(codeMessageLocator); await codeMessage.waitForExist(); @@ -297,8 +298,9 @@ export default class MessageLocal extends UplinkMainScreen { // Message Methods Using Message Custom Locator - async clickOnCopyCodeOfCustomMessageSent(expectedMessage: string) { - const copyButton = await this.getCustomMessageLocator(expectedMessage); + async clickOnCopyCodeOfCustomMessageSent(expectedLanguage: string) { + const copyButton = + await this.getCustomMessageSentCodeCopyButton(expectedLanguage); await this.hoverOnElement(copyButton); await copyButton.click(); } @@ -315,6 +317,22 @@ export default class MessageLocal extends UplinkMainScreen { return messageSent; } + async getCustomMessageLocatorCode(expectedLanguage: string) { + const currentDriver = await this.getCurrentDriver(); + let codeSentLocator: string = ""; + if (currentDriver === MACOS_DRIVER) { + codeSentLocator = + '//XCUIElementTypeGroup[contains(@label, "message-text-```' + + expectedLanguage + + '")]'; + } else if (currentDriver === WINDOWS_DRIVER) { + codeSentLocator = + '//Group[contains(@Name, "message-text-```' + expectedLanguage + '")]'; + } + const codeSent = await $(codeSentLocator); + return codeSent; + } + async getCustomMessageLocatorLink(expectedMessage: string) { const currentDriver = await this.getCurrentDriver(); let messageSentLocator: string = ""; @@ -333,43 +351,45 @@ export default class MessageLocal extends UplinkMainScreen { return messageText; } - async getCustomMessageSentCodeCopyButton(expectedMessage: string) { - const message = await this.getCustomMessageLocator(expectedMessage); - const messageCodeCopyButton = await message - .$(SELECTORS.CHAT_MESSAGE_TEXT_GROUP) - .$(SELECTORS.CHAT_MESSAGE_CODE_COPY_BUTTON); + async getCustomMessageSentCodeCopyButton(expectedLanguage: string) { + const message = await this.getCustomMessageLocatorCode(expectedLanguage); + const messageCodeCopyButton = await message.$( + SELECTORS.CHAT_MESSAGE_CODE_COPY_BUTTON, + ); await messageCodeCopyButton.waitForExist(); return messageCodeCopyButton; } - async getCustomMessageSentCodeLanguage(expectedMessage: string) { - const message = await this.getCustomMessageLocator(expectedMessage); - const messageText = await message.$(SELECTORS.CHAT_MESSAGE_TEXT_GROUP); - const messageCodeLanguage = await messageText.$( - SELECTORS.CHAT_MESSAGE_CODE_LANGUAGE, - ); + async getCustomMessageSentCodeLanguage(expectedLanguage: string) { + const message = await this.getCustomMessageLocatorCode(expectedLanguage); + const messageCodeLanguage = await message + .$(SELECTORS.CHAT_MESSAGE_CODE_LANGUAGE_GROUP) + .$(SELECTORS.CHAT_MESSAGE_CODE_LANGUAGE); await messageCodeLanguage.waitForExist(); return messageCodeLanguage; } - async getCustomMessageSentCodePane(expectedMessage: string) { - const message = await this.getCustomMessageLocator(expectedMessage); - const messageCodePane = await message - .$(SELECTORS.CHAT_MESSAGE_TEXT_GROUP) - .$(SELECTORS.CHAT_MESSAGE_CODE_PANE); + async getCustomMessageSentCodePane(expectedLanguage: string) { + const message = await this.getCustomMessageLocatorCode(expectedLanguage); + const messageCodePane = await message.$(SELECTORS.CHAT_MESSAGE_CODE_PANE); await messageCodePane.waitForExist(); return messageCodePane; } - async getCustomMessageSentCodeMessage(expectedMessage: string) { - const messageCodePane = await this.getCustomMessageLocator(expectedMessage); - let messageResult = ""; + async getCustomMessageSentCodeMessage(expectedLanguage: string) { + const messageCodePane = + await this.getCustomMessageSentCodePane(expectedLanguage); + let messageResult: string = ""; const messageResultElements = await messageCodePane.$$( SELECTORS.CHAT_MESSAGE_CODE_MESSAGES, ); for (let element of messageResultElements) { const codeMessageText = await element.getText(); - messageResult += codeMessageText; + if (codeMessageText === "=") { + messageResult += "= "; + } else { + messageResult += codeMessageText; + } } return messageResult; } diff --git a/tests/screenobjects/chats/MessageRemote.ts b/tests/screenobjects/chats/MessageRemote.ts index eba287dd7d..d8fda3e621 100644 --- a/tests/screenobjects/chats/MessageRemote.ts +++ b/tests/screenobjects/chats/MessageRemote.ts @@ -16,6 +16,7 @@ const SELECTORS_COMMON = {}; const SELECTORS_WINDOWS = { CHAT_MESSAGE_CODE_COPY_BUTTON: '[name="Copy"]', + CHAT_MESSAGE_CODE_LANGUAGE_GROUP: "//Group[2]/Group", CHAT_MESSAGE_CODE_LANGUAGE: "", CHAT_MESSAGE_CODE_MESSAGES: "", CHAT_MESSAGE_CODE_PANE: "", @@ -46,10 +47,12 @@ const SELECTORS_WINDOWS = { const SELECTORS_MACOS = { CHAT_MESSAGE_CODE_COPY_BUTTON: "-ios class chain:**/XCUIElementTypeButton", - CHAT_MESSAGE_CODE_LANGUAGE: - "//XCUIElementTypeGroup/XCUIElementTypeGroup/XCUIElementTypeStaticText", + CHAT_MESSAGE_CODE_LANGUAGE: "-ios class chain:**/XCUIElementTypeStaticText", + CHAT_MESSAGE_CODE_LANGUAGE_GROUP: + "-ios class chain:**/XCUIElementTypeGroup[2]/XCUIElementTypeGroup", CHAT_MESSAGE_CODE_MESSAGES: "-ios class chain:**/XCUIElementTypeStaticText", - CHAT_MESSAGE_CODE_PANE: "-ios class chain:**/XCUIElementTypeGroup", + CHAT_MESSAGE_CODE_PANE: + "-ios class chain:**/XCUIElementTypeGroup[1]/XCUIElementTypeGroup", CHAT_MESSAGE_FILE_BUTTON: "~attachment-button", CHAT_MESSAGE_FILE_EMBED: "~file-embed", CHAT_MESSAGE_FILE_EMBED_REMOTE: "~file-embed-remote", @@ -245,25 +248,17 @@ export default class MessageRemote extends UplinkMainScreen { async waitForReceivingCodeMessage(expectedLanguage: string) { const currentDriver = await this.getCurrentDriver(); - let codeMessageReceivedLocator: string = ""; + let codeReceivedLocator: string = ""; if (currentDriver === MACOS_DRIVER) { - codeMessageReceivedLocator = - '//XCUIElementTypeGroup[contains(@label, "remote")]//XCUIElementTypeStaticText[contains(@value, "' + + codeReceivedLocator = + '//XCUIElementTypeGroup[contains(@label, "message-text-```' + expectedLanguage + '")]'; } else if (currentDriver === WINDOWS_DRIVER) { - codeMessageReceivedLocator = - '//Group[contains(@Name, "remote")]//Text[contains(@Name, "' + - expectedLanguage + - '")]'; + codeReceivedLocator = + '//Group[contains(@Name, "message-text-```' + expectedLanguage + '")]'; } - await driver.waitUntil(async () => { - return await $(codeMessageReceivedLocator).waitForExist({ - timeout: 45000, - timeoutMsg: - "Expected message with code markdown was not found after 45 seconds", - }); - }); + await $(codeReceivedLocator).waitForExist({ timeout: 45000 }); } async waitForReceivingLink(expectedMessage: string) { @@ -300,8 +295,9 @@ export default class MessageRemote extends UplinkMainScreen { // Message Methods Using Message Custom Locator - async clickOnCopyCodeOfCustomMessageReceived(expectedMessage: string) { - const copyButton = await this.getCustomMessageLocator(expectedMessage); + async clickOnCopyCodeOfCustomMessageReceived(expectedLanguage: string) { + const copyButton = + await this.getCustomMessageReceivedCodeCopyButton(expectedLanguage); await this.hoverOnElement(copyButton); await copyButton.click(); } @@ -318,6 +314,22 @@ export default class MessageRemote extends UplinkMainScreen { return MessageReceived; } + async getCustomMessageLocatorCode(expectedLanguage: string) { + const currentDriver = await this.getCurrentDriver(); + let codeReceivedLocator: string = ""; + if (currentDriver === MACOS_DRIVER) { + codeReceivedLocator = + '//XCUIElementTypeGroup[contains(@label, "message-text-```' + + expectedLanguage + + '")]'; + } else if (currentDriver === WINDOWS_DRIVER) { + codeReceivedLocator = + '//Group[contains(@Name, "message-text-```' + expectedLanguage + '")]'; + } + const codeReceived = await $(codeReceivedLocator); + return codeReceived; + } + async getCustomMessageLocatorLink(expectedMessage: string) { const currentDriver = await this.getCurrentDriver(); let MessageReceivedLocator: string = ""; @@ -336,43 +348,45 @@ export default class MessageRemote extends UplinkMainScreen { return messageText; } - async getCustomMessageReceivedCodeCopyButton(expectedMessage: string) { - const message = await this.getCustomMessageLocator(expectedMessage); - const messageCodeCopyButton = await message - .$(SELECTORS.CHAT_MESSAGE_TEXT_GROUP) - .$(SELECTORS.CHAT_MESSAGE_CODE_COPY_BUTTON); + async getCustomMessageReceivedCodeCopyButton(expectedLanguage: string) { + const message = await this.getCustomMessageLocatorCode(expectedLanguage); + const messageCodeCopyButton = await message.$( + SELECTORS.CHAT_MESSAGE_CODE_COPY_BUTTON, + ); await messageCodeCopyButton.waitForExist(); return messageCodeCopyButton; } - async getCustomMessageReceivedCodeLanguage(expectedMessage: string) { - const message = await this.getCustomMessageLocator(expectedMessage); - const messageText = await message.$(SELECTORS.CHAT_MESSAGE_TEXT_GROUP); - const messageCodeLanguage = await messageText.$( - SELECTORS.CHAT_MESSAGE_CODE_LANGUAGE, - ); + async getCustomMessageReceivedCodeLanguage(expectedLanguage: string) { + const message = await this.getCustomMessageLocatorCode(expectedLanguage); + const messageCodeLanguage = await message + .$(SELECTORS.CHAT_MESSAGE_CODE_LANGUAGE_GROUP) + .$(SELECTORS.CHAT_MESSAGE_CODE_LANGUAGE); await messageCodeLanguage.waitForExist(); return messageCodeLanguage; } - async getCustomMessageReceivedCodePane(expectedMessage: string) { - const message = await this.getCustomMessageLocator(expectedMessage); - const messageCodePane = await message - .$(SELECTORS.CHAT_MESSAGE_TEXT_GROUP) - .$(SELECTORS.CHAT_MESSAGE_CODE_PANE); + async getCustomMessageReceivedCodePane(expectedLanguage: string) { + const message = await this.getCustomMessageLocatorCode(expectedLanguage); + const messageCodePane = await message.$(SELECTORS.CHAT_MESSAGE_CODE_PANE); await messageCodePane.waitForExist(); return messageCodePane; } - async getCustomMessageReceivedCodeMessage(expectedMessage: string) { - const messageCodePane = await this.getCustomMessageLocator(expectedMessage); - let messageResult = ""; + async getCustomMessageReceivedCodeMessage(expectedLanguage: string) { + const messageCodePane = + await this.getCustomMessageReceivedCodePane(expectedLanguage); + let messageResult: string = ""; const messageResultElements = await messageCodePane.$$( SELECTORS.CHAT_MESSAGE_CODE_MESSAGES, ); for (let element of messageResultElements) { const codeMessageText = await element.getText(); - messageResult += codeMessageText; + if (codeMessageText === "=") { + messageResult += "= "; + } else { + messageResult += codeMessageText; + } } return messageResult; } diff --git a/tests/specs/reusable-accounts/04-message-input.spec.ts b/tests/specs/reusable-accounts/04-message-input.spec.ts index 46771e3f0e..36a6b70702 100644 --- a/tests/specs/reusable-accounts/04-message-input.spec.ts +++ b/tests/specs/reusable-accounts/04-message-input.spec.ts @@ -130,39 +130,69 @@ export default async function messageInputTests() { // With Chat User A, send a message with __ markdown await chatsInput.typeMessageOnInput("__Bolds2__"); await chatsInput.clickOnSendMessage(); - await chatsInput.goToFiles(); - await filesScreen.waitForIsShown(true); - await filesScreen.goToMainScreen(); - await chatsInput.waitForIsShown(true); await messageLocal.waitForMessageSentToExist("__Bolds2__"); const messageContents = await messageLocal.getCustomMessageContents("__Bolds2__"); await expect(messageContents).toHaveText("Bolds2"); }); - // Needs research to implement on MacOS - xit("Chat Input Text - Validate users can send messages using the code language markdown", async () => { + it("Chat Input Text - Validate texts with * and _ markdown are sent in italic", async () => { + // With Chat User A, send a message with _ markdown + await chatsInput.typeMessageOnInput("_Italic1_"); + await chatsInput.clickOnSendMessage(); + await messageLocal.waitForMessageSentToExist("_Italic1_"); + const messageContentsItalicsOne = + await messageLocal.getCustomMessageContents("_Italic1_"); + await expect(messageContentsItalicsOne).toHaveText("Italic1"); + + // With Chat User A, send a message with * markdown + await chatsInput.typeMessageOnInput("*Italic2*"); + await chatsInput.clickOnSendMessage(); + await messageLocal.waitForMessageSentToExist("*Italic2*"); + const messageContentsItalicsTwo = + await messageLocal.getCustomMessageContents("*Italic2*"); + await expect(messageContentsItalicsTwo).toHaveText("Italic2"); + }); + + it("Chat Input Text - Validate texts with ~ and ~~ markdown are sent in strikethrough", async () => { + // With Chat User A, send a message with ~ markdown + await chatsInput.typeMessageOnInput("~Strikethrough1~"); + await chatsInput.clickOnSendMessage(); + await messageLocal.waitForMessageSentToExist("~Strikethrough1~"); + const messageContentsStrikethroughOne = + await messageLocal.getCustomMessageContents("~Strikethrough1~"); + await expect(messageContentsStrikethroughOne).toHaveText("Strikethrough1"); + + // With Chat User A, send a message with ~~ markdown + await chatsInput.typeMessageOnInput("~~Strikethrough2~~"); + await chatsInput.clickOnSendMessage(); + await messageLocal.waitForMessageSentToExist("~~Strikethrough2~~"); + const messageContentsStrikethroughTwo = + await messageLocal.getCustomMessageContents("~~Strikethrough2~~"); + await expect(messageContentsStrikethroughTwo).toHaveText("Strikethrough2"); + }); + + it("Chat Input Text - Validate users can send messages using the code language markdown", async () => { // With Chat User A, send a code snippet with JavaScript language - await chatsInput.typeCodeOnInputBar("javascript", "let a = 1;"); + await chatsInput.typeCodeOnInputBar("JavaScript", "let a = 1;"); await chatsInput.clickOnSendMessage(); // With Chat User A, validate code message was sent and is displayed correctly await messageLocal.waitForCodeMessageSentToExist("JavaScript"); const codeMessageTextSent = - await messageLocal.getCustomMessageSentCodeMessage("let a = 1;"); + await messageLocal.getCustomMessageSentCodeMessage("JavaScript"); await expect(codeMessageTextSent).toEqual("let a = 1;"); }); - // Needs research to implement on MacOS - xit("Chat Input Text - Code Markdown - User can copy the message from the code block", async () => { + it("Chat Input Text - Code Markdown - User can copy the message from the code block", async () => { // With Chat User A, click on the copy button from code block of last chat message sent - await messageLocal.clickOnCopyCodeOfCustomMessageSent("let a = 1;"); + await messageLocal.clickOnCopyCodeOfCustomMessageSent("JavaScript"); // Then, paste it into the input bar and assert the text contents on input bar await chatsInput.pasteClipboardOnInputBar(); const inputText = await chatsInput.getValueFromInputBar(); - await expect(inputText).toHaveText("let a = 1;"); + await expect(inputText).toEqual("let a = 1;"); // Finally, clear the input bar for next tests await chatsInput.clearInputBar(); @@ -173,23 +203,51 @@ export default async function messageInputTests() { await activateSecondApplication(); await chatsInput.waitForIsShown(true); await messageRemote.waitForReceivingMessage("**Bolds1**"); - const messageContentsBolds1 = + const messageContentsBoldsOne = await messageRemote.getCustomMessageContents("**Bolds1**"); - await expect(messageContentsBolds1).toHaveText("Bolds1"); + await expect(messageContentsBoldsOne).toHaveText("Bolds1"); // With Chat User B, validate message with with __ markdown was received in bolds await messageRemote.waitForReceivingMessage("__Bolds2__"); - const messageContentsBolds2 = + const messageContentsBoldsTwo = await messageRemote.getCustomMessageContents("__Bolds2__"); - await expect(messageContentsBolds2).toHaveText("Bolds2"); + await expect(messageContentsBoldsTwo).toHaveText("Bolds2"); + }); + + it("Chat Input Text - Validate messages with italic markdowns were received in expected format", async () => { + // With Chat User B, validate message with with _ markdown was received in italic + await messageRemote.waitForReceivingMessage("_Italic1_"); + const messageContentsItalicOne = + await messageRemote.getCustomMessageContents("_Italic1_"); + await expect(messageContentsItalicOne).toHaveText("Italic1"); + + // With Chat User B, validate message with with * markdown was received in italic + await messageRemote.waitForReceivingMessage("*Italic2*"); + const messageContentsItalicTwo = + await messageRemote.getCustomMessageContents("*Italic2*"); + await expect(messageContentsItalicTwo).toHaveText("Italic2"); + }); + + it("Chat Input Text - Validate messages with strikethrough markdowns were received in expected format", async () => { + // With Chat User B, validate message with with ~ markdown was received in Strikethrough + await chatsInput.waitForIsShown(true); + await messageRemote.waitForReceivingMessage("~Strikethrough1~"); + const messageContentsStrikethroughOne = + await messageRemote.getCustomMessageContents("~Strikethrough1~"); + await expect(messageContentsStrikethroughOne).toHaveText("Strikethrough1"); + + // With Chat User B, validate message with with ~~ markdown was received in Strikethrough + await messageRemote.waitForReceivingMessage("~~Strikethrough2~~"); + const messageContentsStrikethroughTwo = + await messageRemote.getCustomMessageContents("~~Strikethrough2~~"); + await expect(messageContentsStrikethroughTwo).toHaveText("Strikethrough2"); }); - // Needs research to implement on MacOS - xit("Chat Input Text - Validate message with code markdown is received in expected format", async () => { + it("Chat Input Text - Validate message with code markdown is received in expected format", async () => { // With Chat User B, validate code message was received and is displayed correctly await messageRemote.waitForReceivingCodeMessage("JavaScript"); const codeMessageTextReceived = - await messageRemote.getCustomMessageReceivedCodeMessage("let a = 1;"); + await messageRemote.getCustomMessageReceivedCodeMessage("JavaScript"); await expect(codeMessageTextReceived).toEqual("let a = 1;"); }); @@ -263,7 +321,7 @@ export default async function messageInputTests() { await linkEmbedReceivedIconTitle.waitForExist(); }); - // Test failing on CI + // Skipping this test since the time spent between switching windows to validate, the typing indicator is already gone xit("Typing Indicator - Send a long message to trigger typing indicator on remote side", async () => { await chatsInput.waitForIsShown(true); // Generate a random text with 100 chars @@ -272,7 +330,7 @@ export default async function messageInputTests() { await chatsInput.typeMessageOnInput(shortText + "efgh"); }); - // Test failing on CI + // Skipping this test since the time spent between switching windows to validate, the typing indicator is already gone xit("Validate Typing Indicator is displayed if remote user is typing", async () => { // Switch to second user and validate that Typing Indicator is displayed await activateFirstApplication();