Skip to content

Commit

Permalink
Merge pull request #661 from Satellite-im/luis/multiple-users
Browse files Browse the repository at this point in the history
test(add): add tests for three user instances at the same time
  • Loading branch information
luisecm authored Mar 19, 2024
2 parents 85ae65d + 7fe2ba5 commit 67d44b3
Show file tree
Hide file tree
Showing 10 changed files with 252 additions and 26 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/ui-automated-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -380,12 +380,16 @@ jobs:
run: |
unzip Uplink-Mac-Universal.zip
cp -r ./Uplink.app ./Uplink2.app
cp -r ./Uplink.app ./Uplink3.app
perl -i -pe 's/im.satellite.uplink/im.satellite.uplinkChatUserA/g' ./Uplink.app/Contents/Info.plist
perl -i -pe 's/im.satellite.uplink/im.satellite.uplinkChatUserB/g' ./Uplink2.app/Contents/Info.plist
perl -i -pe 's/im.satellite.uplink/im.satellite.uplinkChatUserC/g' ./Uplink3.app/Contents/Info.plist
cp -r ./Uplink.app /Applications/
cp -r ./Uplink2.app /Applications/
cp -r ./Uplink3.app /Applications/
sudo xattr -r -d com.apple.quarantine /Applications/Uplink.app
sudo xattr -r -d com.apple.quarantine /Applications/Uplink2.app
sudo xattr -r -d com.apple.quarantine /Applications/Uplink3.app
- name: Setup Node.js 🔨
uses: actions/setup-node@v3
Expand Down Expand Up @@ -467,6 +471,7 @@ jobs:
path: |
~/.uplink/.user/debug.log
~/.uplinkUserB/.user/debug.log
~/.uplinkUserC/.user/debug.log
- name: Add label if any of test jobs failed
if: failure()
Expand Down
18 changes: 16 additions & 2 deletions config/wdio.mac.multiremote.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const MACOS_USER_A_BUNDLE_ID =
require("@helpers/constants").MACOS_USER_A_BUNDLE_ID;
const MACOS_USER_B_BUNDLE_ID =
require("@helpers/constants").MACOS_USER_B_BUNDLE_ID;
const MACOS_USER_C_BUNDLE_ID =
require("@helpers/constants").MACOS_USER_C_BUNDLE_ID;
const MACOS_DRIVER = require("@helpers/constants").MACOS_DRIVER;
const fsp = require("fs").promises;
const { readFileSync, rmSync } = require("fs");
Expand Down Expand Up @@ -57,7 +59,7 @@ export const config: WebdriverIO.Config = {
"appium:systemPort": 4725,
"appium:prerun": {
command:
'do shell script "rm -rf ~/.uplink && rm -rf ~/.uplinkUserB"',
'do shell script "rm -rf ~/.uplink && rm -rf ~/.uplinkUserB && rm -rf ~/.uplinkUserC"',
},
},
],
Expand Down Expand Up @@ -100,6 +102,7 @@ export const config: WebdriverIO.Config = {
onPrepare: async function () {
const cacheFolderUserA = homedir() + "/.uplink/.user";
const cacheFolderUserB = homedir() + "/.uplinkUserB/.user";
const cacheFolderUserC = homedir() + "/.uplinkUserC/.user";
const allureResultsFolder = join(process.cwd(), "./allure-results");
const testReportFolder = join(process.cwd(), "./test-report");
const testResultsFolder = join(process.cwd(), "./test-results");
Expand All @@ -116,6 +119,7 @@ export const config: WebdriverIO.Config = {
try {
await rmSync(cacheFolderUserA, { recursive: true, force: true });
await rmSync(cacheFolderUserB, { recursive: true, force: true });
await rmSync(cacheFolderUserC, { recursive: true, force: true });
console.log("Deleted Cache Folder Successfully!");
} catch (error) {
console.error(
Expand Down Expand Up @@ -157,16 +161,26 @@ export const config: WebdriverIO.Config = {
bundleId: MACOS_USER_B_BUNDLE_ID,
},
]);
await driver.executeScript("macos: terminateApp", [
{
bundleId: MACOS_USER_C_BUNDLE_ID,
},
]);
}
},
},

afterSuite: async function (suite) {
// Close second application if open
// Close second and third applications if open
await driver.executeScript("macos: terminateApp", [
{
bundleId: MACOS_USER_B_BUNDLE_ID,
},
]);
await driver.executeScript("macos: terminateApp", [
{
bundleId: MACOS_USER_C_BUNDLE_ID,
},
]);
},
};
46 changes: 43 additions & 3 deletions tests/helpers/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
MACOS_DRIVER,
MACOS_USER_A_BUNDLE_ID,
MACOS_USER_B_BUNDLE_ID,
MACOS_USER_C_BUNDLE_ID,
WINDOWS_APP,
WINDOWS_DRIVER,
} from "./constants";
Expand Down Expand Up @@ -209,7 +210,23 @@ export async function launchFirstApplication() {
}

