Skip to content

Commit c9f4b45

Browse files
committed
test updates
1 parent 58342a3 commit c9f4b45

File tree

3 files changed

+131
-17
lines changed

3 files changed

+131
-17
lines changed

e2e/specs/wallets/extendName-metamask.spec.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,18 +124,19 @@ async function confirmTransactionWithMetaMask(): Promise<void> {
124124
await page.bringToFront()
125125
}
126126

127+
// Extend owned name
127128
async function extendOwnedNameOnSepoliaApp(): Promise<void> {
128129
const name = 'extend-name-test.eth'
129130

130131
console.log(`🎯 Starting extension for ${name}`)
131132

132-
// 1️⃣ Search for name
133+
// Search for name
133134
const searchInput = page.locator('input[placeholder="Search for a name"]')
134135
await searchInput.waitFor({ timeout: 15000 })
135136
await searchInput.fill(name)
136137
await searchInput.press('Enter')
137138

138-
// 2️⃣ Grab the current expiry timestamp from profile
139+
// Grab the current expiry timestamp from profile
139140
const expiryElement = page.getByTestId('owner-profile-button-name.expiry')
140141
await expiryElement.waitFor({ state: 'visible', timeout: 15000 })
141142

@@ -145,17 +146,17 @@ async function extendOwnedNameOnSepoliaApp(): Promise<void> {
145146
const currentExpiryTimestamp = parseInt(timestampAttr, 10)
146147
console.log(`📅 Current expiry: ${new Date(currentExpiryTimestamp).toISOString()}`)
147148

148-
// 3️⃣ Click "extend"
149+
// Click "extend"
149150
const extendButton = page.getByTestId('extend-button')
150151
await extendButton.waitFor({ state: 'visible', timeout: 15000 })
151152
await extendButton.click()
152153

153-
// 4️⃣ Switch to "pick by date"
154+
// Switch to "pick by date"
154155
const dateSelection = page.getByTestId('date-selection')
155156
await expect(dateSelection).toHaveText('Pick by date')
156157
await dateSelection.click()
157158

158-
// 5️⃣ Fill the calendar with a date one day later
159+
// Fill the calendar with a date one day later
159160
const expiryTime = currentExpiryTimestamp / 1000
160161
const calendar = page.getByTestId('calendar')
161162
const dayLater = await page.evaluate((ts) => {
@@ -182,7 +183,7 @@ async function extendOwnedNameOnSepoliaApp(): Promise<void> {
182183
await confirmTransactionWithMetaMask()
183184

184185
// Wait for transaction to complete
185-
await page.waitForTimeout(15000)
186+
await page.waitForTimeout(25000)
186187

187188
// Close transaction complete modal
188189
const transactionCompleteButton = page.getByTestId('transaction-modal-complete-button')
@@ -205,6 +206,7 @@ async function extendOwnedNameOnSepoliaApp(): Promise<void> {
205206
)
206207
}
207208

209+
// Extend unowned name
208210
async function extendUnownedNameSepolia(): Promise<void> {
209211
const name = 'user1-extend.eth'
210212

@@ -238,7 +240,7 @@ async function extendUnownedNameSepolia(): Promise<void> {
238240

239241
// Switch to "pick by date"
240242
const dateSelection = page.getByTestId('date-selection')
241-
await expect(dateSelection).toHaveText('Pick by date')
243+
await expect(dateSelection).toHaveText('Pick by date', { timeout: 5000 })
242244
await dateSelection.click()
243245

244246
// Fill the calendar with a date one day later
@@ -292,7 +294,6 @@ async function extendUnownedNameSepolia(): Promise<void> {
292294
}
293295

294296
test.describe('ENS Sepolia Extend Name', () => {
295-
// Setup MM before the tests run
296297
test.beforeAll('Setup Metamask', async () => {
297298
console.log('🦊 Setting up MetaMask...')
298299
const [mm, pg, ctx] = await dappwright.bootstrap('chromium', {

e2e/specs/wallets/registerName-metamask.spec.ts

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ async function confirmTransactionWithMetaMask(
126126
await page.bringToFront()
127127
}
128128

129-
// Register name on Sepolia using MM
129+
// Register unowned name on Sepolia
130130
async function performRegistrationOnSepolia(name: string): Promise<void> {
131131
console.log(`🎯 Starting registration for ${name}`)
132132

@@ -142,7 +142,7 @@ async function performRegistrationOnSepolia(name: string): Promise<void> {
142142

143143
// Payment + primary toggle
144144
await page.locator('[data-testid="payment-choice-ethereum"]').check()
145-
// await page.locator('[data-testid="primary-name-toggle"]').check()
145+
await page.locator('[data-testid="primary-name-toggle"]').check()
146146

147147
// Proceed to profile step
148148
await page.locator('[data-testid="next-button"]').click()
@@ -180,9 +180,39 @@ async function performRegistrationOnSepolia(name: string): Promise<void> {
180180
console.log('🎉 ENS registration completed!')
181181
}
182182

183+
// Register owned name on Sepolia
184+
async function registerOwnedName() {
185+
const registeredName = 'registered-name.eth'
186+
187+
console.log(`🎯 Starting registration for ${registeredName}`)
188+
189+
// Search for name
190+
const searchInput = page.locator('input[placeholder="Search for a name"]')
191+
const searchResult = page.getByTestId('search-result-name')
192+
193+
await searchInput.waitFor({ timeout: 15000 })
194+
await searchInput.fill(registeredName)
195+
await expect(searchResult).toHaveText(registeredName)
196+
await expect(searchResult).toContainText('Registered')
197+
await searchInput.press('Enter')
198+
199+
// Register should not appear, profile shows instead
200+
await expect(page.getByRole('heading', { name: `Register ${registeredName}` })).not.toBeVisible({
201+
timeout: 15000,
202+
})
203+
204+
const profileSnippet = page.getByTestId('profile-snippet-name')
205+
await expect(profileSnippet).toHaveText('registered-name.eth', { timeout: 15000 })
206+
await expect(page.getByTestId('address-profile-button-eth')).toHaveText('0xaEa...1974F', {
207+
timeout: 15000,
208+
})
209+
210+
console.log(`❌ ${registeredName} has already been registered`)
211+
}
212+
183213
test.describe('ENS Sepolia Registration', () => {
184214
// Setup MM before the tests run
185-
test.beforeAll(async () => {
215+
test.beforeAll('Setup Metamask', async () => {
186216
console.log('🦊 Setting up MetaMask...')
187217
const [mm, pg, ctx] = await dappwright.bootstrap('chromium', {
188218
wallet: 'metamask',
@@ -199,6 +229,14 @@ test.describe('ENS Sepolia Registration', () => {
199229

200230
console.log('✅ MetaMask setup complete')
201231

232+
// Switch to User 2 account
233+
await page.click('[data-testid="account-menu-icon"]')
234+
await page.click('[data-testid="multichain-account-menu-popover-action-button"]')
235+
await page.click('[data-testid="multichain-account-menu-popover-add-account"]')
236+
await page.click('[data-testid="submit-add-account-with-name"]')
237+
238+
console.log('✅ Switched to User 2 account')
239+
202240
try {
203241
await metaMask.switchNetwork('Sepolia')
204242
console.log('✅ Switched to Sepolia network')
@@ -210,7 +248,7 @@ test.describe('ENS Sepolia Registration', () => {
210248
await connectWalletToEns()
211249

212250
// Generate a unique ENS name for tests
213-
ensName = `dappwright-test-${Date.now()}.eth`
251+
ensName = `registername-${Date.now()}.eth`
214252
})
215253

216254
test('Connect MetaMask to ENS Sepolia', async () => {
@@ -224,4 +262,8 @@ test.describe('ENS Sepolia Registration', () => {
224262
test('Register ENS name on Sepolia', async () => {
225263
await performRegistrationOnSepolia(ensName)
226264
})
265+
266+
test('Register owned ENS name on Sepolia', async () => {
267+
await registerOwnedName()
268+
})
227269
})

e2e/specs/wallets/subName-metamask.spec.ts

Lines changed: 76 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ async function confirmTransactionWithMetaMask(): Promise<void> {
123123
await page.bringToFront()
124124
}
125125

126+
// Create subname
126127
async function createSubName(name: string): Promise<void> {
127128
const walletName = 'subname-test.eth'
128129

@@ -161,17 +162,83 @@ async function createSubName(name: string): Promise<void> {
161162
await confirmTransactionWithMetaMask()
162163

163164
// Wait for transaction to complete
164-
await page.waitForTimeout(20000)
165+
await page.waitForTimeout(25000)
165166

166167
// Check subname is opened after transaction complete
167-
const subnameProfileName = page.getByTestId('profile-snippet-name')
168+
const nameProfileName = page.getByTestId('profile-snippet-name')
168169
const expectedSubname = `${ensName}.subname-test.eth`
169-
await expect(subnameProfileName).toHaveText(expectedSubname)
170+
await expect(nameProfileName).toHaveText(expectedSubname)
171+
172+
// Enter parent name profile
173+
await searchInput.waitFor({ timeout: 15000 })
174+
await searchInput.fill(walletName)
175+
await searchInput.press('Enter')
176+
await expect(nameProfileName).toHaveText(walletName, { timeout: 10000 })
177+
178+
// Switch to subname tab
179+
const parentSubnameTab = page.getByTestId('subnames-tab')
180+
await parentSubnameTab.click()
181+
182+
// Check created subname is appearing
183+
const subnameItem = page.getByTestId(`name-item-${ensName}.subname-test.eth`)
184+
await expect(subnameItem).toBeVisible({ timeout: 15000 })
185+
}
186+
187+
// Delete subname
188+
async function deleteSubName(name: string): Promise<void> {
189+
const walletName = 'subname-test.eth'
190+
191+
console.log(`🎯 Deleting ${name}.subname-test.eth`)
192+
193+
// Access created subname through search bar
194+
const searchInput = page.locator('input[placeholder="Search for a name"]')
195+
await searchInput.waitFor({ timeout: 15000 })
196+
await searchInput.fill(`${name}.subname-test.eth`)
197+
await searchInput.press('Enter')
198+
199+
// Confirm subname then click delete
200+
const profileName = page.getByTestId('profile-snippet-name')
201+
const expectedSubname = `${ensName}.subname-test.eth`
202+
await expect(profileName).toHaveText(expectedSubname)
203+
204+
const deleteSubnameButton = page.getByTestId('profile-action-Delete subname')
205+
await deleteSubnameButton.click()
206+
207+
// Start and confirm transaction
208+
await page.locator('text=Open Wallet').waitFor({ timeout: 10000 })
209+
await page.locator('text=Open Wallet').click()
210+
await confirmTransactionWithMetaMask()
211+
212+
// Wait for transaction to complete
213+
await page.waitForTimeout(25000)
214+
215+
// Click done to return to subname profile
216+
const transactionCompleteButton = page.getByTestId('transaction-modal-complete-button')
217+
await transactionCompleteButton.click()
218+
219+
// Check expiry has no expiry
220+
const expiryBox = page.getByTestId('owner-profile-button-name.expiry')
221+
await expect(expiryBox).toContainText('no expiry', { timeout: 15000 })
222+
223+
// Enter parent name profile
224+
const parentSubnameTab = page.getByTestId('subnames-tab')
225+
await searchInput.waitFor({ timeout: 15000 })
226+
await searchInput.fill(walletName)
227+
await searchInput.press('Enter')
228+
await expect(profileName).toHaveText(walletName, { timeout: 10000 })
229+
230+
// Switch to subname tab
231+
await parentSubnameTab.click()
232+
233+
// Check deleted subname is no longer appearing
234+
const subnameItem = page.getByTestId(`name-item-${ensName}.subname-test.eth`)
235+
await expect(subnameItem).not.toBeVisible({ timeout: 15000 })
236+
237+
console.log(`⚔️ {name} has been deleted`)
170238
}
171239

172240
test.describe('ENS Sepolia Connection', () => {
173-
// Setup MM before the tests run
174-
test.beforeAll(async () => {
241+
test.beforeAll('Setup Metamask', async () => {
175242
console.log('🦊 Setting up MetaMask...')
176243
const [mm, pg, ctx] = await dappwright.bootstrap('chromium', {
177244
wallet: 'metamask',
@@ -221,4 +288,8 @@ test.describe('ENS Sepolia Connection', () => {
221288
test('Create new ENS subname on Sepolia', async () => {
222289
await createSubName(ensName)
223290
})
291+
292+
test('Delete created ENS subname on Sepolia', async () => {
293+
await deleteSubName(ensName)
294+
})
224295
})

0 commit comments

Comments
 (0)