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

Fix e2e tests #3651

Merged
merged 11 commits into from
Nov 20, 2023
Merged
2 changes: 1 addition & 1 deletion e2e-tests/regular/nfts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ test.describe("NFTs", () => {
const nftCollection = page
.getByTestId("nft_list_item")
.filter({ has: page.getByTestId("nft_list_item_collection") })
.filter({ hasText: "Notable Crypto Punks" })
.filter({ hasText: "Notable Punks" })
.first()

await nftCollection.hover()
Expand Down
8 changes: 7 additions & 1 deletion e2e-tests/regular/onboarding.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ test.describe("Onboarding", () => {
await page.getByRole("button", { name: "Begin the hunt" }).click()
await page.getByRole("button", { name: "Create recovery phrase" }).click()

// Verify seed
// Wait for the seed phrase to load.
const seedPhraseWord = await page.locator(".seed_phrase .word")
await expect(seedPhraseWord).toHaveCount(24)

// Extract seed into an array of words with no spaces or dashes.
const seedWords = (
await page.locator(".seed_phrase .word").allTextContents()
).map((word) => word.replace(/-|\s/, ""))
Expand All @@ -83,6 +87,8 @@ test.describe("Onboarding", () => {
"verify_seed_word_placeholder",
)

// Extract the ids of the seed phrase words that need to be verified and
// store them as an array of numbers.
const wordsToVerify = (await seedWordPlaceholders.allTextContents()).map(
(word) => Number((word.match(/\d+/) ?? ["0"])[0]),
)
Expand Down
7 changes: 5 additions & 2 deletions e2e-tests/regular/signing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ test.describe("Signing", () => {
await signDataPromptOpens.then(async (prompt) => {
await prompt.getByRole("button", { name: "Sign" }).click()
})

// If we see this then it means we were able to sign in
// There's a bug on login.xyz that makes the test fail
// (https://discord.com/channels/862419652286218251/886997073650655232/1173226370776694794).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I doubt storing the discord links in a code is a good way to document it 😅 Is the login.xyz website open source? Can we add an issue somewhere?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately not, btw. I checked on Friday :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I also prefer documenting such issues in GH, but did not find a repo for the project, hence I contacted them via Discord and documented that.

Btw, I did get a response - they will look into the issue.

// We're adding the expectation of failure. Playwright will throw `Expected
// to fail, but passed.` when bug is fixed.
test.fail()
await expect(siwe.getByText("Vote for your favorite emoji")).toBeVisible()
})

Expand Down
50 changes: 10 additions & 40 deletions e2e-tests/regular/token-trust.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,10 @@ test.describe("Token Trust", () => {
* Verify there are no unverified assets on the Swap screen.
*/
await popup.getByLabel("Swap", { exact: true }).click()
await popup
.getByRole("button", { name: "Select token", exact: true })
.first()
.click()
await popup.getByLabel("Swap from:").click()
await assetsHelper.assertAssetsNotPresentOnAssetsList(untrustedAssets)
await assetsHelper.closeSelectTokenPopup()
await popup
.getByRole("button", { name: "Select token", exact: true })
.nth(1)
.click()
await popup.getByLabel("Swap to:").click()
await assetsHelper.assertAssetsNotPresentOnAssetsList(untrustedAssets)
await assetsHelper.closeSelectTokenPopup()
})
Expand Down Expand Up @@ -265,16 +259,10 @@ test.describe("Token Trust", () => {
* Verify there are no unverified assets on the Swap screen.
*/
await popup.getByLabel("Swap", { exact: true }).click()
await popup
.getByRole("button", { name: "Select token", exact: true })
.first()
.click()
await popup.getByLabel("Swap from:").click()
await assetsHelper.assertAssetsNotPresentOnAssetsList(untrustedAssets)
await assetsHelper.closeSelectTokenPopup()
await popup
.getByRole("button", { name: "Select token", exact: true })
.nth(1)
.click()
await popup.getByLabel("Swap to:").click()
await assetsHelper.assertAssetsNotPresentOnAssetsList(untrustedAssets)
await assetsHelper.closeSelectTokenPopup()
})
Expand Down Expand Up @@ -345,16 +333,10 @@ test.describe("Token Trust", () => {
* Verify there is no "pAAVE" asset on the Swap screen.
*/
await popup.getByLabel("Swap", { exact: true }).click()
await popup
.getByRole("button", { name: "Select token", exact: true })
.first()
.click()
await popup.getByLabel("Swap from:").click()
await assetsHelper.assertAssetsNotPresentOnAssetsList(["pAAVE"])
await assetsHelper.closeSelectTokenPopup()
await popup
.getByRole("button", { name: "Select token", exact: true })
.nth(1)
.click()
await popup.getByLabel("Swap to:").click()
await assetsHelper.assertAssetsNotPresentOnAssetsList(["pAAVE"])
await assetsHelper.closeSelectTokenPopup()
})
Expand Down Expand Up @@ -423,16 +405,10 @@ test.describe("Token Trust", () => {
* Verify recently trusted asset is available on the Swap screen.
*/
await popup.getByLabel("Swap", { exact: true }).click()
await popup
.getByRole("button", { name: "Select token", exact: true })
.first()
.click()
await popup.getByLabel("Swap from:").click()
await assetsHelper.assertAssetsPresentOnAssetsList(["BANANA"])
await assetsHelper.closeSelectTokenPopup()
await popup
.getByRole("button", { name: "Select token", exact: true })
.nth(1)
.click()
await popup.getByLabel("Swap to:").click()
await assetsHelper.assertAssetsPresentOnAssetsList(["BANANA"])
await assetsHelper.closeSelectTokenPopup()
})
Expand Down Expand Up @@ -500,16 +476,10 @@ test.describe("Token Trust", () => {
* Verify there is no "BANANA" asset on the Swap screen.
*/
await popup.getByLabel("Swap", { exact: true }).click()
await popup
.getByRole("button", { name: "Select token", exact: true })
.first()
.click()
await popup.getByLabel("Swap from:").click()
await assetsHelper.assertAssetsNotPresentOnAssetsList(["BANANA"])
await assetsHelper.closeSelectTokenPopup()
await popup
.getByRole("button", { name: "Select token", exact: true })
.nth(1)
.click()
await popup.getByLabel("Swap to:").click()
await assetsHelper.assertAssetsNotPresentOnAssetsList(["BANANA"])
await assetsHelper.closeSelectTokenPopup()
})
Expand Down
14 changes: 10 additions & 4 deletions e2e-tests/utils/onboarding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,17 +183,23 @@ export default class OnboardingHelper {
await page.getByRole("button", { name: "Begin the hunt" }).click()
await page.getByRole("button", { name: "Create recovery phrase" }).click()

// Verify seed
const seedWords = (
await page.locator(".seed_phrase .word").allTextContents()
).map((word) => word.replace(/-|\s/, ""))
// Wait for the seed phrase to load.
const seedPhraseWord = await page.locator(".seed_phrase .word")
await expect(seedPhraseWord).toHaveCount(24)

// Extract seed into an array of words with no spaces or dashes.
const seedWords = (await seedPhraseWord.allTextContents()).map((word) =>
word.replace(/-|\s/, ""),
)

await page.getByRole("button", { name: "I wrote it down" }).click()

const seedWordPlaceholders = page.getByTestId(
"verify_seed_word_placeholder",
)

// Extract the ids of the seed phrase words that need to be verified and
// store them as an array of numbers.
const wordsToVerify = (await seedWordPlaceholders.allTextContents()).map(
(word) => Number((word.match(/\d+/) ?? ["0"])[0]),
)
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/utils/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ export default class TransactionsHelper {
timestampRow
.locator(".right")
// eslint-disable-next-line no-irregular-whitespace
.getByText(/^\d{1,2}\/\d{1,2}\/\d{4}, \d{1,2}:\d{2}:\d{2}(AM|PM)*$/),
.getByText(/^\d{1,2}\/\d{1,2}\/\d{4}, \d{1,2}:\d{2}:\d{2}( AM| PM)*$/),
).toBeVisible()
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
"@babel/preset-react": "^7.22.5",
"@babel/preset-typescript": "^7.22.11",
"@babel/register": "^7.22.5",
"@playwright/test": "^1.31",
"@playwright/test": "^1.39",
"@redux-devtools/cli": "^2.0.0",
"@thesis-co/eslint-config": "^0.6.1",
"@types/archiver": "^5.1.0",
Expand Down
30 changes: 18 additions & 12 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3425,15 +3425,12 @@
picocolors "^1.0.0"
tslib "^2.6.0"

"@playwright/test@^1.31":
version "1.31.0"
resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.31.0.tgz#bde42ca06804164be54893525110adda946248d6"
integrity sha512-Ys5s/06Dg9g3zAIdCIb/UOBYim3U7Zjb3DvC6XBtnRmnglH5O47iwYzmtxXu9fhSyzI2Jn28apkXIOD81GgCdw==
"@playwright/test@^1.39":
version "1.39.0"
resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.39.0.tgz#d10ba8e38e44104499e25001945f07faa9fa91cd"
integrity sha512-3u1iFqgzl7zr004bGPYiN/5EZpRUSFddQBra8Rqll5N0/vfpqlP9I9EXqAoGacuAbX6c9Ulg/Cjqglp5VkK6UQ==
dependencies:
"@types/node" "*"
playwright-core "1.31.0"
optionalDependencies:
fsevents "2.3.2"
playwright "1.39.0"

"@protobufjs/aspromise@^1.1.1", "@protobufjs/aspromise@^1.1.2":
version "1.1.2"
Expand Down Expand Up @@ -13018,10 +13015,19 @@ pkg-dir@^4.1.0, pkg-dir@^4.2.0:
dependencies:
find-up "^4.0.0"

[email protected]:
version "1.31.0"
resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.31.0.tgz#dbd184771535e76c6743ef5c082def5564f07e85"
integrity sha512-/KquBjS5DcASCh8cGeNVHuC0kyb7c9plKTwaKxgOGtxT7+DZO2fjmFvPDBSXslEIK5CeOO/2kk5rOCktFXKEdA==
[email protected]:
version "1.39.0"
resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.39.0.tgz#efeaea754af4fb170d11845b8da30b2323287c63"
integrity sha512-+k4pdZgs1qiM+OUkSjx96YiKsXsmb59evFoqv8SKO067qBA+Z2s/dCzJij/ZhdQcs2zlTAgRKfeiiLm8PQ2qvw==

[email protected]:
version "1.39.0"
resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.39.0.tgz#184c81cd6478f8da28bcd9e60e94fcebf566e077"
integrity sha512-naE5QT11uC/Oiq0BwZ50gDmy8c8WLPRTEWuSSFVG2egBka/1qMoSqYQcROMT9zLwJ86oPofcTH2jBY/5wWOgIw==
dependencies:
playwright-core "1.39.0"
optionalDependencies:
fsevents "2.3.2"

portfinder@^1.0.17:
version "1.0.28"
Expand Down