Skip to content

Commit

Permalink
Revert "REVERT"
Browse files Browse the repository at this point in the history
This reverts commit 0f8aeba.
  • Loading branch information
estebanmino committed Oct 24, 2023
1 parent b6ec35a commit a878ae1
Show file tree
Hide file tree
Showing 11 changed files with 1,770 additions and 0 deletions.
63 changes: 63 additions & 0 deletions e2e/parallel/LedgerImportFlow.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import 'chromedriver';
import 'geckodriver';
import { WebDriver } from 'selenium-webdriver';
import { afterAll, beforeAll, describe, expect, it } from 'vitest';

import {
checkWalletName,
findElementByIdAndClick,
findElementByTestIdAndClick,
findElementByText,
getExtensionIdByName,
getRootUrl,
importHardwareWalletFlow,
initDriverWithOptions,
} from '../helpers';
import { HARDWARE_WALLETS } from '../walletVariables';

let rootURL = getRootUrl();
let driver: WebDriver;

const browser = process.env.BROWSER || 'chrome';
const os = process.env.OS || 'mac';

describe.runIf(browser !== 'firefox')(
'Import wallet with a Ledger hw wallet',
() => {
beforeAll(async () => {
driver = await initDriverWithOptions({
browser,
os,
});
const extensionId = await getExtensionIdByName(driver, 'Rainbow');
if (!extensionId) throw new Error('Extension not found');
rootURL += extensionId;
});
afterAll(async () => driver.quit());

it('should be able import a wallet via hw wallet', async () => {
await importHardwareWalletFlow(driver, rootURL, 'ledger');
});

it('should display account 0 name', async () => {
await checkWalletName(driver, rootURL, HARDWARE_WALLETS.WALLET_1);
});

it('should display hw label on wallet switcher screen', async () => {
await findElementByIdAndClick({
id: 'header-account-name-shuffle',
driver,
});
const hwLabel = await findElementByText(driver, 'Ledger');
expect(hwLabel).toBeTruthy();
});

it('should display account 1 name', async () => {
await findElementByTestIdAndClick({
id: 'wallet-account-2',
driver,
});
await checkWalletName(driver, rootURL, HARDWARE_WALLETS.WALLET_2);
});
},
);
63 changes: 63 additions & 0 deletions e2e/parallel/TrezorImportFlow.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import 'chromedriver';
import 'geckodriver';
import { WebDriver } from 'selenium-webdriver';
import { afterAll, beforeAll, describe, expect, it } from 'vitest';

import {
checkWalletName,
findElementByIdAndClick,
findElementByTestIdAndClick,
findElementByText,
getExtensionIdByName,
getRootUrl,
importHardwareWalletFlow,
initDriverWithOptions,
} from '../helpers';
import { HARDWARE_WALLETS } from '../walletVariables';

let rootURL = getRootUrl();
let driver: WebDriver;

const browser = process.env.BROWSER || 'chrome';
const os = process.env.OS || 'mac';

describe.runIf(browser !== 'firefox')(
'Import wallet with a Trezor hw wallet',
() => {
beforeAll(async () => {
driver = await initDriverWithOptions({
browser,
os,
});
const extensionId = await getExtensionIdByName(driver, 'Rainbow');
if (!extensionId) throw new Error('Extension not found');
rootURL += extensionId;
});
afterAll(async () => driver.quit());

it('should be able import a wallet via hw wallet', async () => {
await importHardwareWalletFlow(driver, rootURL, 'trezor');
});

it('should display account 0 name', async () => {
await checkWalletName(driver, rootURL, HARDWARE_WALLETS.WALLET_1);
});

it('should display hw label on wallet switcher screen', async () => {
await findElementByIdAndClick({
id: 'header-account-name-shuffle',
driver,
});
const hwLabel = await findElementByText(driver, 'Trezor');
expect(hwLabel).toBeTruthy();
});

it('should display account 1 name', async () => {
await findElementByTestIdAndClick({
id: 'wallet-account-2',
driver,
});
await checkWalletName(driver, rootURL, HARDWARE_WALLETS.WALLET_2);
});
},
);
39 changes: 39 additions & 0 deletions e2e/parallel/importWalletFlow.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import 'chromedriver';
import 'geckodriver';
import { WebDriver } from 'selenium-webdriver';
import { afterAll, beforeAll, describe, it } from 'vitest';

import {
checkWalletName,
getExtensionIdByName,
getRootUrl,
importWalletFlow,
initDriverWithOptions,
} from '../helpers';
import { TEST_VARIABLES } from '../walletVariables';

let rootURL = getRootUrl();
let driver: WebDriver;

const browser = process.env.BROWSER || 'chrome';
const os = process.env.OS || 'mac';

