Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
50 changes: 22 additions & 28 deletions e2e/specs/wallets/registerName-metamask.spec.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
import { BrowserContext, expect, Page, test } from '@playwright/test'
import { expect, test } from '@playwright/test'
import dappwright from '@tenkeylabs/dappwright'
import type { Dappwright } from '@tenkeylabs/dappwright'

import { SafeEnsConfig } from './config/safe-ens-config'
import { confirmTransactionWithMetaMask, connectWalletToEns } from './config/wallet-ens-config'
import { navigateToHome, openWalletAndConfirm, searchForName } from './config/test-utilities'
import { connectWalletToEns } from './config/wallet-ens-config'

// Global variables to share state
let metaMask: Dappwright
let page: Page
let context: BrowserContext
let page: any // Using any to avoid Playwright version conflicts with dappwright
let context: any
let ensName: string

// Register unowned name
async function performRegistration(name: string): Promise<void> {
console.log(`🎯 Starting registration for ${name}`)

// Search for name
const searchInput = page.locator('input[placeholder="Search for a name"]')
await searchInput.waitFor({ timeout: 15000 })
await searchInput.fill(name)
await searchInput.press('Enter')
await searchForName(page, name)

// Wait for registration page
await page.getByRole('heading', { name: `Register ${name}` }).waitFor({ timeout: 15000 })
Expand All @@ -40,12 +38,8 @@ async function performRegistration(name: string): Promise<void> {
// Proceed to commit step
await page.locator('[data-testid="next-button"]').click()

// Wait for "Open Wallet" and confirm commit
await page.locator('text=Open Wallet').waitFor({ timeout: 10000 })
await page.locator('text=Open Wallet').click()

// Confirm transaction
await confirmTransactionWithMetaMask(page, 'commit', name)
// Open wallet and confirm commit transaction
await openWalletAndConfirm(page, { type: 'commit', name })

// Wait 60s for commit
await page.waitForTimeout(75000)
Expand All @@ -55,12 +49,14 @@ async function performRegistration(name: string): Promise<void> {
await finishButton.waitFor({ timeout: 10000 })
await finishButton.click()

// Open wallet modal and click
await page.locator('text=Open Wallet').waitFor({ timeout: 10000 })
await page.locator('text=Open Wallet').click()
// Open wallet and confirm register transaction
await openWalletAndConfirm(page, { type: 'register', name })

// Confirm transaction
await confirmTransactionWithMetaMask(page, 'register', name)
// Wait for registration completion page to load
// Registration flow auto-closes the modal and navigates to the completion step
// We wait for the "View Name" button which appears on the completion page
const viewNameButton = page.getByTestId('view-name')
await viewNameButton.waitFor({ state: 'visible', timeout: 120000 })

console.log('🎉 ENS registration completed!')
}
Expand All @@ -71,15 +67,8 @@ async function registerOwnedName() {

console.log(`🎯 Starting registration for ${registeredName}`)

// Search for name
const searchInput = page.locator('input[placeholder="Search for a name"]')
const searchResult = page.getByTestId('search-result-name')

await searchInput.waitFor({ timeout: 15000 })
await searchInput.fill(registeredName)
await expect(searchResult).toHaveText(registeredName)
await expect(searchResult).toContainText('Registered')
await searchInput.press('Enter')
// Search for name and verify it shows as registered
await searchForName(page, registeredName)

// Register should not appear, profile shows instead
await expect(page.getByRole('heading', { name: `Register ${registeredName}` })).not.toBeVisible({
Expand Down Expand Up @@ -136,6 +125,11 @@ test.describe('ENS Name Registration', () => {
ensName = `registername-${Date.now()}.eth`
})

test.beforeEach('Navigate to home page', async () => {
// Use utility function instead of manual navigation + timeout
await navigateToHome(page)
})

test('Connect MetaMask to ENS localhost', async () => {
await expect(
page.locator('button:has-text("Connect"), [data-testid="connect-button"]'),
Expand Down
94 changes: 44 additions & 50 deletions e2e/specs/wallets/subName-metamask.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
import { BrowserContext, expect, Page, test } from '@playwright/test'
import { expect, test } from '@playwright/test'
import dappwright from '@tenkeylabs/dappwright'
import type { Dappwright } from '@tenkeylabs/dappwright'

import { SafeEnsConfig } from './config/safe-ens-config'
import { confirmTransactionWithMetaMask, connectWalletToEns } from './config/wallet-ens-config'
import {
closeTransactionModal,
navigateToHome,
openWalletAndConfirm,
searchForName,
waitForTransactionComplete,
} from './config/test-utilities'
import { connectWalletToEns } from './config/wallet-ens-config'

// Global variables to share state
let metaMask: Dappwright
let page: Page
let context: BrowserContext
let page: any
let context: any
let ensName: string

// Create subname
Expand All @@ -18,10 +24,7 @@ async function createSubName(name: string): Promise<void> {
console.log(`🎯 Creating a new subname for ${walletName}`)

// Search for name
const searchInput = page.locator('input[placeholder="Search for a name"]')
await searchInput.waitFor({ timeout: 15000 })
await searchInput.fill(walletName)
await searchInput.press('Enter')
await searchForName(page, walletName)

// Navigate to subname tab
const subnameTab = page.getByTestId('subnames-tab')
Expand All @@ -35,85 +38,77 @@ async function createSubName(name: string): Promise<void> {

// Enter subname name
const subnameInput = page.getByTestId('add-subname-input')
const subnameNext = page.getByTestId('create-subname-next')
await subnameInput.waitFor()
await subnameInput.waitFor({ state: 'visible', timeout: 15000 })
await subnameInput.fill(name)

const subnameNext = page.getByTestId('create-subname-next')
await subnameNext.waitFor({ state: 'visible', timeout: 15000 })
await subnameNext.click()

// Skip profile creation
const subnameProfileNext = page.getByTestId('create-subname-profile-next')
await subnameProfileNext.waitFor({ state: 'visible', timeout: 15000 })
await subnameProfileNext.click()

// Start and confirm transaction
await page.locator('text=Open Wallet').waitFor({ timeout: 10000 })
await page.locator('text=Open Wallet').click()
await confirmTransactionWithMetaMask(page)
// Open wallet and confirm transaction
await openWalletAndConfirm(page, { type: 'subname creation' })

// Wait for transaction to complete
await page.waitForTimeout(25000)
// Wait for transaction to complete using event-driven approach
await waitForTransactionComplete(page, { action: 'subname creation' })

// Check subname is opened after transaction complete
const nameProfileName = page.getByTestId('profile-snippet-name')
const expectedSubname = `${ensName}.subname-test.eth`
await expect(nameProfileName).toHaveText(expectedSubname)
await expect(nameProfileName).toHaveText(expectedSubname, { timeout: 30000 })

// Check parent is correct
const parentLabel = page.getByTestId('owner-profile-button-name.parent')
await expect(parentLabel).toBeVisible()
await expect(parentLabel).toContainText('subname-test.eth')
await expect(parentLabel).toBeVisible({ timeout: 15000 })
await expect(parentLabel).toContainText('subname-test.eth', { timeout: 10000 })
}

// Delete subname
async function deleteSubName(name: string): Promise<void> {
const walletName = 'subname-test.eth'
const fullSubname = `${name}.subname-test.eth`

console.log(`🎯 Deleting ${name}.subname-test.eth`)
console.log(`🎯 Deleting ${fullSubname}`)

// Access created subname through search bar
const searchInput = page.locator('input[placeholder="Search for a name"]')
await searchInput.waitFor({ timeout: 15000 })
await searchInput.fill(`${name}.subname-test.eth`)
await searchInput.press('Enter')
await searchForName(page, fullSubname)

// Confirm subname then click delete
// Confirm subname profile loaded before deleting
const profileName = page.getByTestId('profile-snippet-name')
const expectedSubname = `${ensName}.subname-test.eth`
await expect(profileName).toHaveText(expectedSubname)
await expect(profileName).toHaveText(expectedSubname, { timeout: 30000 })

const deleteSubnameButton = page.getByTestId('profile-action-Delete subname')
await deleteSubnameButton.waitFor({ state: 'visible', timeout: 15000 })
await deleteSubnameButton.click()

// Start and confirm transaction
await page.locator('text=Open Wallet').waitFor({ timeout: 10000 })
await page.locator('text=Open Wallet').click()
await confirmTransactionWithMetaMask(page)
// Open wallet and confirm transaction
await openWalletAndConfirm(page, { type: 'subname deletion' })

// Wait for transaction to complete
await page.waitForTimeout(25000)
// Wait for transaction to complete using event-driven approach
await waitForTransactionComplete(page, { action: 'subname deletion' })

// Click done to return to subname profile
const transactionCompleteButton = page.getByTestId('transaction-modal-complete-button')
await transactionCompleteButton.click()
// Close the completion modal
await closeTransactionModal(page)

// Check expiry has no expiry
const expiryBox = page.getByTestId('owner-profile-button-name.expiry')
await expect(expiryBox).toContainText('no expiry', { timeout: 15000 })

// Enter parent name profile
const parentSubnameTab = page.getByTestId('subnames-tab')
await searchInput.waitFor({ timeout: 15000 })
await searchInput.fill(walletName)
await searchInput.press('Enter')
await expect(profileName).toHaveText(walletName, { timeout: 10000 })
// Navigate to parent name profile
await searchForName(page, walletName)
await expect(profileName).toHaveText(walletName, { timeout: 30000 })

// Switch to subname tab
const parentSubnameTab = page.getByTestId('subnames-tab')
await parentSubnameTab.waitFor({ state: 'visible', timeout: 15000 })
await parentSubnameTab.click()

// Check deleted subname is no longer appearing
const subnameItem = page.getByTestId(`name-item-${ensName}.subname-test.eth`)
await expect(subnameItem).not.toBeVisible({ timeout: 15000 })

console.log(`⚔️ {name} has been deleted`)
console.log(`⚔️ ${name} has been deleted`)
}

test.describe('ENS Subname Checks', () => {
Expand Down Expand Up @@ -157,9 +152,8 @@ test.describe('ENS Subname Checks', () => {
})

test.beforeEach('Navigate to home page', async () => {
// Navigate back to home page before each test to ensure clean state
await page.goto('http://localhost:3000/')
await page.waitForTimeout(2000)
// Use utility function instead of manual navigation + timeout
await navigateToHome(page)
})

test('Connect MetaMask to ENS localhost', async () => {
Expand Down