From d8e32d38fdff981382fe8aba1fef3a06cbf89b2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Carden=CC=83a?= <35935591+luisecm@users.noreply.github.com> Date: Mon, 22 Jan 2024 16:37:00 -0600 Subject: [PATCH 1/3] test(add): add test for offline friend requests --- tests/helpers/commands.ts | 9 +- tests/specs/16-import-account.spec.ts | 131 +++++++++++++++++++++++++- 2 files changed, 135 insertions(+), 5 deletions(-) diff --git a/tests/helpers/commands.ts b/tests/helpers/commands.ts index 25096bbe10..296986e64c 100644 --- a/tests/helpers/commands.ts +++ b/tests/helpers/commands.ts @@ -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 @@ -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 diff --git a/tests/specs/16-import-account.spec.ts b/tests/specs/16-import-account.spec.ts index 8fd7f7194b..5a582a42a0 100644 --- a/tests/specs/16-import-account.spec.ts +++ b/tests/specs/16-import-account.spec.ts @@ -1,16 +1,54 @@ require("module-alias/register"); -import { getUserRecoverySeed, resetApp } from "@helpers/commands"; +import { + createNewUser, + getUserKey, + getUserRecoverySeed, + grabCacheFolder, + resetApp, + saveTestKeys, +} from "@helpers/commands"; import CreateOrImportScreen from "@screenobjects/account-creation/CreateOrImportScreen"; import CreatePinScreen from "@screenobjects/account-creation/CreatePinScreen"; import EnterRecoverySeedScreen from "@screenobjects/account-creation/EnterRecoverySeedScreen"; +import FriendsScreen from "@screenobjects/friends/FriendsScreen"; +import SettingsProfileScreen from "@screenobjects/settings/SettingsProfileScreen"; import WelcomeScreen from "@screenobjects/welcome-screen/WelcomeScreen"; const createOrImport = new CreateOrImportScreen(); const createPin = new CreatePinScreen(); const enterRecoverySeed = new EnterRecoverySeedScreen(); +const friendsScreen = new FriendsScreen(); +const settingsProfile = new SettingsProfileScreen(); const welcomeScreen = new WelcomeScreen(); export default async function importAccountTests() { - it("Enter Pin Screen - Clear cache, reset app and enter a valid pin", async () => { + // Wait until toast notification is closed + it("Offline Friend Requests - Create reusable account for User B", async () => { + // Create New User and go to Settings Profile Screen + const username = "UserB"; + await createNewUser(username, true); + await welcomeScreen.goToSettings(); + await settingsProfile.waitForIsShown(true); + }); + + it("Offline Friend Requests - Save test account for User B", async () => { + const username = "UserB"; + // Click on Copy ID button and assert Toast Notification is displayed + 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(username, didkey); + await grabCacheFolder(username); + }); + + it("Import Account - Clear cache, reset app and enter a valid pin", async () => { // Clear cache and reset app await resetApp(); @@ -21,7 +59,7 @@ export default async function importAccountTests() { await createPin.clickOnCreateAccount(); }); - it("Enter Recovery Seed - Validate Screen Contents", async () => { + it("Import Account - Validate Screen Contents", async () => { // Validate Create or Import Account is displayed await createOrImport.waitForIsShown(true); @@ -38,10 +76,95 @@ export default async function importAccountTests() { await expect(screenTitle).toHaveTextContaining("RECOVERY SEED"); }); - it("Save Recovery Seed Screen - Enter valid recovery seed and continue", async () => { + it("Import Account - Enter valid recovery seed and continue", async () => { + const recoverySeed = await getUserRecoverySeed("Test123"); + await enterRecoverySeed.typeOnRecoverySeedInput(recoverySeed); + await enterRecoverySeed.clickOnRecoverAccountButton(); + await welcomeScreen.waitForIsShown(true); + }); + + it("Offline Friend Request - Send Friend Request to UserB", async () => { + // Obtain did key from Chat User B + const friendDidKey = await getUserKey("UserB"); + await friendsScreen.sendFriendRequest(friendDidKey, "UserB"); + + // Go to All Friends List + await friendsScreen.goToAllFriendsList(); + await friendsScreen.validateAllFriendsListIsShown(); + }); + + it("Offline Friend Request - Accept offline friend request received", async () => { + // Clear cache and reset app + await resetApp(); + + // Restore account from UserB + await createPin.waitForIsShown(true); + await createPin.enterPin("1234"); + await createPin.waitUntilCreateAccountButtonIsEnabled(); + await createPin.clickOnCreateAccount(); + + // Validate Create or Import Account is displayed + await createOrImport.waitForIsShown(true); + + // Click on Import Account + await createOrImport.clickOnImportAccount(); + + // Validate contents of Enter Recovery Seed Screen + await enterRecoverySeed.waitForIsShown(true); + + // Enter Recovery Seed and Continue + const recoverySeed = await getUserRecoverySeed("UserB"); + await enterRecoverySeed.typeOnRecoverySeedInput(recoverySeed); + await enterRecoverySeed.clickOnRecoverAccountButton(); + await welcomeScreen.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("Test123"); + + // Validate friend is now on all friends list + await friendsScreen.goToAllFriendsList(); + await friendsScreen.validateAllFriendsListIsShown(); + await friendsScreen.validateAllFriendsListIsNotEmpty(); + + // Go to Chat with Test123 + await friendsScreen.chatWithFriendButton.click(); + }); + + it("Offline Friend Request - Validate offline friend request was accepted", async () => { + // Clear cache and reset app + await resetApp(); + + // Restore account from UserB + await createPin.waitForIsShown(true); + await createPin.enterPin("1234"); + await createPin.waitUntilCreateAccountButtonIsEnabled(); + await createPin.clickOnCreateAccount(); + + // Validate Create or Import Account is displayed + await createOrImport.waitForIsShown(true); + + // Click on Import Account + await createOrImport.clickOnImportAccount(); + + // Validate contents of Enter Recovery Seed Screen + await enterRecoverySeed.waitForIsShown(true); + + // Enter Recovery Seed and Continue const recoverySeed = await getUserRecoverySeed("Test123"); await enterRecoverySeed.typeOnRecoverySeedInput(recoverySeed); await enterRecoverySeed.clickOnRecoverAccountButton(); await welcomeScreen.waitForIsShown(true); + + // With UserB - Go to pending requests list, wait for receiving the friend request and accept it + await friendsScreen.waitUntilUserAcceptedFriendRequest(); + + // Validate friend is now on all friends list + await friendsScreen.goToAllFriendsList(); + await friendsScreen.validateAllFriendsListIsShown(); + await friendsScreen.validateAllFriendsListIsNotEmpty(); }); } From 296b3bc2a9ab0d33ab88c9862cdd1a12b1d1d136 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Carden=CC=83a?= <35935591+luisecm@users.noreply.github.com> Date: Mon, 22 Jan 2024 17:33:41 -0600 Subject: [PATCH 2/3] test(update): fixing test to include correct assertions --- tests/specs/16-import-account.spec.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/specs/16-import-account.spec.ts b/tests/specs/16-import-account.spec.ts index 5a582a42a0..8db00f64f1 100644 --- a/tests/specs/16-import-account.spec.ts +++ b/tests/specs/16-import-account.spec.ts @@ -23,6 +23,9 @@ const welcomeScreen = new WelcomeScreen(); export default async function importAccountTests() { // Wait until toast notification is closed it("Offline Friend Requests - Create reusable account for User B", async () => { + // Clear cache and reset app + await resetApp(); + // Create New User and go to Settings Profile Screen const username = "UserB"; await createNewUser(username, true); From 5a0a107e242e63e331b9760c282a8f06ccd16f84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Carden=CC=83a?= <35935591+luisecm@users.noreply.github.com> Date: Tue, 23 Jan 2024 12:30:52 -0600 Subject: [PATCH 3/3] test(update): created test for offline friend requests and skipping --- tests/specs/16-import-account.spec.ts | 134 +----------------- tests/specs/17-offline-requests.spec.ts | 130 +++++++++++++++++ .../suites/MainTests/01-UplinkTests.suite.ts | 2 + .../MainTests/02-UplinkWindows.suite.ts | 2 + 4 files changed, 138 insertions(+), 130 deletions(-) create mode 100644 tests/specs/17-offline-requests.spec.ts diff --git a/tests/specs/16-import-account.spec.ts b/tests/specs/16-import-account.spec.ts index 8db00f64f1..8fd7f7194b 100644 --- a/tests/specs/16-import-account.spec.ts +++ b/tests/specs/16-import-account.spec.ts @@ -1,57 +1,16 @@ require("module-alias/register"); -import { - createNewUser, - getUserKey, - getUserRecoverySeed, - grabCacheFolder, - resetApp, - saveTestKeys, -} from "@helpers/commands"; +import { getUserRecoverySeed, resetApp } from "@helpers/commands"; import CreateOrImportScreen from "@screenobjects/account-creation/CreateOrImportScreen"; import CreatePinScreen from "@screenobjects/account-creation/CreatePinScreen"; import EnterRecoverySeedScreen from "@screenobjects/account-creation/EnterRecoverySeedScreen"; -import FriendsScreen from "@screenobjects/friends/FriendsScreen"; -import SettingsProfileScreen from "@screenobjects/settings/SettingsProfileScreen"; import WelcomeScreen from "@screenobjects/welcome-screen/WelcomeScreen"; const createOrImport = new CreateOrImportScreen(); const createPin = new CreatePinScreen(); const enterRecoverySeed = new EnterRecoverySeedScreen(); -const friendsScreen = new FriendsScreen(); -const settingsProfile = new SettingsProfileScreen(); const welcomeScreen = new WelcomeScreen(); export default async function importAccountTests() { - // Wait until toast notification is closed - it("Offline Friend Requests - Create reusable account for User B", async () => { - // Clear cache and reset app - await resetApp(); - - // Create New User and go to Settings Profile Screen - const username = "UserB"; - await createNewUser(username, true); - await welcomeScreen.goToSettings(); - await settingsProfile.waitForIsShown(true); - }); - - it("Offline Friend Requests - Save test account for User B", async () => { - const username = "UserB"; - // Click on Copy ID button and assert Toast Notification is displayed - 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(username, didkey); - await grabCacheFolder(username); - }); - - it("Import Account - Clear cache, reset app and enter a valid pin", async () => { + it("Enter Pin Screen - Clear cache, reset app and enter a valid pin", async () => { // Clear cache and reset app await resetApp(); @@ -62,7 +21,7 @@ export default async function importAccountTests() { await createPin.clickOnCreateAccount(); }); - it("Import Account - Validate Screen Contents", async () => { + it("Enter Recovery Seed - Validate Screen Contents", async () => { // Validate Create or Import Account is displayed await createOrImport.waitForIsShown(true); @@ -79,95 +38,10 @@ export default async function importAccountTests() { await expect(screenTitle).toHaveTextContaining("RECOVERY SEED"); }); - it("Import Account - Enter valid recovery seed and continue", async () => { + it("Save Recovery Seed Screen - Enter valid recovery seed and continue", async () => { const recoverySeed = await getUserRecoverySeed("Test123"); await enterRecoverySeed.typeOnRecoverySeedInput(recoverySeed); await enterRecoverySeed.clickOnRecoverAccountButton(); await welcomeScreen.waitForIsShown(true); }); - - it("Offline Friend Request - Send Friend Request to UserB", async () => { - // Obtain did key from Chat User B - const friendDidKey = await getUserKey("UserB"); - await friendsScreen.sendFriendRequest(friendDidKey, "UserB"); - - // Go to All Friends List - await friendsScreen.goToAllFriendsList(); - await friendsScreen.validateAllFriendsListIsShown(); - }); - - it("Offline Friend Request - Accept offline friend request received", async () => { - // Clear cache and reset app - await resetApp(); - - // Restore account from UserB - await createPin.waitForIsShown(true); - await createPin.enterPin("1234"); - await createPin.waitUntilCreateAccountButtonIsEnabled(); - await createPin.clickOnCreateAccount(); - - // Validate Create or Import Account is displayed - await createOrImport.waitForIsShown(true); - - // Click on Import Account - await createOrImport.clickOnImportAccount(); - - // Validate contents of Enter Recovery Seed Screen - await enterRecoverySeed.waitForIsShown(true); - - // Enter Recovery Seed and Continue - const recoverySeed = await getUserRecoverySeed("UserB"); - await enterRecoverySeed.typeOnRecoverySeedInput(recoverySeed); - await enterRecoverySeed.clickOnRecoverAccountButton(); - await welcomeScreen.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("Test123"); - - // Validate friend is now on all friends list - await friendsScreen.goToAllFriendsList(); - await friendsScreen.validateAllFriendsListIsShown(); - await friendsScreen.validateAllFriendsListIsNotEmpty(); - - // Go to Chat with Test123 - await friendsScreen.chatWithFriendButton.click(); - }); - - it("Offline Friend Request - Validate offline friend request was accepted", async () => { - // Clear cache and reset app - await resetApp(); - - // Restore account from UserB - await createPin.waitForIsShown(true); - await createPin.enterPin("1234"); - await createPin.waitUntilCreateAccountButtonIsEnabled(); - await createPin.clickOnCreateAccount(); - - // Validate Create or Import Account is displayed - await createOrImport.waitForIsShown(true); - - // Click on Import Account - await createOrImport.clickOnImportAccount(); - - // Validate contents of Enter Recovery Seed Screen - await enterRecoverySeed.waitForIsShown(true); - - // Enter Recovery Seed and Continue - const recoverySeed = await getUserRecoverySeed("Test123"); - await enterRecoverySeed.typeOnRecoverySeedInput(recoverySeed); - await enterRecoverySeed.clickOnRecoverAccountButton(); - await welcomeScreen.waitForIsShown(true); - - // With UserB - Go to pending requests list, wait for receiving the friend request and accept it - await friendsScreen.waitUntilUserAcceptedFriendRequest(); - - // Validate friend is now on all friends list - await friendsScreen.goToAllFriendsList(); - await friendsScreen.validateAllFriendsListIsShown(); - await friendsScreen.validateAllFriendsListIsNotEmpty(); - }); } diff --git a/tests/specs/17-offline-requests.spec.ts b/tests/specs/17-offline-requests.spec.ts new file mode 100644 index 0000000000..d6bde520d3 --- /dev/null +++ b/tests/specs/17-offline-requests.spec.ts @@ -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(); + }); +} diff --git a/tests/suites/MainTests/01-UplinkTests.suite.ts b/tests/suites/MainTests/01-UplinkTests.suite.ts index 06b4242c07..3e973d7923 100644 --- a/tests/suites/MainTests/01-UplinkTests.suite.ts +++ b/tests/suites/MainTests/01-UplinkTests.suite.ts @@ -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)); @@ -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)); }); diff --git a/tests/suites/MainTests/02-UplinkWindows.suite.ts b/tests/suites/MainTests/02-UplinkWindows.suite.ts index 06b4242c07..3e973d7923 100644 --- a/tests/suites/MainTests/02-UplinkWindows.suite.ts +++ b/tests/suites/MainTests/02-UplinkWindows.suite.ts @@ -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)); @@ -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)); });