Skip to content

Commit

Permalink
Merge branch 'dev' into luis/online-status
Browse files Browse the repository at this point in the history
  • Loading branch information
luisecm authored Mar 13, 2024
2 parents 64b6f07 + 6c32c9e commit cfd9704
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 15 deletions.
54 changes: 45 additions & 9 deletions tests/screenobjects/account-creation/EnterRecoverySeedScreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const SELECTORS_WINDOWS = {
RECOVERY_SEED_HELPER: '[name="instructions"]',
RECOVERY_SEED_HELPER_TEXT:
'//Text[contains(@Name, "Type your recovery seed")]',
RECOVERY_SEED_INPUT: '[name="recovery-seed-input"]',
RECOVERY_SEED_TITLE: '[name="enter-seed-words"]',
RECOVERY_SEED_TITLE_TEXT: '//Text[@Name="RECOVERY SEED"]',
};
Expand All @@ -28,7 +27,6 @@ const SELECTORS_MACOS = {
RECOVER_ACCOUNT_BUTTON: "~recover-account-button",
RECOVERY_SEED_HELPER: "~instructions",
RECOVERY_SEED_HELPER_TEXT: "-ios class chain:**/XCUIElementTypeStaticText",
RECOVERY_SEED_INPUT: "~recovery-seed-input",
RECOVERY_SEED_TITLE: "~enter-seed-words",
RECOVERY_SEED_TITLE_TEXT: "-ios class chain:**/XCUIElementTypeStaticText",
};
Expand Down Expand Up @@ -72,10 +70,6 @@ export default class EnterRecoverySeedScreen extends UplinkMainScreen {
return this.recoverySeedHelper.$(SELECTORS.RECOVERY_SEED_HELPER_TEXT);
}

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

get recoverySeedTitle() {
return this.enterSeedsWordLayout.$(SELECTORS.RECOVERY_SEED_TITLE);
}
Expand All @@ -94,8 +88,50 @@ export default class EnterRecoverySeedScreen extends UplinkMainScreen {
await recoverAccountButton.click();
}

async typeOnRecoverySeedInput(seed: string) {
const recoverySeedInput = await this.recoverySeedInput;
await recoverySeedInput.setValue(seed);
async getSeedWord(numberOfWord: string) {
const currentDriver = await this.getCurrentDriver();
let locatorOfWord: string = "";
let word: string = "";
if (currentDriver === WINDOWS_DRIVER) {
locatorOfWord = '[name="recovery-seed-input-' + numberOfWord + '"]';
} else {
locatorOfWord = "~recovery-seed-input-" + numberOfWord;
}
word = await $(locatorOfWord).$(SELECTORS.SEED_WORD_VALUE_TEXT).getText();
return word;
}

async getSeedWords() {
let seedWords: string[] = [];
for (let i = 1; i <= 12; i++) {
seedWords.push(await this.getSeedWord(i.toString()));
}
return seedWords;
}

async enterSeedWords(seedWords: string[]) {
const currentDriver = await this.getCurrentDriver();
for (let i = 1; i <= 12; i++) {
let locatorOfWord: string = "";
if (currentDriver === WINDOWS_DRIVER) {
locatorOfWord = '[name="recovery-seed-input-' + i + '"]';
} else {
locatorOfWord = "~recovery-seed-input-" + i;
}
const seedWord = await $(locatorOfWord);
await seedWord.setValue(seedWords[i - 1]);
}
}

async enterSingleSeedWord(seedWord: string, seedNumber: number) {
const currentDriver = await this.getCurrentDriver();
let locatorOfWord: string = "";
if (currentDriver === WINDOWS_DRIVER) {
locatorOfWord = '[name="recovery-seed-input-' + seedNumber + '"]';
} else {
locatorOfWord = "~recovery-seed-input-" + seedNumber;
}
const seed = await $(locatorOfWord);
await seed.setValue(seedWord);
}
}
11 changes: 11 additions & 0 deletions tests/screenobjects/account-creation/SaveRecoverySeedScreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ let SELECTORS = {};
const SELECTORS_COMMON = {};

