forked from ensdomains/ens-app-v3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
241 additions
and
57 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
Binary file not shown.
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,129 @@ | ||
import { expect } from '@playwright/test' | ||
|
||
import { test } from '../../../playwright' | ||
|
||
test('should allow claim (owned by user)', async ({ page, login, accounts, makePageObject }) => { | ||
const name = 'swagabc.xyz' | ||
|
||
const homePage = makePageObject('HomePage') | ||
const importPage = makePageObject('ImportPage') | ||
const transactionModal = makePageObject('TransactionModal') | ||
|
||
await homePage.goto() | ||
await login.connect() | ||
|
||
// should redirect to registration page | ||
await homePage.searchInput.fill(name) | ||
await homePage.searchInput.press('Enter') | ||
await expect(importPage.heading).toHaveText(`Claim ${name}`) | ||
|
||
// no type should be checked yet | ||
await expect(importPage.offchainRadio).not.toBeChecked() | ||
await expect(importPage.onchainRadio).not.toBeChecked() | ||
await expect(importPage.nextButton).toBeDisabled() | ||
|
||
await importPage.onchainRadio.click() | ||
|
||
// option selection should enable next | ||
await expect(importPage.nextButton).toBeEnabled({ timeout: 15000 }) | ||
await importPage.nextButton.click() | ||
|
||
// should jump straight to transaction step | ||
await expect(importPage.heading).toHaveText('Claim your domain') | ||
|
||
// should show cost value above 0 | ||
await expect(importPage.getCost()).resolves.toBeGreaterThan(0) | ||
|
||
await expect(importPage.nextButton).toHaveText('Claim') | ||
await expect(importPage.nextButton).toBeEnabled({ timeout: 15000 }) | ||
|
||
await importPage.nextButton.click() | ||
|
||
// should be two steps: approve and claim | ||
await expect(transactionModal.getStepCount()).resolves.toEqual(2) | ||
|
||
await transactionModal.confirm() | ||
await transactionModal.complete() | ||
|
||
// should save transaction status on refresh | ||
await page.reload() | ||
await expect(importPage.heading).toHaveText('Claim your domain') | ||
await expect(importPage.nextButton).toBeEnabled({ timeout: 15000 }) | ||
|
||
// should allow finalising | ||
await importPage.nextButton.click() | ||
|
||
// transaction modal should still have 2 steps | ||
await expect(transactionModal.getStepCount()).resolves.toEqual(2) | ||
|
||
await expect(page.getByText('Open Wallet')).toBeVisible() | ||
await transactionModal.confirm() | ||
|
||
// should show complete step | ||
await expect(page.getByText('Congratulations!')).toBeVisible() | ||
await expect(page.getByText(`You are now the owner of ${name}`)).toBeVisible() | ||
|
||
await page.getByTestId('view-name').click() | ||
await expect(page.getByTestId('address-profile-button-eth')).toHaveText( | ||
accounts.getAddress('user', 5), | ||
) | ||
}) | ||
|
||
test('should allow import (not owned by user)', async ({ page, login, makePageObject }) => { | ||
const name = 'taytems.xyz' | ||
|
||
const homePage = makePageObject('HomePage') | ||
const importPage = makePageObject('ImportPage') | ||
const transactionModal = makePageObject('TransactionModal') | ||
|
||
await homePage.goto() | ||
await login.connect() | ||
|
||
// should redirect to registration page | ||
await homePage.searchInput.fill(name) | ||
await homePage.searchInput.press('Enter') | ||
await expect(importPage.heading).toHaveText(`Claim ${name}`) | ||
|
||
// no type should be checked yet | ||
await expect(importPage.offchainRadio).not.toBeChecked() | ||
await expect(importPage.onchainRadio).not.toBeChecked() | ||
await expect(importPage.nextButton).toBeDisabled() | ||
|
||
await importPage.onchainRadio.click() | ||
|
||
// option selection should enable next | ||
await expect(importPage.nextButton).toBeEnabled({ timeout: 15000 }) | ||
await importPage.nextButton.click() | ||
|
||
// should show verify ownership step with error message | ||
await expect(importPage.heading).toHaveText('Verify Ownership') | ||
await expect( | ||
page.getByText( | ||
'The record found does not match your connected address. You can still import this name, but you will not have ownership of it.', | ||
), | ||
).toBeVisible() | ||
await expect(importPage.nextButton).toHaveText('Import without ownership') | ||
await expect(importPage.nextButton).toHaveCSS('background-color', 'rgb(197, 47, 27)') | ||
|
||
await importPage.nextButton.click() | ||
|
||
// should go to transaction step | ||
await expect(importPage.heading).toHaveText('Import this domain') | ||
|
||
// should show cost value above 0 | ||
await expect(importPage.getCost()).resolves.toBeGreaterThan(0) | ||
|
||
await expect(importPage.nextButton).toHaveText('Import') | ||
await expect(importPage.nextButton).toBeEnabled({ timeout: 15000 }) | ||
|
||
await importPage.nextButton.click() | ||
|
||
await transactionModal.attemptStep() | ||
|
||
// should show complete step | ||
await expect(page.getByText('Congratulations!')).toBeVisible() | ||
await expect(page.getByText(`${name} has been imported`)).toBeVisible() | ||
|
||
await page.getByTestId('view-name').click() | ||
await page.waitForURL(`/${name}`) | ||
}) |
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
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,32 @@ | ||
/* eslint-disable import/no-extraneous-dependencies */ | ||
import { expect, Locator, Page } from '@playwright/test' | ||
|
||
export class ImportPage { | ||
readonly page: Page | ||
|
||
readonly nextButton: Locator | ||
|
||
readonly onchainRadio: Locator | ||
|
||
readonly offchainRadio: Locator | ||
|
||
readonly heading: Locator | ||
|
||
readonly cost: Locator | ||
|
||
constructor(page: Page) { | ||
this.page = page | ||
this.nextButton = this.page.getByTestId('import-next-button') | ||
this.onchainRadio = this.page.getByTestId('onchain-radio') | ||
this.offchainRadio = this.page.getByTestId('offchain-radio') | ||
this.heading = this.page.getByTestId('import-heading') | ||
this.cost = this.page.getByTestId('import-cost') | ||
} | ||
|
||
async getCost() { | ||
await expect(this.cost).not.toBeEmpty() | ||
await expect(this.cost).not.toHaveText('0.0000 ETH') | ||
const text = (await this.cost.textContent()) as string | ||
return parseFloat(text) | ||
} | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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.