User button and profile
A signed-in user opens their profile from UserButton, sees their own account, and can sign out or delete the account.
Sub-features
user-buttonopens UserProfileView for the signed-in user from the home UserButton.sections-and-backopens Manage account and Security from the profile, and returns to the profile with back from each.add-accountopens AuthView from the profile'sAdd accountrow.sign-outends the session from the homeSign outbutton.sign-out-profileends the session from the profile'sSign outrow.delete-accountdeletes the account from the profile's Security screen.
How to get to it (user POV)
- Tap the avatar UserButton on the signed-in home screen.
- Tap
Sign outon the home screen, or theSign outrow in the profile. - Open the profile, tap
Security, tapDelete account, typeDELETE, and tapDelete accountin the sheet.
Driving it with verify
Preconditions:
Each test seeds a
+clerk_testuser on the standard instance and signs in with a ticket on the home (host.launch({ signedInAs })). The launch lands when the home shows that user's email and user ID.Profile. Run
e2e-tests/bin/control-clerk-android run user-button-and-profile/profile. The first test tapsclerk.userButton.profileand expectsEdit profile. Screenshotuser-button-profile. It tapsclerk.userProfile.row.manageAccountand expects the user's email. Screenshotprofile.Sections and back. The second test seeds a user with a phone. It taps
clerk.userButton.profileand expectsEdit profile. Screenshotprofile-before-sections. It tapsclerk.userProfile.row.manageAccountand expects the user's email,PHONE NUMBER, the user's number as Clerk formats it, andCONNECTED ACCOUNTS. It presses back and expectsEdit profile. It tapsclerk.userProfile.row.security, expectsACTIVE DEVICES, presses back, and expectsEdit profilewith noACTIVE DEVICES. Screenshotsmanage-account-sectionsandprofile-after-back.Add account. The third test opens the profile the same way, taps
clerk.userProfile.row.addAccount, and expectsclerk.auth.start.continue. Screenshotadd-account.Sign out. The fourth test taps
e2e.auth.signOutand waits for the home to showSigned outwith no user ID and no session ID, then expectse2e.auth.signIn. Screenshotsigned-out.Sign out from the profile. The fifth test opens the profile, taps
clerk.userProfile.row.signOut, and waits for the same signed-out home. The profile closes when the user is gone. Screenshotsigned-out-from-profile.Delete account. Run
e2e-tests/bin/control-clerk-android run user-button-and-profile/delete-account. The spec launches withauthMode: 'signIn', opens the profile, tapsclerk.userProfile.row.security, and tapsDelete account. It expects the sheet's warning,Are you sure you want to delete your account? This action is permanent and irreversible., typesDELETEinto the one text box of the sheet, and taps the sheet'sDelete accountbutton. It waits for the home to showSigned out. It then tapse2e.auth.signIn, enters the deleted user's email, tapsclerk.auth.start.continue, and expectsCouldn't find your account.. Screenshotaccount-deleted.Proof.
specs/features/user-button-and-profile/profile.e2e.tsanddelete-account.e2e.tspass. The video shows the home naming the seeded user before each test opens the profile, andSigned outafter each sign-out.
Gotchas
Edit profile, the section headers of Manage account,ACTIVE DEVICES, and the user's email address on the profile have no test tag, so those checks use text.- The Security row opens a list of active devices with the public IP address and city of the machine that runs the emulator. No spec takes a screenshot while that list is on screen, and the video of a run shows it.
- The Security screen and the delete sheet have no test tags.
Delete accountis the text of the row on the Security screen, and of both the title and the button of the sheet. The screen tree leaves out what a sheet covers, so the text matches one node before the sheet opens and two after. The spec taps the row while it is the only match and the button with.last(). The confirmation field is the onlytextboxin the sheet. The button stays disabled until the field holdsDELETE. Signed outafter a deletion looks the same as after a sign-out. The sign-in attempt with the deleted email is what shows that the account is gone. It needsauthMode: 'signIn', because the default mode would start a sign-up for an unknown email.Couldn't find your account.shows in a message at the bottom of the sign-in screen that closes itself after a few seconds. It is Clerk's wording, so a change of it fails the spec.- A new application has reverification on, and the Platform API has no setting for it. Clerk accepts the deletion without another verification because the ticket sign-in happened seconds earlier. A spec that deletes the account long after its sign-in can be asked to verify again.
clerk.userButton.profileis the clickable icon button itself, with the avatar inside it. agent-device refuses a plain tap on it with "no parent-owned touch point outside its interactive descendants", so tap it withhost.tap(middleOf(locator)), andmiddleOfis inspecs/compose.ts.Edit profileis also the title of the screen it opens, so on its own it does not show that the profile's first screen is up.- Ticket sign-in is a shortcut, not the feature. It is fine here because this feature is not about authentication.
- The host shows a spinner while the ticket sign-in runs.
host.launchreturns once the home shows the user, and fails with the reason when the sign-in fails.