const SELECTORS_WINDOWS = {
COPY_SEED_BUTTON: '[name="copy-seed-button"]',
COPY_SEED_HELPER_TEXT:
'//Group/Text[contains(@Name, "Write these words down")]',
COPY_SEED_WORDS_LABEL: '[name="copy-seed-words"]',
Expand All @@ -18,6 +19,7 @@ const SELECTORS_WINDOWS = {
};

const SELECTORS_MACOS = {
COPY_SEED_BUTTON: "~copy-seed-button",
COPY_SEED_HELPER_TEXT:
'-ios class chain:**/XCUIElementTypeGroup/XCUIElementTypeStaticText[`value CONTAINS[cd] "Write these words down"`]',
COPY_SEED_WORDS_LABEL: "~copy-seed-words",
Expand All @@ -37,6 +39,10 @@ export default class SaveRecoverySeedScreen extends UplinkMainScreen {
super(SELECTORS.COPY_SEED_WORDS_LAYOUT);
}

get copySeedButton() {
return this.copySeedsWordsLayout.$(SELECTORS.COPY_SEED_BUTTON);
}

get copySeedHelperText() {
return this.copySeedsWordsLayout.$(SELECTORS.COPY_SEED_HELPER_TEXT);
}
Expand All @@ -61,6 +67,11 @@ export default class SaveRecoverySeedScreen extends UplinkMainScreen {
return this.copySeedsWordsLayout.$(SELECTORS.I_SAVED_IT_BUTTON);
}

async clickOnCopySeedButton() {
const copySeedButton = await this.copySeedButton;
await copySeedButton.click();
}

async clickOnGoBackButton() {
const goBackButton = await this.goBackButton;
await goBackButton.click();
Expand Down
3 changes: 2 additions & 1 deletion tests/specs/01-create-account.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,10 @@ export default async function createAccountTests() {
await createOrImport.clickOnCreateAccount();
});

it("Save Recovery Seed Screen - User can click on I Saved It to continue", async () => {
it("Save Recovery Seed Screen - User can click Copy to Clipboard and then on I Saved It to continue", async () => {
// Click on I Saved It Button to continue to Enter Username Screen
await saveRecoverySeed.waitForIsShown(true);
await saveRecoverySeed.clickOnCopySeedButton();
const recoverySeed = await saveRecoverySeed.getSeedWords();
await saveUserRecoverySeed("Test123", recoverySeed);
await saveRecoverySeed.clickOnISavedItButton();
Expand Down
10 changes: 5 additions & 5 deletions tests/specs/16-import-account.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ export default async function importAccountTests() {
await enterRecoverySeed.waitForIsShown(true);
const helperText = await enterRecoverySeed.recoverySeedHelperText;
const screenTitle = await enterRecoverySeed.recoverySeedTitleText;
await expect(helperText).toHaveTextContaining(
"Type your recovery seed here. You may either enter one word at a time or all at once separated by spaces.",
await expect(helperText).toHaveText(
"Type your recovery seed here. Each phrase should go into their respective box. Alternatively you can simply copy past your recovery seed in here.",
);
await expect(screenTitle).toHaveTextContaining("RECOVERY SEED");
await expect(screenTitle).toHaveText("RECOVERY SEED");
});

it("Save Recovery Seed Screen - Attempt to enter invalid recovery seed", async () => {
await enterRecoverySeed.typeOnRecoverySeedInput("invalid");
await enterRecoverySeed.enterSingleSeedWord("invalid", 1);
await enterRecoverySeed.clickOnRecoverAccountButton();
await enterRecoverySeed.inputError.waitForExist();
const inputErrorText = await enterRecoverySeed.inputErrorText;
Expand All @@ -48,7 +48,7 @@ export default async function importAccountTests() {

it("Save Recovery Seed Screen - Enter valid recovery seed and continue", async () => {
const recoverySeed = await getUserRecoverySeed("Test123");
await enterRecoverySeed.typeOnRecoverySeedInput(recoverySeed);
await enterRecoverySeed.enterSeedWords(recoverySeed);
await enterRecoverySeed.clickOnRecoverAccountButton();
await welcomeScreen.waitForIsShown(true);
});
Expand Down

0 comments on commit cfd9704

Please sign in to comment.