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

test(add): add tests to bypass recovery seed screens #585

Merged
merged 2 commits into from
Jan 4, 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
10 changes: 10 additions & 0 deletions tests/helpers/commands.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
require("module-alias/register");
import CreateOrImportScreen from "@screenobjects/account-creation/CreateOrImportScreen";
import CreatePinScreen from "@screenobjects/account-creation/CreatePinScreen";
import CreateUserScreen from "@screenobjects/account-creation/CreateUserScreen";
import FriendsScreen from "@screenobjects/friends/FriendsScreen";
import SaveRecoverySeedScreen from "@screenobjects/account-creation/SaveRecoverySeedScreen";
import WelcomeScreen from "@screenobjects/welcome-screen/WelcomeScreen";
import { homedir } from "os";
import { join } from "path";
Expand All @@ -17,9 +19,11 @@ 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");
const createOrImport = new CreateOrImportScreen();
let createPin = new CreatePinScreen();
let createUser = new CreateUserScreen();
let friendsScreen = new FriendsScreen();
const saveRecoverySeed = new SaveRecoverySeedScreen();
let welcomeScreen = new WelcomeScreen();

// Users cache helper functions
Expand Down Expand Up @@ -106,6 +110,12 @@ export async function createNewUser(username: string) {
await createPin.createAccountButton.waitForEnabled();
await createPin.clickOnCreateAccount();

// Bypass new Recovery Seed Screens
await createOrImport.waitForIsShown(true);
await createOrImport.clickOnCreateAccount();
await saveRecoverySeed.waitForIsShown(true);
await saveRecoverySeed.clickOnISavedItButton();

// Enter Username and click on Create Account
await createUser.enterUsername(username);
await createUser.createAccountButton.waitForEnabled();
Expand Down
72 changes: 72 additions & 0 deletions tests/screenobjects/account-creation/CreateOrImportScreen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
require("module-alias/register");
import UplinkMainScreen from "@screenobjects/UplinkMainScreen";
import { WINDOWS_DRIVER } from "@helpers/constants";

const currentOS = driver.capabilities.automationName;
let SELECTORS = {};

const SELECTORS_COMMON = {};

const SELECTORS_WINDOWS = {
CREATE_NEW_ACCOUNT_BUTTON: "<Button>[1]",
CREATE_OR_RECOVER_LABEL: '[name="create-or-recover"]',
CREATE_OR_RECOVER_LABEL_TEXT: "<Text>",
IMPORT_ACCOUNT_BUTTON: "<Button>[2]",
RECOVERY_LAYOUT: '[name="create-or-recover-layout"]',
RECOVERY_PARAGRAPH:
'//Group/Text[contains(@Name, "going to create an account")]',
};

const SELECTORS_MACOS = {
CREATE_NEW_ACCOUNT_BUTTON: "-ios class chain:**/XCUIElementTypeButton[1]",
CREATE_OR_RECOVER_LABEL: "~create-or-recover",
CREATE_OR_RECOVER_LABEL_TEXT: "-ios class chain:**/XCUIElementTypeStaticText",
IMPORT_ACCOUNT_BUTTON: "-ios class chain:**/XCUIElementTypeButton[2]",
RECOVERY_LAYOUT: "~create-or-recover-layout",
RECOVERY_PARAGRAPH:
'-ios class chain:**/XCUIElementTypeGroup/XCUIElementTypeStaticText[`value CONTAINS[cd] "going to create an account"`]',
};

currentOS === WINDOWS_DRIVER
? (SELECTORS = { ...SELECTORS_WINDOWS, ...SELECTORS_COMMON })
: (SELECTORS = { ...SELECTORS_MACOS, ...SELECTORS_COMMON });

export default class CreateOrImportScreen extends UplinkMainScreen {
constructor() {
super(SELECTORS.RECOVERY_LAYOUT);
}

get createNewAccountButton() {
return this.recoveryLayout.$(SELECTORS.CREATE_NEW_ACCOUNT_BUTTON);
}

get createOrRecoverLabel() {
return this.recoveryLayout.$(SELECTORS.CREATE_OR_RECOVER_LABEL);
}

get createOrRecoverLabelText() {
return this.createOrRecoverLabel.$(SELECTORS.CREATE_OR_RECOVER_LABEL_TEXT);
}

get importAccountButton() {
return this.recoveryLayout.$(SELECTORS.IMPORT_ACCOUNT_BUTTON);
}

get recoveryLayout() {
return $(SELECTORS.RECOVERY_LAYOUT);
}

get recoveryParagraph() {
return this.recoveryLayout.$(SELECTORS.RECOVERY_PARAGRAPH);
}

async clickOnCreateAccount() {
const createAccountButton = await this.createNewAccountButton;
await createAccountButton.click();
}

async clickOnImportAccount() {
const importAccountButton = await this.importAccountButton;
await importAccountButton.click();
}
}
6 changes: 6 additions & 0 deletions tests/screenobjects/account-creation/CreateUserScreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,18 @@ const SELECTORS_COMMON = {

const SELECTORS_WINDOWS = {
CREATE_ACCOUNT_BUTTON: '[name="create-account-button"]',
CREATE_USER_HELPER_TEXT: '//Group/Text[contains(@Name, "Time to pick")]',
CREATE_USER_LABEL_TEXT: "//Text/Text",
INPUT_ERROR: '[name="input-error"]',
INPUT_ERROR_TEXT: "<Text>",
};

const SELECTORS_MACOS = {
CREATE_ACCOUNT_BUTTON: "~create-account-button",
CREATE_USER_HELPER_TEXT:
'-ios class chain:**/XCUIElementTypeGroup/XCUIElementTypeStaticText[`value CONTAINS[cd] "Time to pick"`]',
CREATE_USER_LABEL_TEXT:
"-ios class chain:**/XCUIElementTypeStaticText/XCUIElementTypeStaticText",
INPUT_ERROR: "~input-error",
INPUT_ERROR_TEXT: "-ios class chain:**/XCUIElementTypeStaticText",
};
Expand Down
83 changes: 83 additions & 0 deletions tests/screenobjects/account-creation/EnterRecoverySeedScreen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
require("module-alias/register");
import UplinkMainScreen from "@screenobjects/UplinkMainScreen";
import { WINDOWS_DRIVER } from "@helpers/constants";

const currentOS = driver.capabilities.automationName;
let SELECTORS = {};

const SELECTORS_COMMON = {};

const SELECTORS_WINDOWS = {
ENTER_SEEDS_WORD_LAYOUT: '[name="enter-seed-words-layout"]',
GO_BACK_BUTTON: '[name="back-button"]',
RECOVER_ACCOUNT_BUTTON: "<Button>[2]",
RECOVERY_SEED_HELPER_TEXT:
'//Group/Text[contains(@Name, "Type your recovery seed")]',
RECOVERY_SEED_INPUT: "<Edit>",
RECOVERY_SEED_TITLE: '[name="enter-seed-words"]',
RECOVERY_SEED_TITLE_TEXT: "<Text>",
};

const SELECTORS_MACOS = {
ENTER_SEEDS_WORD_LAYOUT: "~enter-seed-words-layout",
GO_BACK_BUTTON: "~back-button",
RECOVER_ACCOUNT_BUTTON: "-ios class chain:**/XCUIElementTypeButton[2]",
RECOVERY_SEED_HELPER_TEXT:
'-ios class chain:**/XCUIElementTypeGroup/XCUIElementTypeStaticText[`value CONTAINS[cd] "Type your recovery seed"`]',
RECOVERY_SEED_INPUT: "-ios class chain:**/XCUIElementTypeTextField",
RECOVERY_SEED_TITLE: "~enter-seed-words",
RECOVERY_SEED_TITLE_TEXT: "<Text>",
};

currentOS === WINDOWS_DRIVER
? (SELECTORS = { ...SELECTORS_WINDOWS, ...SELECTORS_COMMON })
: (SELECTORS = { ...SELECTORS_MACOS, ...SELECTORS_COMMON });

export default class EnterRecoverySeedScreen extends UplinkMainScreen {
constructor() {
super(SELECTORS.ENTER_SEEDS_WORD_LAYOUT);
}

get enterSeedsWordLayout() {
return $(SELECTORS.ENTER_SEEDS_WORD_LAYOUT);
}

get goBackButton() {
return this.enterSeedsWordLayout.$(SELECTORS.GO_BACK_BUTTON);
}

get recoverAccountButton() {
return this.enterSeedsWordLayout.$(SELECTORS.RECOVER_ACCOUNT_BUTTON);
}

get recoverySeedHelperText() {
return this.enterSeedsWordLayout.$(SELECTORS.RECOVERY_SEED_HELPER_TEXT);
}

get recoverySeedInput() {
return this.enterSeedsWordLayout.$(SELECTORS.RECOVERY_SEED_INPUT);
}

get recoverySeedTitle() {
return this.enterSeedsWordLayout.$(SELECTORS.RECOVERY_SEED_TITLE);
}

get recoverySeedTitleText() {
return this.recoverySeedTitle.$(SELECTORS.RECOVERY_SEED_TITLE_TEXT);
}

async clickOnBackButton() {
const goBackButton = await this.goBackButton;
await goBackButton.click();
}

async clickOnRecoverAccountButton() {
const recoverAccountButton = await this.recoverAccountButton;
await recoverAccountButton.click();
}

async typeOnRecoverySeedInput(seed: string) {
const recoverySeedInput = await this.recoverySeedInput;
await recoverySeedInput.setValue(seed);
}
}
72 changes: 72 additions & 0 deletions tests/screenobjects/account-creation/SaveRecoverySeedScreen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
require("module-alias/register");
import UplinkMainScreen from "@screenobjects/UplinkMainScreen";
import { WINDOWS_DRIVER } from "@helpers/constants";

const currentOS = driver.capabilities.automationName;
let SELECTORS = {};

const SELECTORS_COMMON = {};

const SELECTORS_WINDOWS = {
COPY_SEED_HELPER_TEXT:
'//Group/Text[contains(@Name, "Write these words down")]',
COPY_SEED_WORDS_LABEL: '[name="copy-seed-words"]',
COPY_SEED_WORDS_LABEL_TEXT: "<Text>>",
COPY_SEED_WORDS_LAYOUT: '[name="copy-seed-words-layout"]',
GO_BACK_BUTTON: '[name="back-button"]',
I_SAVED_IT_BUTTON: "<Button>[2]",
};

const SELECTORS_MACOS = {
COPY_SEED_HELPER_TEXT:
'-ios class chain:**/XCUIElementTypeGroup/XCUIElementTypeStaticText[`value CONTAINS[cd] "Write these words down"`]',
COPY_SEED_WORDS_LABEL: "~copy-seed-words",
COPY_SEED_WORDS_LABEL_TEXT: "-ios class chain:**/XCUIElementTypeStaticText",
COPY_SEED_WORDS_LAYOUT: "~copy-seed-words-layout",
GO_BACK_BUTTON: "~back-button",
I_SAVED_IT_BUTTON: "-ios class chain:**/XCUIElementTypeButton[2]",
};

currentOS === WINDOWS_DRIVER
? (SELECTORS = { ...SELECTORS_WINDOWS, ...SELECTORS_COMMON })
: (SELECTORS = { ...SELECTORS_MACOS, ...SELECTORS_COMMON });

export default class SaveRecoverySeedScreen extends UplinkMainScreen {
constructor() {
super(SELECTORS.COPY_SEED_WORDS_LAYOUT);
}

get copySeedHelperText() {
return this.copySeedsWordsLayout.$(SELECTORS.COPY_SEED_HELPER_TEXT);
}

get copySeedWordsLabel() {
return this.copySeedsWordsLayout.$(SELECTORS.COPY_SEED_WORDS_LABEL);
}

get copySeedWordsLabelText() {
return this.copySeedWordsLabel.$(SELECTORS.COPY_SEED_WORDS_LABEL_TEXT);
}

get copySeedsWordsLayout() {
return $(SELECTORS.COPY_SEED_WORDS_LAYOUT);
}

get goBackButton() {
return this.copySeedsWordsLayout.$(SELECTORS.GO_BACK_BUTTON);
}

get iSavedItButton() {
return this.copySeedsWordsLayout.$(SELECTORS.I_SAVED_IT_BUTTON);
}

async clickOnGoBackButton() {
const goBackButton = await this.goBackButton;
await goBackButton.click();
}

async clickOnISavedItButton() {
const iSavedItButton = await this.iSavedItButton;
await iSavedItButton.click();
}
}
11 changes: 11 additions & 0 deletions tests/specs/01-create-account.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
require("module-alias/register");
import { maximizeWindow } from "@helpers/commands";
import CreateOrImportScreen from "@screenobjects/account-creation/CreateOrImportScreen";
import CreatePinScreen from "@screenobjects/account-creation/CreatePinScreen";
import CreateUserScreen from "@screenobjects/account-creation/CreateUserScreen";
import SaveRecoverySeedScreen from "@screenobjects/account-creation/SaveRecoverySeedScreen";
import WelcomeScreen from "@screenobjects/welcome-screen/WelcomeScreen";
const createOrImport = new CreateOrImportScreen();
const createPin = new CreatePinScreen();
const createUser = new CreateUserScreen();
const saveRecoverySeed = new SaveRecoverySeedScreen();
const welcomeScreen = new WelcomeScreen();

export default async function createAccountTests() {
Expand Down Expand Up @@ -109,6 +113,13 @@ export default async function createAccountTests() {
const statusOfButton = await createPin.getStatusOfCreateAccountButton();
await expect(statusOfButton).toEqual("true");
await createPin.clickOnCreateAccount();
});

it("Create or Import Account Screen - Click on Create New Account and save receovery seed", async () => {
await createOrImport.waitForIsShown(true);
await createOrImport.clickOnCreateAccount();
await saveRecoverySeed.waitForIsShown(true);
await saveRecoverySeed.clickOnISavedItButton();
await createUser.waitForIsShown(true);
});

Expand Down
Loading