-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
11 changed files
with
1,770 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); |
Oops, something went wrong.