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

Create E2E tests for verified/unverified tokens #3472

Merged
merged 37 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
fdf09c6
Create E2E tests for verified/unverified tokens
michalinacienciala Jun 13, 2023
19cebd0
Merge remote-tracking branch 'origin/main' into trust-tokens-e2e
michalinacienciala Jun 26, 2023
2ce0f5c
Uncomment temporarily turned off test steps
michalinacienciala Jun 29, 2023
db5302a
Merge remote-tracking branch 'origin/main' into trust-tokens-e2e
michalinacienciala Jun 29, 2023
1b6d888
Switch test to use account that we control
michalinacienciala Jul 6, 2023
bdf5b87
Merge remote-tracking branch 'origin/main' into trust-tokens-e2e
michalinacienciala Jul 20, 2023
1debde9
Adjust the code after the merge
michalinacienciala Jul 21, 2023
b1d8382
Improve comments
michalinacienciala Jul 21, 2023
c0f9193
Refactor code asserting asset's balance
michalinacienciala Jul 24, 2023
3f0a378
Uncomment temporarily disabled assertions
michalinacienciala Jul 24, 2023
bf682cc
Merge `assertAssetDetailsPage()` with `verifyAssetActivityScreen()`
michalinacienciala Jul 24, 2023
1a75c5d
Remove obsolete comment
michalinacienciala Jul 24, 2023
06208b6
Improve comments
michalinacienciala Jul 24, 2023
7511aa4
Update names of the JSON-related variables and secrets
michalinacienciala Jul 24, 2023
f37e61b
Wait 1s before switching to Polygon network
michalinacienciala Jul 24, 2023
a07be0a
Merge remote-tracking branch 'origin/main' into trust-tokens-e2e
michalinacienciala Jul 24, 2023
22a9b91
Give dev fork builds the -fork suffix
michalinacienciala Jul 24, 2023
4ef9622
Increase waiting time before switching network
michalinacienciala Jul 24, 2023
5debafc
Uncomment previously failing code
michalinacienciala Jul 25, 2023
cbd2990
Remove empty line
michalinacienciala Jul 25, 2023
b16c9a0
Merge remote-tracking branch 'origin/main' into trust-tokens-e2e
michalinacienciala Jul 27, 2023
5ad6ca6
Rename `verify...` functions to `assert...`
michalinacienciala Jul 27, 2023
833cbf4
Update dApp connection banner assertion
michalinacienciala Jul 27, 2023
0fa759f
Merge remote-tracking branch 'origin/main' into trust-tokens-e2e
michalinacienciala Aug 3, 2023
95db29f
Extract the name and address of the testing account to a helper file
michalinacienciala Aug 4, 2023
b4a61d2
Explain usage of ElementHandle in `closeAccountsPopup()`
michalinacienciala Aug 6, 2023
4e740df
Remove obsolete steps in `addAddressToAccount()`
michalinacienciala Aug 6, 2023
e9d7951
Remove obsolete comment
michalinacienciala Aug 6, 2023
89019b4
Improve comments
michalinacienciala Aug 6, 2023
c562952
Refactor function closing Accounts slide up
michalinacienciala Aug 14, 2023
1cf604e
Move the `closeAccountsSlideUp()` steps under `addAddressToAccount()`
michalinacienciala Aug 14, 2023
c21299e
Remove obsolete timeout
michalinacienciala Aug 14, 2023
1265763
Support assets with the same name in `assertVerifiedAssetOnWalletPage`
michalinacienciala Aug 15, 2023
5f45f7f
Refactor onboarding with JSON
michalinacienciala Aug 15, 2023
bd19521
Access account-specific data in e2e tests using interface
michalinacienciala Aug 15, 2023
6bfbd18
Merge remote-tracking branch 'origin/main' into trust-tokens-e2e
michalinacienciala Aug 15, 2023
0013d2a
Merge branch 'main' into trust-tokens-e2e
hyphenized Aug 16, 2023
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
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ jobs:
# tests on every PR update. We'll tag those tests with the `@expensive`
# tag.
- name: Run free Playwright tests
env:
E2E_TEST_ONLY_WALLET_JSON_BODY: ${{ secrets.E2E_TEST_ONLY_WALLET_JSON_BODY }}
E2E_TEST_ONLY_WALLET_JSON_PASSWORD: ${{ secrets.E2E_TEST_ONLY_WALLET_JSON_PASSWORD }}
run: xvfb-run npx playwright test --grep-invert @expensive
#env:
# DEBUG: pw:api*
Expand Down
144 changes: 54 additions & 90 deletions e2e-tests/fork-based/transactions.spec.ts
Original file line number Diff line number Diff line change
@@ -1,56 +1,32 @@
import fs from "fs"
import { test, expect } from "../utils"
import { account2 } from "../utils/onboarding"