describe('Import wallet with a secret phrase flow', () => {
beforeAll(async () => {
driver = await initDriverWithOptions({
browser,
os,
});
const extensionId = await getExtensionIdByName(driver, 'Rainbow');
if (!extensionId) throw new Error('Extension not found');
rootURL += extensionId;
});
afterAll(async () => driver.quit());

it('should be able import a wallet via seed', async () => {
await importWalletFlow(driver, rootURL, TEST_VARIABLES.EMPTY_WALLET.SECRET);
});
it('should display account name', async () => {
await checkWalletName(driver, rootURL, TEST_VARIABLES.EMPTY_WALLET.ADDRESS);
});
});
47 changes: 47 additions & 0 deletions e2e/parallel/importWalletFlowPkey.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import 'chromedriver';
import 'geckodriver';
import { WebDriver } from 'selenium-webdriver';
import { afterAll, beforeAll, describe, it } from 'vitest';

import {
checkWalletName,
getExtensionIdByName,
getRootUrl,
importWalletFlow,
initDriverWithOptions,
} from '../helpers';
import { TEST_VARIABLES } from '../walletVariables';

let rootURL = getRootUrl();
let driver: WebDriver;

const browser = process.env.BROWSER || 'chrome';
const os = process.env.OS || 'mac';

describe('Import wallet with a private key flow', () => {
beforeAll(async () => {
driver = await initDriverWithOptions({
browser,
os,
});
const extensionId = await getExtensionIdByName(driver, 'Rainbow');
if (!extensionId) throw new Error('Extension not found');
rootURL += extensionId;
});
afterAll(async () => driver.quit());

it('should be able import a wallet via private key', async () => {
await importWalletFlow(
driver,
rootURL,
TEST_VARIABLES.PRIVATE_KEY_WALLET.SECRET,
);
});
it('should display account name', async () => {
await checkWalletName(
driver,
rootURL,
TEST_VARIABLES.PRIVATE_KEY_WALLET.ADDRESS,
);
});
});
117 changes: 117 additions & 0 deletions e2e/parallel/newWalletFlow.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/* eslint-disable no-await-in-loop */
import 'chromedriver';
import 'geckodriver';
import { WebDriver } from 'selenium-webdriver';
import { afterAll, beforeAll, describe, expect, it } from 'vitest';

import {
delayTime,
findElementByTestIdAndClick,
findElementByText,
getExtensionIdByName,
getRootUrl,
goToPopup,
goToWelcome,
initDriverWithOptions,
passSecretQuiz,
querySelector,
typeOnTextInput,
waitAndClick,
} from '../helpers';

let rootURL = getRootUrl();
let driver: WebDriver;

const browser = process.env.BROWSER || 'chrome';
const os = process.env.OS || 'mac';

describe('New wallet flow', () => {
beforeAll(async () => {
driver = await initDriverWithOptions({
browser,
os,
});
const extensionId = await getExtensionIdByName(driver, 'Rainbow');
if (!extensionId) throw new Error('Extension not found');
rootURL += extensionId;
});

afterAll(async () => driver.quit());

// Create a new wallet
it('should be able create a new wallet', async () => {
await goToWelcome(driver, rootURL);
await findElementByTestIdAndClick({
id: 'create-wallet-button',
driver,
});
await findElementByTestIdAndClick({
id: 'show-recovery-phrase-button',
driver,
});

await passSecretQuiz(driver);

await typeOnTextInput({ id: 'password-input', driver, text: 'test1234' });
await typeOnTextInput({
id: 'confirm-password-input',
driver,
text: 'test1234',
});

await findElementByTestIdAndClick({ id: 'set-password-button', driver });
await delayTime('long');
await findElementByText(driver, 'Rainbow is ready to use');
});

it('should display account name', async () => {
await goToPopup(driver, rootURL);
const label = await querySelector(
driver,
'[data-testid="header"] [data-testid="account-name"]',
);

const actual = await label.getText();
expect(actual.substr(0, 2) === '0x' && actual.length === 11).toEqual(true);
});

it('should be able to lock and unlock the extension', async () => {
await goToPopup(driver, rootURL, '#/home');
// Lock
await findElementByTestIdAndClick({
id: 'home-page-header-right',
driver,
});
await findElementByTestIdAndClick({ id: 'lock', driver });

// Unlock
await typeOnTextInput({ id: 'password-input', driver, text: 'test1234' });
await findElementByTestIdAndClick({ id: 'unlock-button', driver });
});

it('should be able to test the sandbox for the popup', async () => {
await goToPopup(driver, rootURL, '#/home');
await findElementByTestIdAndClick({ id: 'home-page-header-right', driver });
await findElementByTestIdAndClick({ id: 'settings-link', driver });
const btn = await querySelector(
driver,
'[data-testid="test-sandbox-popup"]',
);
await waitAndClick(btn, driver);
const text = await driver.switchTo().alert().getText();
expect(text).toBe('Popup sandboxed!');
await driver.switchTo().alert().accept();
});

it('should be able to test the sandbox for the background', async () => {
const btn = await querySelector(
driver,
'[data-testid="test-sandbox-background"]',
);
await waitAndClick(btn, driver);
await delayTime('long');
const text = await driver.switchTo().alert().getText();
expect(text).toBe('Background sandboxed!');
await driver.switchTo().alert().accept();
});
});
Loading

0 comments on commit a878ae1

Please sign in to comment.