-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BX-1080 - Add op Sends to testing (#1048)
- Loading branch information
1 parent
dcc5c08
commit 0a1959a
Showing
25 changed files
with
426 additions
and
71 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
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
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,144 @@ | ||
import 'chromedriver'; | ||
import 'geckodriver'; | ||
import { WebDriver } from 'selenium-webdriver'; | ||
import { | ||
afterAll, | ||
afterEach, | ||
beforeAll, | ||
beforeEach, | ||
describe, | ||
expect, | ||
it, | ||
} from 'vitest'; | ||
|
||
import { | ||
checkExtensionURL, | ||
checkWalletName, | ||
delay, | ||
delayTime, | ||
executePerformShortcut, | ||
findElementByTestId, | ||
findElementByText, | ||
getExtensionIdByName, | ||
getRootUrl, | ||
goToPopup, | ||
importWalletFlowUsingKeyboardNavigation, | ||
initDriverWithOptions, | ||
navigateToElementWithTestId, | ||
takeScreenshotOnFailure, | ||
transactionStatus, | ||
} 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('Complete Hardhat Optimism send flow', () => { | ||
beforeAll(async () => { | ||
driver = await initDriverWithOptions({ | ||
browser, | ||
os, | ||
}); | ||
const extensionId = await getExtensionIdByName(driver, 'Rainbow'); | ||
if (!extensionId) throw new Error('Extension not found'); | ||
rootURL += extensionId; | ||
}); | ||
|
||
beforeEach<{ driver: WebDriver }>(async (context) => { | ||
context.driver = driver; | ||
}); | ||
|
||
afterEach<{ driver: WebDriver }>(async (context) => { | ||
await takeScreenshotOnFailure(context); | ||
}); | ||
|
||
afterAll(() => driver.quit()); | ||
|
||
it('should be able import a wallet via pk', async () => { | ||
await importWalletFlowUsingKeyboardNavigation( | ||
driver, | ||
rootURL, | ||
TEST_VARIABLES.SEED_WALLET.PK, | ||
); | ||
}); | ||
|
||
it('should display account name', async () => { | ||
await checkWalletName(driver, rootURL, TEST_VARIABLES.SEED_WALLET.ADDRESS); | ||
}); | ||
|
||
it('should be able to go to setings', async () => { | ||
await goToPopup(driver, rootURL); | ||
await executePerformShortcut({ driver, key: 'DECIMAL' }); | ||
await executePerformShortcut({ driver, key: 'ARROW_DOWN' }); | ||
await executePerformShortcut({ driver, key: 'ENTER' }); | ||
await checkExtensionURL(driver, 'settings'); | ||
}); | ||
|
||
it('should be able to connect to hardhat Optimism', async () => { | ||
await navigateToElementWithTestId({ | ||
driver, | ||
testId: 'connect-to-hardhat-op', | ||
}); | ||
const button = await findElementByText( | ||
driver, | ||
'Disconnect from Hardhat Optimism', | ||
); | ||
expect(button).toBeTruthy(); | ||
await executePerformShortcut({ driver, key: 'ESCAPE' }); | ||
}); | ||
|
||
it('should be able to navigate to send', async () => { | ||
await executePerformShortcut({ driver, key: 's' }); | ||
await checkExtensionURL(driver, 'send'); | ||
}); | ||
|
||
it('should be able to nav to send field and type in address', async () => { | ||
await executePerformShortcut({ driver, key: 'TAB', timesToPress: 2 }); | ||
await driver | ||
.actions() | ||
.sendKeys('0x9126914f62314402cC3f098becfaa7c2Bc23a55C') | ||
.perform(); | ||
const shortenedAddress = await findElementByText(driver, '0x9126…a55C'); | ||
expect(shortenedAddress).toBeTruthy(); | ||
}); | ||
|
||
it('should be able to select asset to send with keyboard', async () => { | ||
await navigateToElementWithTestId({ | ||
driver, | ||
testId: 'asset-name-eth_10', | ||
}); | ||
await delayTime('long'); | ||
const tokenInput = await findElementByTestId({ | ||
id: 'input-wrapper-dropdown-token-input', | ||
driver, | ||
}); | ||
expect(await tokenInput.getText()).toContain('Ethereum'); | ||
const value = await findElementByTestId({ id: 'send-input-mask', driver }); | ||
const valueNum = await value.getAttribute('value'); | ||
expect(Number(valueNum)).toBe(0); | ||
}); | ||
|
||
it('should be able to initiate Optimisim ETH transaction', async () => { | ||
await driver.actions().sendKeys('1').perform(); | ||
const value = await findElementByTestId({ id: 'send-input-mask', driver }); | ||
const valueNum = await value.getAttribute('value'); | ||
expect(Number(valueNum)).toBe(1); | ||
await navigateToElementWithTestId({ driver, testId: 'send-review-button' }); | ||
const reviewText = await findElementByText(driver, 'Review & Send'); | ||
expect(reviewText).toBeTruthy(); | ||
await delayTime('medium'); | ||
await navigateToElementWithTestId({ driver, testId: 'L2-check-1' }); | ||
await navigateToElementWithTestId({ driver, testId: 'L2-check-2' }); | ||
await navigateToElementWithTestId({ | ||
driver, | ||
testId: 'review-confirm-button', | ||
}); | ||
await delayTime('very-long'); | ||
const sendTransaction = await transactionStatus(); | ||
expect(sendTransaction).toBe('success'); | ||
await delay(10000); | ||
}); | ||
}); |
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
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
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,29 @@ | ||
#!/bin/bash | ||
ANVIL_PORT=8545 | ||
|
||
# Launch anvil in the bg | ||
yarn anvil:kill | ||
yarn anvil:optimism --chain-id 1338 & | ||
echo "Launching Anvil..." | ||
|
||
# Give it some time to boot | ||
interval=5 | ||
until nc -z localhost $ANVIL_PORT; do | ||
sleep $interval | ||
interval=$((interval * 2)) | ||
done | ||
echo "Anvil Launched..." | ||
|
||
# Run the tests and store the result | ||
echo "Running Tests..." | ||
yarn vitest e2e/serial/$1 --config ./e2e/serial/vitest.config.ts --reporter=verbose | ||
|
||
# Store exit code | ||
TEST_RESULT=$? | ||
|
||
# kill anvil | ||
echo "Cleaning Up..." | ||
yarn anvil:kill | ||
|
||
# return the result of the tests | ||
exit "$TEST_RESULT" |
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
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
Oops, something went wrong.