@@ -123,6 +123,7 @@ async function confirmTransactionWithMetaMask(): Promise<void> {
123123 await page . bringToFront ( )
124124}
125125
126+ // Create subname
126127async 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
172240test . 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