Skip to content

Commit

Permalink
test(update): start adding tests to execute on two runners
Browse files Browse the repository at this point in the history
  • Loading branch information
luisecm committed Nov 1, 2023
1 parent c95c9e2 commit ec114c3
Show file tree
Hide file tree
Showing 8 changed files with 384 additions and 46 deletions.
20 changes: 0 additions & 20 deletions tests/specs/reusable-accounts/ChatUserA/01-create-account.spec.ts

This file was deleted.

150 changes: 150 additions & 0 deletions tests/specs/reusable-accounts/ChatUserA/01-main-chats-userA.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
import "module-alias/register";
import { loginWithTestUser } from "@helpers/commands";
import { USER_A_INSTANCE } from "@helpers/constants";
import ChatsLayout from "@screenobjects/chats/ChatsLayout";
import EmojiSelector from "@screenobjects/chats/EmojiSelector";
import FavoritesSidebar from "@screenobjects/chats/FavoritesSidebar";
import FriendsScreen from "@screenobjects/friends/FriendsScreen";
import InputBar from "@screenobjects/chats/InputBar";
import Messages from "@screenobjects/chats/Messages";
import MessageGroup from "@screenobjects/chats/MessageGroup";
import Topbar from "@screenobjects/chats/Topbar";
import WelcomeScreen from "@screenobjects/welcome-screen/WelcomeScreen";
let chatsMessagesFirstUser = new Messages(USER_A_INSTANCE);
let chatsMessageGroupsFirstUser = new MessageGroup(USER_A_INSTANCE);
let chatsInputFirstUser = new InputBar(USER_A_INSTANCE);
let chatsLayoutFirstUser = new ChatsLayout(USER_A_INSTANCE);
let chatsTopbarFirstUser = new Topbar(USER_A_INSTANCE);
let emojiSelectorFirstUser = new EmojiSelector(USER_A_INSTANCE);
let favoritesSidebarFirstUser = new FavoritesSidebar(USER_A_INSTANCE);
let friendsScreenFirstUser = new FriendsScreen(USER_A_INSTANCE);
let welcomeScreenFirstUser = new WelcomeScreen(USER_A_INSTANCE);

