diff --git a/e2e/slashtags.e2e.js b/e2e/slashtags.e2e.js index 140c43510..0ef8ad07b 100644 --- a/e2e/slashtags.e2e.js +++ b/e2e/slashtags.e2e.js @@ -80,6 +80,7 @@ d('Profile and Contacts', () => { // - receive money and attach contact to the transaction // - backup and restore wallet from the seed // - check that everything is in place + // - delete profile it('Can manage Slashtags Profile', async () => { if (checkComplete('slash-1')) { @@ -281,6 +282,19 @@ d('Profile and Contacts', () => { element(by.text(satoshi.name).withAncestor(by.id('ContactSmall'))), ).toBeVisible(); + // DELETE PROFILE + await element(by.id('NavigationClose')).tap(); + await element(by.id('Header')).tap(); + await element(by.id('EditButton')).tap(); + await element(by.id('ProfileDeleteButton')).tap(); + await waitFor(element(by.id('DeleteDialog'))) + .toBeVisible() + .withTimeout(10000); + await element(by.id('DialogConfirm')).tap(); + await expect(element(by.id('EmptyProfileHeader'))).toBeVisible(); + await element(by.id('Header')).tap(); + await expect(element(by.id('OnboardingContinue'))).toBeVisible(); + markComplete('slash-1'); }); }); diff --git a/src/screens/Profile/ProfileEdit.tsx b/src/screens/Profile/ProfileEdit.tsx index 64678b671..45034bb88 100644 --- a/src/screens/Profile/ProfileEdit.tsx +++ b/src/screens/Profile/ProfileEdit.tsx @@ -13,6 +13,7 @@ import { useTranslation } from 'react-i18next'; import { ScrollView, View as ThemedView } from '../../styles/components'; import { BodyS } from '../../styles/text'; import { PlusIcon } from '../../styles/icons'; +import Dialog from '../../components/Dialog'; import NavigationHeader from '../../components/NavigationHeader'; import KeyboardAvoidingView from '../../components/KeyboardAvoidingView'; import Button from '../../components/buttons/Button'; @@ -31,9 +32,10 @@ import { BasicProfile } from '../../store/types/slashtags'; import { slashtagsLinksSelector } from '../../store/reselect/slashtags'; import { onboardingProfileStepSelector } from '../../store/reselect/slashtags'; import { arraysMatch } from '../../utils/helpers'; +import { deleteProfile, saveProfile } from '../../utils/slashtags'; +import { showToast } from '../../utils/notifications'; import ProfileLinkNavigation from '../../navigation/bottom-sheet/ProfileLinkNavigation'; import type { RootStackScreenProps } from '../../navigation/types'; -import { saveProfile } from '../../utils/slashtags'; const ProfileEdit = ({ navigation, @@ -42,7 +44,8 @@ const ProfileEdit = ({ const { url, profile: slashtagsProfile } = useSlashtags(); const { profile: savedProfile } = useProfile(url); const [hasEdited, setHasEdited] = useState(false); - const [isSaving, setIsSaving] = useState(false); + const [isLoading, setIsLoading] = useState(false); + const [showDeleteDialog, setShowDeleteDialog] = useState(false); const [fields, setFields] = useState>({}); const dispatch = useAppDispatch(); const links = useAppSelector(slashtagsLinksSelector); @@ -95,9 +98,9 @@ const ProfileEdit = ({ }; const onSave = async (): Promise => { - setIsSaving(true); + setIsLoading(true); const res = await saveProfile(url, profile, slashtagsProfile); - setIsSaving(false); + setIsLoading(false); if (res.isErr()) { return; } @@ -110,6 +113,23 @@ const ProfileEdit = ({ } }; + const onDelete = async (): Promise => { + setIsLoading(true); + const res = await deleteProfile(url, slashtagsProfile); + setIsLoading(false); + setShowDeleteDialog(false); + if (res.isErr()) { + return; + } + await Keyboard.dismiss(); + navigation.popToTop(); + showToast({ + type: 'success', + title: t('profile_delete_success_title'), + description: t('profile_delete_success_msg'), + }); + }; + const isValid = useCallback(() => { const isAnyLinkEmpty = links.some((link) => link.url === ''); @@ -160,12 +180,28 @@ const ProfileEdit = ({ {t('profile_public_warn')} {/* leave button visible over keyboard for onboarding */} - + + {onboardedProfile && ( +