test.describe("Transactions", () => {
test.beforeAll(async () => {
/**
* Create a JSON file with an encoded private key based on the file
* content passed from an environment variable. The further steps of
* the tests assume that the file encodes the pk of the `testertesting.eth`
* account. The JSON file can be generated using a script
* `scripts/key-generation/export-key-as-json.js`.
*/
const jsonBody = process.env.TEST_WALLET_JSON_BODY
if (jsonBody) {
fs.writeFileSync("./e2e-tests/utils/JSON.json", jsonBody)
} else {
throw new Error(
"TEST_WALLET_JSON_BODY environment variable is not defined."
)
}
})

test("User can send base asset", async ({
page: popup,
walletPageHelper,
transactionsHelper,
assetsHelper,
}) => {
await test.step("Import account", async () => {
/**
* Onboard using JSON file.
* Import the `testertesting.eth` account using onboarding with a JSON
* file.
*/
const jsonPassword = process.env.TEST_WALLET_JSON_PASSWORD
if (jsonPassword) {
await walletPageHelper.onboardWithJSON(
"./e2e-tests/utils/JSON.json",
jsonPassword
)
} else {
throw new Error(
"TEST_WALLET_JSON_PASSWORD environment variable is not defined."
)
}
await walletPageHelper.onboardWithJSON(account2)
await walletPageHelper.goToStartPage()
await walletPageHelper.setViewportSize()

/**
* Verify we're on Ethereum network. Verify common elements on the main
* page.
*/
await walletPageHelper.verifyCommonElements(
await walletPageHelper.assertCommonElements(
/^Ethereum$/,
false,
/^testertesting\.eth$/
account2.name
)
await walletPageHelper.verifyAnalyticsBanner()
await walletPageHelper.assertAnalyticsBanner()

/**
* Verify ETH is visible on the asset list and has the correct balance
Expand All @@ -74,9 +50,9 @@ test.describe("Transactions", () => {
* already selected. Verify elements on the page. Make sure `Continue`
* isn't active.
*/
await transactionsHelper.verifyUnfilledSendAssetScreen(
await transactionsHelper.assertUnfilledSendAssetScreen(
/^Ethereum$/,
/^testertesting\.eth$/,
account2.name,
"ETH",
"0\\.1021",
true
Expand Down Expand Up @@ -110,7 +86,7 @@ test.describe("Transactions", () => {
/**
* Check if "Transfer" has opened and verify elements on the page.
*/
await transactionsHelper.verifyTransferScreen(
await transactionsHelper.assertTransferScreen(
"Ethereum",
"testertesting\\.eth",
"0x47745a7252e119431ccf973c0ebd4279638875a6",
Expand Down Expand Up @@ -143,12 +119,12 @@ test.describe("Transactions", () => {
/**
* Verify elements on the asset activity screen
*/
await transactionsHelper.verifyAssetActivityScreen(
await assetsHelper.assertAssetDetailsPage(
/^Ethereum$/,
/^testertesting\.eth$/,
account2.name,
/^ETH$/,
/^0\.0914$/,
true
"base"
)
// This is what we expect currently on forked network. If ve ever fix
// displaying activity on fork, we should perform following checks
Expand Down Expand Up @@ -192,12 +168,12 @@ test.describe("Transactions", () => {
.first()
).toBeVisible()

await walletPageHelper.verifyCommonElements(
await walletPageHelper.assertCommonElements(
/^Ethereum$/,
false,
/^testertesting\.eth$/
account2.name
)
await walletPageHelper.verifyAnalyticsBanner()
await walletPageHelper.assertAnalyticsBanner()
}
)
})
Expand All @@ -206,33 +182,27 @@ test.describe("Transactions", () => {
page: popup,
walletPageHelper,
transactionsHelper,
assetsHelper,
}) => {
await test.step("Import account", async () => {
/**
* Onboard using JSON file.
* Import the `testertesting.eth` account using onboarding with a JSON
* file.
*/
const jsonPassword = process.env.TEST_WALLET_JSON_PASSWORD
if (jsonPassword) {
await walletPageHelper.onboardWithJSON(
"./e2e-tests/utils/JSON.json",
jsonPassword
)
} else {
throw new Error(
"TEST_WALLET_JSON_PASSWORD environment variable is not defined."
)
}
await walletPageHelper.onboardWithJSON(account2)
await walletPageHelper.goToStartPage()
await walletPageHelper.setViewportSize()

/**
* Verify we're on Ethereum network. Verify common elements on the main
* page.
*/
await walletPageHelper.verifyCommonElements(
await walletPageHelper.assertCommonElements(
/^Ethereum$/,
false,
/^testertesting\.eth$/
account2.name
)
await walletPageHelper.verifyAnalyticsBanner()
await walletPageHelper.assertAnalyticsBanner()

/**
* Verify KEEP is visible on the asset list and has the correct balance
Expand Down Expand Up @@ -261,9 +231,9 @@ test.describe("Transactions", () => {
* already selected. Verify elements on the page. Make sure `Continue`
* isn't active.
*/
await transactionsHelper.verifyUnfilledSendAssetScreen(
await transactionsHelper.assertUnfilledSendAssetScreen(
/^Ethereum$/,
/^testertesting\.eth$/,
account2.name,
"KEEP",
"65\\.88",
false
Expand Down Expand Up @@ -297,7 +267,7 @@ test.describe("Transactions", () => {
/**
* Check if "Transfer" has opened and verify elements on the page.
*/
await transactionsHelper.verifyTransferScreen(
await transactionsHelper.assertTransferScreen(
"Ethereum",
"testertesting\\.eth",
"0x47745a7252e119431ccf973c0ebd4279638875a6",
Expand Down Expand Up @@ -328,12 +298,12 @@ test.describe("Transactions", () => {
/**
* Verify elements on the asset activity screen
*/
await transactionsHelper.verifyAssetActivityScreen(
await assetsHelper.assertAssetDetailsPage(
/^Ethereum$/,
/^testertesting\.eth$/,
account2.name,
/^KEEP$/,
/^65\.88$/,
false,
"knownERC20",
"https://etherscan.io/token/0x85eee30c52b0b379b046fb0f85f4f3dc3009afec"
)
// This is what we expect currently on a forked network.
Expand All @@ -353,33 +323,27 @@ test.describe("Transactions", () => {
page: popup,
walletPageHelper,
transactionsHelper,
assetsHelper,
}) => {
await test.step("Import account", async () => {
/**
* Onboard using JSON file.
* Import the `testertesting.eth` account using onboarding with a JSON
* file.
*/
const jsonPassword = process.env.TEST_WALLET_JSON_PASSWORD
if (jsonPassword) {
await walletPageHelper.onboardWithJSON(
"./e2e-tests/utils/JSON.json",
jsonPassword
)
} else {
throw new Error(
"TEST_WALLET_JSON_PASSWORD environment variable is not defined."
)
}
await walletPageHelper.onboardWithJSON(account2)
await walletPageHelper.goToStartPage()
await walletPageHelper.setViewportSize()

/**
* Verify we're on Ethereum network. Verify common elements on the main
* page.
*/
await walletPageHelper.verifyCommonElements(
await walletPageHelper.assertCommonElements(
/^Ethereum$/,
false,
/^testertesting\.eth$/
account2.name
)
await walletPageHelper.verifyAnalyticsBanner()
await walletPageHelper.assertAnalyticsBanner()

/**
* Verify KEEP is visible on the asset list and has the correct balance
Expand Down Expand Up @@ -408,9 +372,9 @@ test.describe("Transactions", () => {
* already selected. Verify elements on the page. Make sure `Continue`
* isn't active.
*/
await transactionsHelper.verifyUnfilledSendAssetScreen(
await transactionsHelper.assertUnfilledSendAssetScreen(
/^Ethereum$/,
/^testertesting\.eth$/,
account2.name,
"ETH",
"\\d+\\.\\d{4}",
true
Expand Down Expand Up @@ -466,9 +430,9 @@ test.describe("Transactions", () => {
* Verify elements on the page after selecting token. Make sure
* `Continue` isn't active.
*/
await transactionsHelper.verifyUnfilledSendAssetScreen(
await transactionsHelper.assertUnfilledSendAssetScreen(
/^Ethereum$/,
/^testertesting\.eth$/,
account2.name,
"KEEP",
"65\\.88",
false
Expand Down Expand Up @@ -502,7 +466,7 @@ test.describe("Transactions", () => {
/**
* Check if "Transfer" has opened and verify elements on the page.
*/
await transactionsHelper.verifyTransferScreen(
await transactionsHelper.assertTransferScreen(
"Ethereum",
"testertesting\\.eth",
"0x47745a7252e119431ccf973c0ebd4279638875a6",
Expand Down Expand Up @@ -535,12 +499,12 @@ test.describe("Transactions", () => {
/**
* Verify elements on the asset activity screen
*/
await transactionsHelper.verifyAssetActivityScreen(
await assetsHelper.assertAssetDetailsPage(
/^Ethereum$/,
/^testertesting\.eth$/,
account2.name,
/^KEEP$/,
/^53\.54$/,
false,
"knownERC20",
"https://etherscan.io/token/0x85eee30c52b0b379b046fb0f85f4f3dc3009afec"
)
// This is what we expect currently on forked network. If ve ever fix
Expand Down Expand Up @@ -585,12 +549,12 @@ test.describe("Transactions", () => {
.first()
).toBeVisible()

await walletPageHelper.verifyCommonElements(
await walletPageHelper.assertCommonElements(
/^Ethereum$/,
false,
/^testertesting\.eth$/
account2.name
)
await walletPageHelper.verifyAnalyticsBanner()
await walletPageHelper.assertAnalyticsBanner()
}
)
})
Expand Down
8 changes: 4 additions & 4 deletions e2e-tests/regular/nfts.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { wait } from "@tallyho/tally-background/lib/utils"
import { test, expect } from "../utils"
import { account1Address, account1Name } from "../utils/onboarding"
import { account1 } from "../utils/onboarding"

test.describe("NFTs", () => {
test("User can view nft collections, poaps and badges", async ({
Expand Down Expand Up @@ -37,7 +37,7 @@ test.describe("NFTs", () => {
}
})

await walletPageHelper.onboarding.addReadOnlyAccount(account1Address)
await walletPageHelper.onboarding.addReadOnlyAccount(account1.address)

await walletPageHelper.goToStartPage()
await walletPageHelper.setViewportSize()
Expand Down Expand Up @@ -78,7 +78,7 @@ test.describe("NFTs", () => {
await page
.getByTestId("nft_account_filters")
.filter({
hasText: account1Name,
hasText: account1.name,
})
.getByRole("checkbox")
.click()
Expand All @@ -105,7 +105,7 @@ test.describe("NFTs", () => {
.getByTestId("nft_account_filters")
.getByTestId("toggle_item")
.filter({
hasText: account1Name,
hasText: account1.name,
})
.getByRole("checkbox")
.click()
Expand Down
Loading
Loading