export default async function mainChatsTestsUserA() {
it("Chat User A - Login with account previously created", async () => {
// Login with account previously created
await loginWithTestUser();
await welcomeScreenFirstUser.validateWelcomeScreenIsShown();
await welcomeScreenFirstUser.goToFriends();
await friendsScreenFirstUser.validateFriendsScreenIsShown();
});

it("Chat User A - Accept friend request from User A and go to chat button", async () => {
// With User A - Go to pending requests list, wait for receiving the friend request and accept it
await friendsScreenFirstUser.hoverOnPendingListButton();
await friendsScreenFirstUser.goToPendingFriendsList();
await friendsScreenFirstUser.validateIncomingListIsShown();
await friendsScreenFirstUser.waitUntilFriendRequestIsReceived();
await friendsScreenFirstUser.acceptIncomingRequest("ChatUserB");

// Validate friend is now on all friends list
await friendsScreenFirstUser.goToAllFriendsList();
await friendsScreenFirstUser.validateAllFriendsListIsShown();
await friendsScreenFirstUser.validateAllFriendsListIsNotEmpty();

// Go to Chat with User B
await friendsScreenFirstUser.chatWithFriendButton.click();
});

it("Chat User A - Chat screen displays Messages secured text displayed on top of conversation", async () => {
await chatsTopbarFirstUser.validateTopbarExists();

// Validate E2E message is displayed on top of chat
const encryptedMessagesText =
await chatsLayoutFirstUser.encryptedMessagesText;
await encryptedMessagesText.waitForExist();
await expect(encryptedMessagesText).toHaveTextContaining(
"Messages are secured by end-to-end encryption and sent over a peer-to-peer network.",
);
});

it("Input Bar - Chars Counter on Input Bar displays 0/1024 before typing a text", async () => {
// Validate Char counter is displayed on Input Bar and it displays 0/1024
const inputCharCounter = await chatsInputFirstUser.inputCharCounterText;
const inputCharMaxText = await chatsInputFirstUser.inputCharMaxText;
await expect(inputCharCounter).toHaveTextContaining("0");
await expect(inputCharMaxText).toHaveTextContaining("/1024");
});

it("Input Bar - Chars Counter on Input Bar displays the number of chars of text entered", async () => {
// Validate Char counter increases after typing a text
const inputCharCounter = await chatsInputFirstUser.inputCharCounterText;
const inputCharMaxText = await chatsInputFirstUser.inputCharMaxText;
await chatsInputFirstUser.typeMessageOnInput("Testing...");
await expect(inputCharCounter).toHaveTextContaining("10");
await expect(inputCharMaxText).toHaveTextContaining("/1024");
});

it("Input Bar - Add emoji to the message to be sent", async () => {
// Add emoji to the message to be sent
await chatsInputFirstUser.clickOnEmojiButton();
await emojiSelectorFirstUser.clickOnEmoji("😀");

// Validate Char counter increases after adding an emoji to input bar
const inputCharCounter = await chatsInputFirstUser.inputCharCounterText;
const inputCharMaxText = await chatsInputFirstUser.inputCharMaxText;
await expect(inputCharCounter).toHaveTextContaining("11");
await expect(inputCharMaxText).toHaveTextContaining("/1024");
});

it("Input Bar - Click on send button will send the message to the other user", async () => {
// Send message to the other user
await chatsInputFirstUser.clickOnSendMessage();
await chatsMessagesFirstUser.waitForMessageSentToExist("Testing...😀");

const textFromMessage =
await chatsMessagesFirstUser.getFirstMessageSentText();
await expect(textFromMessage).toHaveTextContaining("Testing...😀");
});

it("Input Bar - Chars Counter on Input Bar displays 0/1024 after sending a message", async () => {
// Validate Char counter is displayed on Input Bar and it displays 0/1024
const inputCharCounter = await chatsInputFirstUser.inputCharCounterText;
const inputCharMaxText = await chatsInputFirstUser.inputCharMaxText;
await expect(inputCharCounter).toHaveTextContaining("0");
await expect(inputCharMaxText).toHaveTextContaining("/1024");
});

it("Chat User A - Validate Chat Message displays timestamp and user who sent it", async () => {
//Timestamp from last message sent should be displayed
const timeAgo =
await chatsMessageGroupsFirstUser.getLastMessageSentTimeAgo();
await expect(timeAgo).toHaveTextContaining(
/- (?:\d{1,2}\s+(?:second|minute)s?\s+ago|now)$/,
);
await expect(timeAgo).toHaveTextContaining("ChatUserA");
});

it("Chat User A - Validate Chat Message sent contents", async () => {
//Any message you sent yourself should appear within a colored message bubble
const messageText = await chatsMessagesFirstUser.getFirstMessageSentText();
await expect(messageText).toHaveTextContaining("Testing...😀");
});

it("Chat User A - Validate Chat Message Group displays username picture", async () => {
//Your user image should be displayed next to the message
const userImage =
await chatsMessageGroupsFirstUser.getLastGroupWrapSentImage();
await userImage.waitForExist();
});

it("Chat User A - Topbar information", async () => {
// Validate user image, username is displayed on Chat Topbar
await chatsTopbarFirstUser.validateTopbarUserImage();
await chatsTopbarFirstUser.validateTopbarUserName("ChatUserB");
});

it("Chat User A - Add user with active chat to Favorites", async () => {
// Add user to favorites
await chatsTopbarFirstUser.addToFavorites();
await favoritesSidebarFirstUser.validateFavoritesAreShown();

// Favorites Sidebar User bubble should be displayed with image
await favoritesSidebarFirstUser.validateFavoritesUserImage("ChatUserB");
});

it("Chat User A - Remove user with active chat from Favorites", async () => {
// Remove user from favorites
await chatsTopbarFirstUser.removeFromFavorites();
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import "module-alias/register";
import { USER_A_INSTANCE } from "@helpers/constants";
import ContextMenu from "@screenobjects/chats/ContextMenu";
import InputBar from "@screenobjects/chats/InputBar";
import MessageGroup from "@screenobjects/chats/MessageGroup";
import Messages from "@screenobjects/chats/Messages";
import ReplyPrompt from "@screenobjects/chats/ReplyPrompt";
let chatsContextMenuFirstUser = new ContextMenu(USER_A_INSTANCE);
let chatsInputFirstUser = new InputBar(USER_A_INSTANCE);
let chatsMessageGroupsFirstUser = new MessageGroup(USER_A_INSTANCE);
let chatsMessagesFirstUser = new Messages(USER_A_INSTANCE);
let chatsReplyPromptFirstUser = new ReplyPrompt(USER_A_INSTANCE);

export default async function repliesTestsUserA() {
it("Chat User A - Validate reply message contents", async () => {
// Switch control to User A
await chatsMessagesFirstUser.switchToOtherUserWindow();

// With User A - Validate that reply message is received
await chatsMessagesFirstUser.chatMessageReply.waitForExist();

// Validate message replied appears smaller above your reply
const replyReceived = await chatsMessagesFirstUser.getLastReply();
const replyReceivedText = await chatsMessagesFirstUser.getLastReplyText();
await replyReceived.waitForExist();
await expect(replyReceivedText).toHaveTextContaining("Testing...😀");

// Validate reply message sent appears as last message
const textFromMessage =
await chatsMessagesFirstUser.getLastMessageReceivedText();
await expect(textFromMessage).toHaveTextContaining("Reply");
});

it("Chat User A - Validate reply message group contains timestamp", async () => {
//Timestamp from last message sent should be displayed
const timeAgo =
await chatsMessageGroupsFirstUser.getLastMessageReceivedTimeAgo();
await expect(timeAgo).toHaveTextContaining(
/- (?:\d{1,2}\s+(?:second|minute)s?\s+ago|now)$/,
);
await expect(timeAgo).toHaveTextContaining("ChatUserB");
});

it("Chat User A - Validate reply message group contains user image", async () => {
//Your user image should be displayed next to the message
const userImage =
await chatsMessageGroupsFirstUser.getLastGroupWrapReceivedImage();
await userImage.waitForExist();
});

it("Chat User A - Reply to yourself", async () => {
// Open Context Menu on Last Message Sent
await chatsMessagesFirstUser.openContextMenuOnLastSent();
await chatsContextMenuFirstUser.validateContextMenuIsOpen();
await chatsContextMenuFirstUser.selectContextOptionReply();

// Type a reply and sent it
await chatsReplyPromptFirstUser.replyPopUp.waitForExist();
await chatsInputFirstUser.typeMessageOnInput("SelfReply");
await chatsInputFirstUser.clickOnSendMessage();
await chatsReplyPromptFirstUser.waitForReplyModalToNotExist();

// Validate reply to self message is displayed on Chat Conversation
const repliedMessage = await chatsMessagesFirstUser.getLastReply();
const repliedMessageText = await chatsMessagesFirstUser.getLastReplyText();
await repliedMessage.waitForExist();
await expect(repliedMessageText).toHaveTextContaining("Testing...😀");

// Validate reply message sent appears as last message
const message = await chatsMessagesFirstUser.getLastMessageSentText();
await expect(message).toHaveTextContaining("SelfReply");
});
}
20 changes: 0 additions & 20 deletions tests/specs/reusable-accounts/ChatUserB/01-create-account.spec.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import "module-alias/register";
import { getUserKey, loginWithTestUser } from "@helpers/commands";
import { USER_A_INSTANCE } from "@helpers/constants";
import FriendsScreen from "@screenobjects/friends/FriendsScreen";
import Messages from "@screenobjects/chats/Messages";
import MessageGroup from "@screenobjects/chats/MessageGroup";
import Topbar from "@screenobjects/chats/Topbar";
import WelcomeScreen from "@screenobjects/welcome-screen/WelcomeScreen";
let chatsMessagesFirstUser = new Messages(USER_A_INSTANCE);
let chatsMessageGroupsFirstUser = new MessageGroup(USER_A_INSTANCE);
let chatsTopbarFirstUser = new Topbar(USER_A_INSTANCE);
let friendsScreenFirstUser = new FriendsScreen(USER_A_INSTANCE);
let welcomeScreenFirstUser = new WelcomeScreen(USER_A_INSTANCE);

export default async function mainChatsTestsUserB() {
it("Chat User B - Login with account previously created", async () => {
// Login with account previously created
await loginWithTestUser();
await welcomeScreenFirstUser.validateWelcomeScreenIsShown();
await welcomeScreenFirstUser.goToFriends();
await friendsScreenFirstUser.validateFriendsScreenIsShown();
});

it("Chat User B - Send friend request to User A", async () => {
// Obtain did key from Chat User B
const friendDidKey = await getUserKey("ChatUserA", USER_A_INSTANCE);
await friendsScreenFirstUser.enterFriendDidKey(friendDidKey);
await friendsScreenFirstUser.clickOnAddSomeoneButton();

// Wait for toast notification to be closed
await friendsScreenFirstUser.waitUntilNotificationIsClosed();

// Validate friend request appears on pending list
await friendsScreenFirstUser.hoverOnPendingListButton();
await friendsScreenFirstUser.goToPendingFriendsList();
await friendsScreenFirstUser.validateOutgoingListIsShown();
await friendsScreenFirstUser.validateOutgoingListIsNotEmpty();

await friendsScreenFirstUser.goToAllFriendsList();
await friendsScreenFirstUser.validateAllFriendsListIsShown();
});

it("Chat User B - Validate friend request was accepted", async () => {
// With User A - Go to pending requests list, wait for receiving the friend request and accept it
await friendsScreenFirstUser.waitUntilUserAcceptedFriendRequest();

// Validate friend is now on all friends list
await friendsScreenFirstUser.goToAllFriendsList();
await friendsScreenFirstUser.validateAllFriendsListIsShown();
await friendsScreenFirstUser.validateAllFriendsListIsNotEmpty();
});

it("Chat User B - Wait until the other user is connected", async () => {
// Go to the current list of All friends and then open a Chat conversation with ChatUserA
await friendsScreenFirstUser.chatWithFriendButton.waitForExist();
await friendsScreenFirstUser.hoverOnChatWithFriendButton("ChatUserA");
await friendsScreenFirstUser.chatWithFriendButton.click();
await chatsTopbarFirstUser.validateTopbarExists();
});

it("Chat User B - Assert message received from Chat User A", async () => {
// Validate message received from Chat User A
await chatsMessagesFirstUser.waitForReceivingMessage("Testing...😀");

//Any message you sent yourself should appear within a colored message bubble
const textFromMessage =
await chatsMessagesFirstUser.getLastMessageReceivedText();
await expect(textFromMessage).toHaveTextContaining("Testing...😀");
});

it("Chat User B - Validate Chat Message Group from remote user displays username picture", async () => {
//Your user image should be displayed next to the message
const userImage =
await chatsMessageGroupsFirstUser.getLastGroupWrapReceivedImage();
await userImage.waitForExist();
});

it("Chat User B - Validate Chat Message received displays timestamp and user who sent it", async () => {
//Timestamp should be displayed when you send a message
const timeAgo =
await chatsMessageGroupsFirstUser.getLastMessageReceivedTimeAgo();
await expect(timeAgo).toHaveTextContaining(
/- (?:\d{1,2}\s+(?:second|minute)s?\s+ago|now)$/,
);
await expect(timeAgo).toHaveTextContaining("ChatUserA");
});
}
Loading

0 comments on commit ec114c3

Please sign in to comment.