export async function launchSecondApplication(existingUser: boolean = true) {
await launchAppMacOS(MACOS_USER_B_BUNDLE_ID, "/.uplinkUserB");
await launchAppMacOS(
MACOS_USER_B_BUNDLE_ID,
"/.uplinkUserB",
"/Applications/Uplink2.app",
);
await browser.pause(5000);
if (existingUser === true) {
await loginWithTestUser();
}
}

export async function launchThirdApplication(existingUser: boolean = true) {
await launchAppMacOS(
MACOS_USER_C_BUNDLE_ID,
"/.uplinkUserC",
"/Applications/Uplink3.app",
);
await browser.pause(5000);
if (existingUser === true) {
await loginWithTestUser();
Expand Down Expand Up @@ -242,6 +259,19 @@ export async function activateSecondApplication() {
}
}

export async function activateThirdApplication() {
if (process.env.DRIVER === WINDOWS_DRIVER) {
await activateAppWindows(WINDOWS_APP);
} else if (process.env.DRIVER === MACOS_DRIVER) {
const appState = await queryAppStateMacOS(MACOS_USER_C_BUNDLE_ID);
if (appState === 1) {
await launchThirdApplication();
} else {
await activateAppMacOS(MACOS_USER_C_BUNDLE_ID);
}
}
}

export async function closeApplication() {
if (process.env.DRIVER === WINDOWS_DRIVER) {
await closeAppWindows(WINDOWS_APP);
Expand All @@ -266,6 +296,14 @@ export async function closeSecondApplication() {
]);
}

export async function closeThirdApplication() {
await driver.executeScript("macos: terminateApp", [
{
bundleId: MACOS_USER_C_BUNDLE_ID,
},
]);
}

export async function maximizeWindow() {
if (process.env.DRIVER === WINDOWS_DRIVER) {
await $('[name="square-button"]').click();
Expand Down Expand Up @@ -308,12 +346,14 @@ export async function closeAppMacOS(bundle: string) {

export async function launchAppMacOS(
bundle: string,
relativePath: string = "/.uplink",
relativePathUserData: string = "/.uplink",
appPath: string = "/Applications/Uplink.app",
) {
await driver.executeScript("macos: launchApp", [
{
bundleId: bundle,
arguments: ["--path", homedir() + relativePath],
path: appPath,
arguments: ["--path", homedir() + relativePathUserData],
},
]);
}
Expand Down
1 change: 1 addition & 0 deletions tests/helpers/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const CHAT_USER_J_ID =
export const MACOS_BUNDLE_ID = "im.satellite.uplink";
export const MACOS_USER_A_BUNDLE_ID = "im.satellite.uplinkChatUserA";
export const MACOS_USER_B_BUNDLE_ID = "im.satellite.uplinkChatUserB";
export const MACOS_USER_C_BUNDLE_ID = "im.satellite.uplinkChatUserC";
export const MACOS_DRIVER = "mac2";
export const WINDOWS_APP = "C:\\Program Files\\uplink\\uplink.exe";
export const WINDOWS_DRIVER = "windows";
24 changes: 13 additions & 11 deletions tests/helpers/debugging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,20 @@ export async function setupBeforeCreateGroupTests() {

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

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

// Grab cache folder and restart
const didkeyA = await settingsProfile.getCopiedDidFromStatusInput();
await saveTestKeys(usernameA, didkeyA);
await settingsProfile.deleteStatus();

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

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

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

// Go to Notifications Settings and disable all notifications
Expand Down Expand Up @@ -83,19 +84,20 @@ export async function setupBeforeCreateGroupTests() {

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

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

// Grab cache folder and restart
const didkeyB = await settingsProfile.getCopiedDidFromStatusInput();
await saveTestKeys(usernameB, didkeyB);
await settingsProfile.deleteStatus();

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

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

// Click on font scaling minus
await settingsGeneral.waitForIsShown(true);
await settingsGeneral.clickOnFontScalingMinus();

// Go to Notifications Settings and disable all notifications
Expand Down Expand Up @@ -132,7 +134,7 @@ export async function setupBeforeCreateGroupTests() {
await friendsScreen.validateAllFriendsListIsNotEmpty();

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

// Switch control to User B
await activateSecondApplication();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import {
activateSecondApplication,
closeFirstApplication,
closeSecondApplication,
closeThirdApplication,
createNewUser,
getUserKey,
launchSecondApplication,
maximizeWindow,
launchThirdApplication,
saveTestKeys,
scrollDown,
} from "@helpers/commands";
Expand Down Expand Up @@ -395,10 +396,84 @@ export default async function createChatAccountsTests() {
// Return to chat and validate Local User Status is Idle
await settingsProfile.goToMainScreen();
await chatsInput.waitForIsShown(true);
await closeFirstApplication();
await closeSecondApplication();
});

it("Chat User C - Create Account", async () => {
// Launch third application
await launchThirdApplication(false);

// Create a new account and go to Settings Profile
await createPin.waitForIsShown(true);
const username = "ChatUserC";
await createNewUser(username);
await welcomeScreen.goToSettings();
await settingsProfile.validateSettingsProfileIsShown();

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

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

// Paste copied DID Key into Status Input
await settingsProfile.pasteUserKeyInStatus();

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

// Grab cache folder and restart
const didkey = await settingsProfile.getCopiedDidFromStatusInput();
await saveTestKeys(username, didkey);
await settingsProfile.deleteStatus();
});

it("Chat User C - Settings General - Reduce font size", async () => {
// Go to General Settings and reduce Font Size by 0.5
await settingsProfile.goToGeneralSettings();
await settingsGeneral.waitForIsShown(true);

// Click on font scaling minus
await settingsGeneral.clickOnFontScalingMinus();
});

it("Chat User C - Settings Developer - Enable Save Logs In A File", async () => {
// Go to Settings About and click 10 times on Version Number to Unlock Developer Settings
await settingsGeneral.goToAboutSettings();
await settingsAbout.waitForIsShown(true);
await settingsAbout.unlockDeveloperSettings();

// Validate Developer Settings button is unlocked
const developerSettingsButton = await settingsAbout.developerButton;
await developerSettingsButton.waitForDisplayed();

// Go to Menu from the left and Scroll Down
const settingsAboutButton = await settingsAbout.aboutButton;
await settingsAbout.hoverOnElement(settingsAboutButton);
await scrollDown(1000);

// Go to Settings Developer and Enable Save Logs in a File
await settingsAbout.goToDeveloperSettings();
await settingsDeveloper.waitForIsShown(true);
await settingsDeveloper.clickOnSaveLogs();
await settingsDeveloper.validateSaveLogsIsEnabled();
});

it("Chat User C - Settings Notifications - Disable notifications", async () => {
// Go to Notifications Settings and disable all notifications
await settingsDeveloper.goToNotificationsSettings();
await settingsNotifications.validateSettingsNotificationsIsShown();
await settingsNotifications.clickOnFriendsNotifications();
await settingsNotifications.clickOnMessagesNotifications();

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

after(async () => {
await closeFirstApplication();
await closeSecondApplication();
await closeThirdApplication();
});
}
16 changes: 9 additions & 7 deletions tests/specs/reusable-accounts/02-chat-replies.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import {
activateFirstApplication,
closeFirstApplication,
closeSecondApplication,
closeThirdApplication,
launchFirstApplication,
launchSecondApplication,
launchThirdApplication,
} from "@helpers/commands";
const chatsContextMenu = new ContextMenu();
const chatsInput = new InputBar();
Expand All @@ -27,13 +29,6 @@ export default async function repliesTests() {
await launchSecondApplication();
});

it("Chat User B - Validate User Status changes are seen in remote side", async () => {
// Validate Chat User B is now Idle
const firstRemoteStatus =
await messageGroupRemote.getLastGroupWrapReceivedCurrentStatus();
await expect(firstRemoteStatus).toEqual("indicator-idle");
});

it("Chat User B - Reply popup - Validate contents and close it", async () => {
// Open Context Menu on Last Message Received and select Reply
await messageRemote.openContextMenuOnReceivedMessage("Testing...😀");
Expand Down Expand Up @@ -84,6 +79,13 @@ export default async function repliesTests() {
await userImage.waitForExist();
});

it("Chat User B - Validate User Status changes are seen in remote side", async () => {
// Validate Chat User B is now Idle
const firstRemoteStatus =
await messageGroupRemote.getLastGroupWrapReceivedCurrentStatus();
await expect(firstRemoteStatus).toEqual("indicator-idle");
});

it("Chat User A - Validate reply message contents", async () => {
// Switch control to User A
await activateFirstApplication();
Expand Down
Loading

0 comments on commit 67d44b3

Please sign in to comment.