@@ -2,22 +2,17 @@ import { expect } from '@playwright/test'
22import { labelhash } from 'viem'
33
44import { getResolver } from '@ensdomains/ensjs/public'
5- import { setPrimaryName } from '@ensdomains/ensjs/wallet'
65
76import { test } from '../../../playwright'
87import { createAccounts } from '../../../playwright/fixtures/accounts'
9- import {
10- waitForTransaction ,
11- walletClient ,
12- } from '../../../playwright/fixtures/contracts/utils/addTestContracts'
8+ import { walletClient } from '../../../playwright/fixtures/contracts/utils/addTestContracts'
9+ import { setPrimaryNameState } from '../../../playwright/fixtures/primaryName'
1310
1411const UNAUTHORISED_RESOLVER = '0xd7a4F6473f32aC2Af804B3686AE8F1932bC35750'
1512
1613test . afterAll ( async ( ) => {
17- await setPrimaryName ( walletClient , {
18- name : '' ,
19- account : createAccounts ( ) . getAddress ( 'user' ) as `0x${string } `,
20- } )
14+ const accounts = createAccounts ( )
15+ await setPrimaryNameState ( accounts , { user : 'user' , state : { l1 : '' , default : '' } } )
2116} )
2217
2318test . describe ( 'profile' , ( ) => {
@@ -46,10 +41,7 @@ test.describe('profile', () => {
4641 addr : 'user' ,
4742 } )
4843
49- await setPrimaryName ( walletClient , {
50- name : '' ,
51- account : createAccounts ( ) . getAddress ( 'user' ) as `0x${string } `,
52- } )
44+ await setPrimaryNameState ( accounts , { user : 'user' , state : { l1 : '' , default : '' } } )
5345
5446 const profilePage = makePageObject ( 'ProfilePage' )
5547 const transactionModal = makePageObject ( 'TransactionModal' )
@@ -71,9 +63,9 @@ test.describe('profile', () => {
7163 )
7264
7365 await page . getByText ( 'Set as primary name' ) . click ( )
74- // Transaction modal
66+ // Transaction modal - uses default registry when no L1 primary name exists
7567 await expect ( page . getByTestId ( 'display-item-info-normal' ) ) . toContainText (
76- 'Set the primary name for your address' ,
68+ 'Set the default primary name for your address' ,
7769 )
7870 await expect ( page . getByTestId ( 'display-item-name-normal' ) ) . toContainText ( name )
7971 await expect ( page . getByTestId ( 'display-item-address-normal' ) ) . toContainText ( / 0 x f 3 9 ...9 2 2 6 6 / )
@@ -110,10 +102,7 @@ test.describe('profile', () => {
110102 } ) => {
111103 test . slow ( )
112104
113- await setPrimaryName ( walletClient , {
114- name : '' ,
115- account : createAccounts ( ) . getAddress ( 'user' ) as `0x${string } `,
116- } )
105+ await setPrimaryNameState ( accounts , { user : 'user' , state : { l1 : '' , default : '' } } )
117106
118107 const name = await makeName ( {
119108 label : 'other-eth-record' ,
@@ -157,10 +146,7 @@ test.describe('profile', () => {
157146 } ) => {
158147 test . slow ( )
159148
160- await setPrimaryName ( walletClient , {
161- name : '' ,
162- account : createAccounts ( ) . getAddress ( 'user' ) as `0x${string } `,
163- } )
149+ await setPrimaryNameState ( accounts , { user : 'user' , state : { l1 : '' , default : '' } } )
164150
165151 const name = await makeName ( {
166152 label : 'wrapped' ,
@@ -215,10 +201,7 @@ test.describe('profile', () => {
215201 } ) => {
216202 test . slow ( )
217203
218- await setPrimaryName ( walletClient , {
219- name : '' ,
220- account : createAccounts ( ) . getAddress ( 'user' ) as `0x${string } `,
221- } )
204+ await setPrimaryNameState ( accounts , { user : 'user' , state : { l1 : '' , default : '' } } )
222205
223206 const name = await makeName ( {
224207 label : 'wrapped' ,
@@ -287,6 +270,7 @@ test.describe('profile', () => {
287270 test ( 'should skip setting primary name step if reverse registry name is already set to that name' , async ( {
288271 page,
289272 login,
273+ accounts,
290274 makeName,
291275 makePageObject,
292276 } ) => {
@@ -306,11 +290,8 @@ test.describe('profile', () => {
306290 } )
307291 const subname = `test.${ name } `
308292
309- const tx = await setPrimaryName ( walletClient , {
310- name : subname ,
311- account : createAccounts ( ) . getAddress ( 'user' ) as `0x${string } `,
312- } )
313- await waitForTransaction ( tx )
293+ // Set L1 primary name first to test that the primary name step is skipped
294+ await setPrimaryNameState ( accounts , { user : 'user' , state : { l1 : subname } } )
314295
315296 const profilePage = makePageObject ( 'ProfilePage' )
316297 const transactionModal = makePageObject ( 'TransactionModal' )
@@ -396,12 +377,7 @@ test.describe('profile', () => {
396377 } ) => {
397378 test . slow ( )
398379
399- const tx = await setPrimaryName ( walletClient , {
400- name : '' ,
401- account : createAccounts ( ) . getAddress ( 'user' ) as `0x${string } `,
402- } )
403- await waitForTransaction ( tx )
404- console . log ( 'tx' , tx )
380+ await setPrimaryNameState ( accounts , { user : 'user' , state : { l1 : '' , default : '' } } )
405381
406382 const label = `unknown-label-${ Date . now ( ) } `
407383 const _labelhash = labelhash ( label )
@@ -454,11 +430,7 @@ test.describe('profile', () => {
454430 } ) => {
455431 test . slow ( )
456432
457- const tx = await setPrimaryName ( walletClient , {
458- name : '' ,
459- account : createAccounts ( ) . getAddress ( 'user' ) as `0x${string } `,
460- } )
461- await waitForTransaction ( tx )
433+ await setPrimaryNameState ( accounts , { user : 'user' , state : { l1 : '' , default : '' } } )
462434
463435 const name = await makeName ( {
464436 label : 'legacy' ,
0 commit comments