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

chore(appium): refactor for chats and improve code readability #582

Merged
merged 4 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions config/wdio.mac.multiremote.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export const config: WebdriverIO.Config = {
// it and to build services around it. You can either apply a single function or an array of
// methods to it. If one of them returns with a promise, WebdriverIO will wait until that promise got
// resolved to continue.
/*onPrepare: async function () {
onPrepare: async function () {
const cacheFolderUserA = homedir() + "/.uplink/.user";
const cacheFolderUserB = homedir() + "/.uplinkUserB/.user";
const allureResultsFolder = join(process.cwd(), "./allure-results");
Expand All @@ -127,7 +127,7 @@ export const config: WebdriverIO.Config = {
`Got an error trying to delete Cache Folder: ${error.message}`,
);
}
},*/
},
/**
* Function to be executed after a test (in Mocha/Jasmine).
*/
Expand Down
4 changes: 2 additions & 2 deletions docs/ARIA_LABELS.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ Find more information about the WebdriverIO API methods in the following [`link`

```js
it("Validate Welcome Screen is displayed", async () => {
await expect(welcomeScreenFirstUser.addSomeoneText).toHaveTextContaining(
await expect(welcomeScreen.addSomeoneText).toHaveTextContaining(
"Things are better with friends.",
);
});
Expand All @@ -299,7 +299,7 @@ it("Validate Welcome Screen is displayed", async () => {

```js
it("Validate Welcome Screen is displayed", async () => {
await expect(welcomeScreenFirstUser.addSomeoneText).toHaveTextContaining(
await expect(welcomeScreen.addSomeoneText).toHaveTextContaining(
"No friends added yet!",
);
});
Expand Down
33 changes: 17 additions & 16 deletions tests/helpers/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ const { readFileSync, rmSync, writeFileSync } = require("fs");
const { execSync } = require("child_process");
const fsp = require("fs").promises;
const { clipboard, mouse, Button } = require("@nut-tree/nut-js");
let createPinFirstUser = new CreatePinScreen();
let createUserFirstUser = new CreateUserScreen();
let friendsScreenFirstUser = new FriendsScreen();
let welcomeScreenFirstUser = new WelcomeScreen();
let createPin = new CreatePinScreen();
let createUser = new CreateUserScreen();
let friendsScreen = new FriendsScreen();
let welcomeScreen = new WelcomeScreen();

// Users cache helper functions

Expand Down Expand Up @@ -99,31 +99,32 @@ export async function saveTestKeys(username: string, didkey: string) {
// Login or Create Users Functions

export async function createNewUser(username: string) {
await createPinFirstUser.unlockLayout.waitForExist();
await createPin.unlockLayout.waitForExist();

// Enter pin for test user
await createPinFirstUser.enterPin("1234");
await createPinFirstUser.createAccountButton.waitForEnabled();
await createPinFirstUser.clickOnCreateAccount();
await createPin.enterPin("1234");
await createPin.createAccountButton.waitForEnabled();
await createPin.clickOnCreateAccount();

// Enter Username and click on Create Account
await createUserFirstUser.enterUsername(username);
await createUserFirstUser.createAccountButton.waitForEnabled();
await createUserFirstUser.clickOnCreateAccount();
await createUser.enterUsername(username);
await createUser.createAccountButton.waitForEnabled();
await createUser.clickOnCreateAccount();

// Ensure Main Screen is displayed
await welcomeScreenFirstUser.welcomeLayout.waitForExist();
await welcomeScreen.welcomeLayout.waitForExist();

// Workaround to ensure that user clicks on Add Someone
await welcomeScreenFirstUser.clickAddSomeone();
await friendsScreenFirstUser.friendsBody.waitForExist();
await welcomeScreen.clickAddSomeone();
await friendsScreen.friendsBody.waitForExist();
}

export async function loginWithTestUser() {
// Enter pin for test user
const unlockScreen = await createPinFirstUser.unlockLayout;
const unlockScreen = await createPin.unlockLayout;
await unlockScreen.waitForExist();
await createPinFirstUser.enterPin("1234");
await createPin.enterPin("1234");
await createPin.unlockLayout.waitForExist({ reverse: true });
}

export async function resetApp() {
Expand Down
140 changes: 70 additions & 70 deletions tests/helpers/debugging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,158 +14,158 @@ import SettingsGeneralScreen from "@screenobjects/settings/SettingsGeneralScreen
import SettingsNotificationsScreen from "@screenobjects/settings/SettingsNotificationsScreen";
import SettingsProfileScreen from "@screenobjects/settings/SettingsProfileScreen";
import WelcomeScreen from "@screenobjects/welcome-screen/WelcomeScreen";
let chatsTopbarFirstUser = new Topbar();
let createPinFirstUser = new CreatePinScreen();
let friendsScreenFirstUser = new FriendsScreen();
let settingsGeneralFirstUser = new SettingsGeneralScreen();
let settingsNotificationsFirstUser = new SettingsNotificationsScreen();
let settingsProfileFirstUser = new SettingsProfileScreen();
let welcomeScreenFirstUser = new WelcomeScreen();
let chatsTopbar = new Topbar();
let createPin = new CreatePinScreen();
let friendsScreen = new FriendsScreen();
let settingsGeneral = new SettingsGeneralScreen();
let settingsNotifications = new SettingsNotificationsScreen();
let settingsProfile = new SettingsProfileScreen();
let welcomeScreen = new WelcomeScreen();

export async function setupBeforeCreateGroupTests() {
// Create a new account and go to Settings Profile
await createPinFirstUser.waitForIsShown(true);
await createPin.waitForIsShown(true);
const usernameA = "ChatUserA";
await createNewUser(usernameA);
await welcomeScreenFirstUser.goToSettings();
await settingsProfileFirstUser.validateSettingsProfileIsShown();
await welcomeScreen.goToSettings();
await settingsProfile.validateSettingsProfileIsShown();

// Click on Copy ID button and assert Toast Notification is displayed
await settingsProfileFirstUser.openCopyIDContextMenu();
await settingsProfileFirstUser.clickOnContextMenuCopyDidKey();
await settingsProfile.openCopyIDContextMenu();
await settingsProfile.clickOnContextMenuCopyDidKey();

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

// Paste copied DID Key into Status Input
await settingsProfileFirstUser.pasteUserKeyInStatus();
const didkeyA = await settingsProfileFirstUser.getCopiedDidFromStatusInput();
await settingsProfile.pasteUserKeyInStatus();
const didkeyA = await settingsProfile.getCopiedDidFromStatusInput();

// Grab cache folder and restart
await saveTestKeys(usernameA, didkeyA);

// Go to General Settings and reduce Font Size by 0.5
await settingsProfileFirstUser.goToGeneralSettings();
await settingsProfile.goToGeneralSettings();

// Wait for toast notification of Profile Updated to not exist
await settingsGeneralFirstUser.waitUntilNotificationIsClosed();
await settingsGeneral.waitUntilNotificationIsClosed();

// Click on font scaling minus button
await settingsGeneralFirstUser.settingsGeneral.waitForExist();
await settingsGeneralFirstUser.clickOnFontScalingMinus();
await settingsGeneral.settingsGeneral.waitForExist();
await settingsGeneral.clickOnFontScalingMinus();

// Go to Notifications Settings and disable all notifications
await settingsGeneralFirstUser.goToNotificationsSettings();
await settingsNotificationsFirstUser.validateSettingsNotificationsIsShown();
await settingsNotificationsFirstUser.clickOnFriendsNotifications();
await settingsNotificationsFirstUser.clickOnMessagesNotifications();
await settingsGeneral.goToNotificationsSettings();
await settingsNotifications.validateSettingsNotificationsIsShown();
await settingsNotifications.clickOnFriendsNotifications();
await settingsNotifications.clickOnMessagesNotifications();

// Go to Friends Screen
await settingsNotificationsFirstUser.goToFriends();
await friendsScreenFirstUser.validateFriendsScreenIsShown();
await settingsNotifications.goToFriends();
await friendsScreen.validateFriendsScreenIsShown();

// Launch second application
await launchSecondApplication();

// Create a new account and go to Settings Profile
await createPinFirstUser.waitForIsShown(true);
await createPin.waitForIsShown(true);
const usernameB = "ChatUserB";
await createNewUser(usernameB);
await welcomeScreenFirstUser.goToSettings();
await settingsProfileFirstUser.validateSettingsProfileIsShown();
await welcomeScreen.goToSettings();
await settingsProfile.validateSettingsProfileIsShown();

// Click on Copy ID button and assert Toast Notification is displayed
await settingsProfileFirstUser.openCopyIDContextMenu();
await settingsProfileFirstUser.clickOnContextMenuCopyDidKey();
await settingsProfile.openCopyIDContextMenu();
await settingsProfile.clickOnContextMenuCopyDidKey();

// Wait for toast notification of Copied To Clipboard to not exist
await settingsProfileFirstUser.waitUntilNotificationIsClosed();
await settingsProfile.waitUntilNotificationIsClosed();

// Paste copied DID Key into Status Input
await settingsProfileFirstUser.pasteUserKeyInStatus();
const didkeyB = await settingsProfileFirstUser.getCopiedDidFromStatusInput();
await settingsProfile.pasteUserKeyInStatus();
const didkeyB = await settingsProfile.getCopiedDidFromStatusInput();

// Grab cache folder and restart
await saveTestKeys(usernameB, didkeyB);

// Go to General Settings and reduce Font Size by 0.5
await settingsProfileFirstUser.goToGeneralSettings();
await settingsProfile.goToGeneralSettings();

// Wait for toast notification of Profile Updated to not exist
await settingsGeneralFirstUser.waitUntilNotificationIsClosed();
await settingsGeneral.waitUntilNotificationIsClosed();

// Click on font scaling minus button
await settingsGeneralFirstUser.settingsGeneral.waitForExist();
await settingsGeneralFirstUser.clickOnFontScalingMinus();
await settingsGeneral.settingsGeneral.waitForExist();
await settingsGeneral.clickOnFontScalingMinus();

// Go to Notifications Settings and disable all notifications
await settingsGeneralFirstUser.goToNotificationsSettings();
await settingsNotificationsFirstUser.validateSettingsNotificationsIsShown();
await settingsNotificationsFirstUser.clickOnFriendsNotifications();
await settingsNotificationsFirstUser.clickOnMessagesNotifications();
await settingsGeneral.goToNotificationsSettings();
await settingsNotifications.validateSettingsNotificationsIsShown();
await settingsNotifications.clickOnFriendsNotifications();
await settingsNotifications.clickOnMessagesNotifications();

// Go to Friends Screen
await settingsNotificationsFirstUser.goToFriends();
await friendsScreenFirstUser.validateFriendsScreenIsShown();
await settingsNotifications.goToFriends();
await friendsScreen.validateFriendsScreenIsShown();

// Obtain did key from Chat User B
const friendDidKey = await getUserKey("ChatUserA");
await friendsScreenFirstUser.enterFriendDidKey(friendDidKey);
await friendsScreenFirstUser.clickOnAddSomeoneButton();
await friendsScreen.enterFriendDidKey(friendDidKey);
await friendsScreen.clickOnAddSomeoneButton();

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

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

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

// Switch control to User A
await activateFirstApplication();

// 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");
await friendsScreen.hoverOnPendingListButton();
await friendsScreen.goToPendingFriendsList();
await friendsScreen.validateIncomingListIsShown();
await friendsScreen.waitUntilFriendRequestIsReceived();
await friendsScreen.acceptIncomingRequest("ChatUserB");

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

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

// Switch control to User B
await activateSecondApplication();

// With User A - Go to pending requests list, wait for receiving the friend request and accept it
await friendsScreenFirstUser.waitUntilUserAcceptedFriendRequest();
await friendsScreen.waitUntilUserAcceptedFriendRequest();

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

// Switch control to User A
await activateFirstApplication();
await chatsTopbarFirstUser.validateTopbarExists();
await chatsTopbar.validateTopbarExists();

// Switch control to User B
await activateSecondApplication();

// 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();
await friendsScreen.chatWithFriendButton.waitForExist();
await friendsScreen.hoverOnChatWithFriendButton("ChatUserA");
await friendsScreen.chatWithFriendButton.click();
await chatsTopbar.validateTopbarExists();

// Switch control to User A
await activateFirstApplication();
Expand Down
Loading
Loading