@@ -264,4 +264,51 @@ export default function Page() {
264264 state : 'visible' ,
265265 } ) ;
266266 } ) ;
267+
268+ test ( 'can delete account' , async ( { page, context } ) => {
269+ const m = createTestUtils ( { app } ) ;
270+ const delFakeUser = m . services . users . createFakeUser ( {
271+ withUsername : true ,
272+ fictionalEmail : true ,
273+ withPhoneNumber : true ,
274+ } ) ;
275+ await m . services . users . createBapiUser ( {
276+ ...delFakeUser ,
277+ username : undefined ,
278+ phoneNumber : undefined ,
279+ } ) ;
280+
281+ const u = createTestUtils ( { app, page, context } ) ;
282+ await u . po . signIn . goTo ( ) ;
283+ await u . po . signIn . waitForMounted ( ) ;
284+ await u . po . signIn . signInWithEmailAndInstantPassword ( { email : delFakeUser . email , password : delFakeUser . password } ) ;
285+ await u . po . expect . toBeSignedIn ( ) ;
286+
287+ await u . po . userProfile . goTo ( ) ;
288+ await u . po . userProfile . waitForMounted ( ) ;
289+ await u . po . userProfile . switchToSecurityTab ( ) ;
290+
291+ await u . page
292+ . getByRole ( 'button' , {
293+ name : / d e l e t e a c c o u n t / i,
294+ } )
295+ . click ( ) ;
296+
297+ await u . page . locator ( 'input[name=deleteConfirmation]' ) . fill ( 'Delete account' ) ;
298+
299+ await u . page
300+ . getByRole ( 'button' , {
301+ name : / d e l e t e a c c o u n t / i,
302+ } )
303+ . click ( ) ;
304+
305+ await u . po . expect . toBeSignedOut ( ) ;
306+
307+ await u . page . waitForAppUrl ( '/' ) ;
308+
309+ // Make sure that the session cookie is deleted
310+ const sessionCookieList = ( await u . page . context ( ) . cookies ( ) ) . filter ( cookie => cookie . name === '__session' ) ;
311+
312+ expect ( sessionCookieList . length ) . toBe ( 0 ) ;
313+ } ) ;
267314} ) ;
0 commit comments