Skip to content

Commit

Permalink
test(update): attempt to fix skipped chats tests
Browse files Browse the repository at this point in the history
  • Loading branch information
luisecm committed Feb 27, 2024
1 parent ae7878c commit e2091db
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 52 deletions.
4 changes: 4 additions & 0 deletions tests/helpers/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,10 @@ export async function hoverOnMacOS(locator: WebdriverIO.Element) {
]);
}

export async function setClipboardValue(value: string) {
await clipboard.setContent(value);
}

export async function scrollUp(deltaX: number) {
await mouse.scrollUp(deltaX);
}
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 @@ -9,6 +9,8 @@ const SELECTORS_COMMON = {
};

const SELECTORS_WINDOWS = {
CHATBAR_INPUT_ERROR: '[name="chatbar-input-error"]',
CHATBAR_INPUT_ERROR_TEXT: "<Text>",
ENCRYPTED_MESSAGES: '[name="messages-secured-alert"]',
ENCRYPTED_MESSAGES_TEXT: "//Group/Text",
SCROLL_TO_BOTTOM: '//Text[@Name="Scroll to bottom"]',
Expand All @@ -18,6 +20,8 @@ const SELECTORS_WINDOWS = {
};

const SELECTORS_MACOS = {
CHATBAR_INPUT_ERROR: "~chatbar-input-error",
CHATBAR_INPUT_ERROR_TEXT: "-ios class chain:**/XCUIElementTypeStaticText",
ENCRYPTED_MESSAGES: "~messages-secured-alert",
ENCRYPTED_MESSAGES_TEXT: "-ios class chain:**/XCUIElementTypeStaticText",
SCROLL_TO_BOTTOM:
Expand All @@ -36,6 +40,14 @@ export default class ChatsLayout extends UplinkMainScreen {
super(SELECTORS.CHAT_LAYOUT);
}

get chatbarInputError() {
return this.chatLayout.$(SELECTORS.CHATBAR_INPUT_ERROR);
}

get chatbarInputErrorText() {
return this.chatbarInputError.$(SELECTORS.CHATBAR_INPUT_ERROR_TEXT);
}

get chatLayout() {
return $(SELECTORS.CHAT_LAYOUT);
}
Expand Down
29 changes: 15 additions & 14 deletions tests/screenobjects/chats/CreateGroupChat.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
require("module-alias/register");
import { getClipboardMacOS, keyboardShortcutPaste } from "@helpers/commands";
import {
getClipboardMacOS,
keyboardShortcutPaste,
setClipboardValue,
} from "@helpers/commands";
import { faker } from "@faker-js/faker";
import { MACOS_DRIVER, WINDOWS_DRIVER } from "@helpers/constants";
import UplinkMainScreen from "@screenobjects/UplinkMainScreen";

Expand Down Expand Up @@ -227,20 +232,16 @@ export default class CreateGroupChat extends UplinkMainScreen {

async typeLongerTextInGroupName() {
// Assuming that user already clicked on Copy ID button
// If driver is macos, then get clipboard and pass it to enterStatus function
const groupNameInput = await this.groupNameInput;
const currentDriver = await this.getCurrentDriver();
if (currentDriver === MACOS_DRIVER) {
await groupNameInput.click();
const userKey = await getClipboardMacOS();
await groupNameInput.setValue(userKey + userKey);
} else if (currentDriver === WINDOWS_DRIVER) {
await driver.touchAction([{ action: "press", element: groupNameInput }]);
// If driver is windows, then click on status input to place cursor there and simulate a control + v
await keyboardShortcutPaste();
await driver.touchAction([{ action: "press", element: locator }]);
await keyboardShortcutPaste();
}
// Get a random word of 8 chars
const wordToRepeat = faker.lorem.word(8);
// Then repeat the same word for 8 times (64 chars)
let longText = wordToRepeat.repeat(8);
await setClipboardValue(longText);
// Now, add 4 more chars, to have 1024 chars
await groupNameInput.click();
await keyboardShortcutPaste();
await groupNameInput.addValue("a");
}

async typeOnGroupName(name: string) {
Expand Down
24 changes: 16 additions & 8 deletions tests/screenobjects/chats/EmojiSuggestions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ let SELECTORS = {};
const SELECTORS_COMMON = {};

const SELECTORS_WINDOWS = {
EMOJI_SUGGESTIONS_CLOSE_BUTTON: '[name="emoji-suggestions-close-button"]',
EMOJI_SUGGESTIONS_CONTAINER: '[name="emoji-suggestions-container"]',
EMOJI_SUGGESTIONS_CLOSE_BUTTON: '[name="chatbar-suggestions-close-button"]',
EMOJI_SUGGESTIONS_CONTAINER: '[name="chatbar-suggestions-container"]',
EMOJI_SUGGESTIONS_HEADER: "<Text>",
EMOJI_SUGGESTED: '//Group[contains(@Name, "emoji-suggested-")]',
EMOJI_SUGGESTED_VALUE: "<Text>",
};

const SELECTORS_MACOS = {
EMOJI_SUGGESTIONS_CLOSE_BUTTON: "~emoji-suggestion-close-button",
EMOJI_SUGGESTIONS_CONTAINER: "~emoji-suggestions-container",
EMOJI_SUGGESTIONS_CLOSE_BUTTON: "~chatbar-suggestion-close-button",
EMOJI_SUGGESTIONS_CONTAINER: "~chatbar-suggestions-container",
EMOJI_SUGGESTIONS_HEADER:
'-ios class chain:**/XCUIElementTypeStaticText[`value == "SUGGESTED EMOJI"`][2]',
EMOJI_SUGGESTED:
Expand Down Expand Up @@ -55,7 +55,7 @@ export default class EmojiSuggestions extends UplinkMainScreen {
}

async clickOnEmojiSuggested(emojiToClick: string) {
await this.emojiSuggestionsContainer.waitForDisplayed();
await this.validateEmojiSuggestionsContainerIsShown();
const currentDriver = await this.getCurrentDriver();
let emojiLocator, emojiElement;
if (currentDriver === MACOS_DRIVER) {
Expand All @@ -77,7 +77,7 @@ export default class EmojiSuggestions extends UplinkMainScreen {
}

async getEmojisSuggested() {
await this.emojiSuggestionsContainer.waitForDisplayed();
await this.validateEmojiSuggestionsContainerIsShown();
const emojiSuggestedList = await this.emojiSuggestionsContainer.$$(
SELECTORS.EMOJI_SUGGESTED,
);
Expand All @@ -91,13 +91,21 @@ export default class EmojiSuggestions extends UplinkMainScreen {
}

async validateEmojiSuggestionsContainerIsShown() {
await this.emojiSuggestionsContainer.waitForDisplayed();
await driver.waitUntil(
async () => {
return await $(SELECTORS.EMOJI_SUGGESTIONS_CONTAINER).waitForExist();
},
{
timeout: 30000,
timeoutMsg: "Expected Emoji Container was not displayed after 30s",
},
);
}

async validateEmojiSuggestionsHeader(expectedHeader: string) {
await this.emojiSuggestionsHeader.waitForDisplayed();
const emojiSuggestionsHeader = await this.emojiSuggestionsHeader;
await expect(emojiSuggestionsHeader).toHaveTextContaining(expectedHeader);
await expect(emojiSuggestionsHeader).toHaveText(expectedHeader);
}

async validateEmojiSuggestionsReceived(expectedEmojiList: string[]) {
Expand Down
54 changes: 26 additions & 28 deletions tests/specs/reusable-accounts/04-message-input.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ import {
activateSecondApplication,
closeFirstApplication,
closeSecondApplication,
keyboardShiftEnter,
keyboardShortcutPaste,
launchFirstApplication,
launchSecondApplication,
setClipboardValue,
} from "@helpers/commands";
const chatsLayout = new ChatsLayout();
const chatsInput = new InputBar();
Expand Down Expand Up @@ -42,24 +45,28 @@ export default async function messageInputTests() {
await expect(textMessage).toHaveTextContaining("Two...");
});

// Skipping Test Failing on CI
xit("Chat User A - Message Input - User can type up to 1024 chars on input bar", async () => {
// Generate a random text with 1024 chars
it("Chat User A - Message Input - User can type up to 1024 chars on input bar", async () => {
// Generate a random text with 1024 chars and set this to clipboard
const longText = await chatsInput.generateRandomText();
// Type long text with 1024 chars on input bar and attempt to add 4 more chars (efgh)
await chatsInput.typeMessageOnInput(longText + "efgh");
await setClipboardValue(longText);

// Click on input bar and paste long text twice
await chatsInput.clickOnInputBar();
await keyboardShortcutPaste();
await keyboardShortcutPaste();

// Ensure that latest chars were not added to input bar, since the max number of chars has been reached
// Input bar text should be equal to long text with 1024 chars
const inputText = await chatsInput.getValueFromInputBar();
await expect(inputText).toHaveText(longText);
const chatbarInputErrorText = await chatsLayout.chatbarInputErrorText;
await expect(chatbarInputErrorText).toHaveText(
"Maximum of 1024 characters exceeded.",
);

// Clear input bar to finish test
await chatsInput.clearInputBar();
});

// Skipping for Emoji Suggested List taking too long to display on CI runner
xit("Emoji Suggested List - Displays expected data", async () => {
it("Emoji Suggested List - Displays expected data", async () => {
// Type :en to show emoji suggestions starting with "en"
await chatsInput.typeMessageOnInput(":en");
await emojiSuggestions.emojiSuggestionsContainer.waitForDisplayed({
Expand All @@ -82,8 +89,7 @@ export default async function messageInputTests() {
await emojiSuggestions.validateEmojiSuggestionsHeader("SUGGESTED EMOJI");
});

// Skipping for Emoji Suggested List taking too long to display on CI runner
xit("Emoji Suggested List - Can be closed without choosing suggestion", async () => {
it("Emoji Suggested List - Can be closed without choosing suggestion", async () => {
// Close Emoji Suggested List using the Close Button
await emojiSuggestions.clickOnCloseButton();

Expand All @@ -93,8 +99,7 @@ export default async function messageInputTests() {
});
});

// Skipping for Emoji Suggested List taking too long to display on CI runner
xit("Emoji Suggested List - Selected emoji is added to input bar", async () => {
it("Emoji Suggested List - Selected emoji is added to input bar", async () => {
// Open Emoji Suggested List again by typing :en to show emoji suggestions starting with "en"
await chatsInput.typeMessageOnInput(":en");
await emojiSuggestions.emojiSuggestionsContainer.waitForDisplayed({
Expand Down Expand Up @@ -129,8 +134,7 @@ export default async function messageInputTests() {
await messageLocal.waitForMessageSentToExist("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 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.clickOnSendMessage();
Expand All @@ -142,8 +146,7 @@ export default async function messageInputTests() {
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.clickOnCopyCodeOfLastMessageSent();

Expand All @@ -167,8 +170,7 @@ export default async function messageInputTests() {
await messageRemote.waitForReceivingMessage("Bolds2");
});

// 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 =
Expand Down Expand Up @@ -235,27 +237,23 @@ export default async function messageInputTests() {
await linkEmbedReceivedIconTitle.waitForExist();
});

// Test failing on CI
xit("Typing Indicator - Send a long message to trigger typing indicator on remote side", async () => {
// With User A
await activateFirstApplication();
it("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
const shortText = await chatsInput.generateShortRandomText();
// Type the text with 90 chars on input bar
await chatsInput.typeMessageOnInput(shortText + "efgh");
});

// Test failing on CI
xit("Validate Typing Indicator is displayed if remote user is typing", async () => {
it("Validate Typing Indicator is displayed if remote user is typing", async () => {
// Switch to second user and validate that Typing Indicator is displayed
await activateSecondApplication();
await activateFirstApplication();
await chatsInput.waitForIsShown(true);
await chatsLayout.typingIndicator.waitForExist({
timeout: 30000,
});
await expect(chatsLayout.typingIndicatorTextValue).toHaveTextContaining(
"ChatUserA is typing",
await expect(chatsLayout.typingIndicatorTextValue).toHaveText(
"ChatUserB is typing",
);
});

Expand Down
3 changes: 1 addition & 2 deletions tests/specs/reusable-accounts/09-group-chats.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ export default async function groupChatTests() {
await createGroup.clearGroupNameInput();
});

// Needs rework to use new Copy DID method
xit("Chat User A - Attempt to create group chat with more than 64 chars in name", async () => {
it("Chat User A - Attempt to create group chat with more than 64 chars in name", async () => {
// Open modal to create group chat and type more than 64 chars in name
await createGroup.typeLongerTextInGroupName();
await createGroup.validateCreateGroupChatInputErrorIsShown();
Expand Down

0 comments on commit e2091db

Please sign in to comment.