Skip to content

Commit

Permalink
Merge pull request #608 from Satellite-im/luis/offline-friends
Browse files Browse the repository at this point in the history
test(add): add test for offline friend requests
  • Loading branch information
luisecm authored Jan 23, 2024
2 parents c1be82b + 5a0a107 commit e5a4acb
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tests/helpers/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ export async function saveTestKeys(username: string, didkey: string) {

// Login or Create Users Functions

export async function createNewUser(username: string) {
export async function createNewUser(
username: string,
saveSeedWords: boolean = false,
) {
await createPin.unlockLayout.waitForExist();

// Enter pin for test user
Expand All @@ -114,6 +117,10 @@ export async function createNewUser(username: string) {
await createOrImport.waitForIsShown(true);
await createOrImport.clickOnCreateAccount();
await saveRecoverySeed.waitForIsShown(true);
if (saveSeedWords === true) {
const recoverySeed = await saveRecoverySeed.getSeedWords();
await saveUserRecoverySeed(username, recoverySeed);
}
await saveRecoverySeed.clickOnISavedItButton();

// Enter Username and click on Create Account
Expand Down
130 changes: 130 additions & 0 deletions tests/specs/17-offline-requests.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
require("module-alias/register");
import {
createNewUser,
getUserKey,
grabCacheFolder,
resetApp,
resetAndLoginWithCache,
saveTestKeys,
} from "@helpers/commands";
import FriendsScreen from "@screenobjects/friends/FriendsScreen";
import SettingsProfileScreen from "@screenobjects/settings/SettingsProfileScreen";
import WelcomeScreen from "@screenobjects/welcome-screen/WelcomeScreen";
const friendsScreen = new FriendsScreen();
const settingsProfile = new SettingsProfileScreen();
const welcomeScreen = new WelcomeScreen();
const userA: string = "UserA";
const userB: string = "UserB";

export default async function offlineRequestsTests() {
it("Offline Friend Requests - Create test account #1", async () => {
// Create New User and go to Settings Profile Screen
await resetApp();
await createNewUser(userA, true);
await welcomeScreen.goToSettings();
await settingsProfile.waitForIsShown(true);
});

it("Offline Friend Requests - Save test account #1 data", async () => {
// Click on Copy ID button and assert Toast Notification is displayed
await welcomeScreen.goToSettings();
await settingsProfile.waitForIsShown(true);
await settingsProfile.openCopyIDContextMenu();
await settingsProfile.clickOnContextMenuCopyDidKey();

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

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

// Grab cache folder and restart
await saveTestKeys(userA, didkey);

// Update profile picture from user A

// Update banner picture from user A
await grabCacheFolder(userA);
});

// Wait until toast notification is closed
it("Offline Friend Requests - Create account user #2", async () => {
// Create New User and go to Settings Profile Screen
await resetApp();
await createNewUser(userB, true);
await welcomeScreen.goToFriends();
});

it("Offline Friend Requests - Send Friend Request to user #1", async () => {
// Obtain did key from User #1
const friendDidKey = await getUserKey(userA);
await friendsScreen.sendFriendRequest(friendDidKey, userA);

// Go to All Friends List
await friendsScreen.goToAllFriendsList();
await friendsScreen.validateAllFriendsListIsShown();
});

it("Offline Friend Requests - Save test account #2 data", async () => {
// Click on Copy ID button and assert Toast Notification is displayed
await friendsScreen.goToSettings();
await settingsProfile.waitForIsShown(true);
await settingsProfile.openCopyIDContextMenu();
await settingsProfile.clickOnContextMenuCopyDidKey();

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

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

// Grab cache folder and restart
await saveTestKeys(userB, didkey);
await grabCacheFolder(userB);
});

it("Offline Friend Requests - User #1 accepts offline friend request received", async () => {
// Clear cache and reset app
await resetAndLoginWithCache("UserA");

// Go to Friends Screen
await welcomeScreen.goToFriends();
await friendsScreen.waitForIsShown(true);

// With UserB - Go to pending requests list, wait for receiving the friend request and accept it
await friendsScreen.hoverOnPendingListButton();
await friendsScreen.goToPendingFriendsList();
await friendsScreen.validateIncomingListIsShown();
await friendsScreen.waitUntilFriendRequestIsReceived();
await friendsScreen.acceptIncomingRequest("UserB");

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

// Go to Chat with User #2
await friendsScreen.chatWithFriendButton.click();
});

it("Offline Friend Requests - Validate offline friend request was accepted", async () => {
// Clear cache and reset app
await resetAndLoginWithCache(userB);

// Go to Friends Screen
await welcomeScreen.goToFriends();
await friendsScreen.waitForIsShown(true);

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

// Validate friend is now on all friends list
await friendsScreen.goToAllFriendsList();
await friendsScreen.validateAllFriendsListIsShown();
await friendsScreen.validateAllFriendsListIsNotEmpty();
});
}
2 changes: 2 additions & 0 deletions tests/suites/MainTests/01-UplinkTests.suite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import settingsAboutTests from "@specs/11-settings-about.spec";
import settingsLicensesTests from "@specs/12-settings-licenses.spec";
import settingsDeveloperTests from "@specs/13-settings-developer.spec";
import importAccountTests from "@specs/16-import-account.spec";
import offlineRequestsTests from "@specs/17-offline-requests.spec";

describe("MacOS Tests", function () {
describe("Create Pin and Account Tests", createAccountTests.bind(this));
Expand All @@ -37,4 +38,5 @@ describe("MacOS Tests", function () {
describe("Settings Developer Tests", settingsDeveloperTests.bind(this));
describe("Friends Screen Tests", friendsTests.bind(this));
describe("Import Account Tests", importAccountTests.bind(this));
xdescribe("Offline Friend Requests", offlineRequestsTests.bind(this));
});
2 changes: 2 additions & 0 deletions tests/suites/MainTests/02-UplinkWindows.suite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import settingsAboutTests from "@specs/11-settings-about.spec";
import settingsLicensesTests from "@specs/12-settings-licenses.spec";
import settingsDeveloperTests from "@specs/13-settings-developer.spec";
import importAccountTests from "@specs/16-import-account.spec";
import offlineRequestsTests from "@specs/17-offline-requests.spec";

describe("MacOS Tests", function () {
describe("Create Pin and Account Tests", createAccountTests.bind(this));
Expand All @@ -37,4 +38,5 @@ describe("MacOS Tests", function () {
describe("Settings Developer Tests", settingsDeveloperTests.bind(this));
describe("Friends Screen Tests", friendsTests.bind(this));
describe("Import Account Tests", importAccountTests.bind(this));
xdescribe("Offline Friend Requests", offlineRequestsTests.bind(this));
});

0 comments on commit e5a4acb

Please sign in to comment.