Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(add): add markdowns strikethrough italics and fix code ones #653

Merged
merged 7 commits into from
Mar 8, 2024
4 changes: 3 additions & 1 deletion tests/screenobjects/chats/InputBar.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
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,
keyboardShortcutPaste,
getUplinkWindowHandle,
selectFileOnMacos,
selectFileOnWindows,
setClipboardValue,
} from "@helpers/commands";
import UplinkMainScreen from "@screenobjects/UplinkMainScreen";
let SELECTORS = {};
Expand Down Expand Up @@ -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) {
Expand Down
80 changes: 50 additions & 30 deletions tests/screenobjects/chats/MessageLocal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: "<Text>",
CHAT_MESSAGE_CODE_MESSAGES: "<Text>",
CHAT_MESSAGE_CODE_PANE: "<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"]',
Expand All @@ -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",
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
}
Expand All @@ -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 = "";
Expand All @@ -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;
}
Expand Down
92 changes: 53 additions & 39 deletions tests/screenobjects/chats/MessageRemote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: "<Text>",
CHAT_MESSAGE_CODE_MESSAGES: "<Text>",
CHAT_MESSAGE_CODE_PANE: "<Pane>",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
}
Expand All @@ -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 = "";
Expand All @@ -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;
}
Expand Down
Loading
Loading