From 84d0401e3c722acad5c5d4733177831a8bd2f981 Mon Sep 17 00:00:00 2001 From: Reinaldo Neto Date: Wed, 14 Dec 2022 19:09:14 -0300 Subject: [PATCH] refactor the e2e test --- .../ChangeAvatarView/AvatarSuggestion.tsx | 20 ++++++-- e2e/tests/assorted/03-profile.spec.ts | 50 ++++++++----------- 2 files changed, 38 insertions(+), 32 deletions(-) diff --git a/app/views/ChangeAvatarView/AvatarSuggestion.tsx b/app/views/ChangeAvatarView/AvatarSuggestion.tsx index ab2447f1d..cf7d9b31e 100644 --- a/app/views/ChangeAvatarView/AvatarSuggestion.tsx +++ b/app/views/ChangeAvatarView/AvatarSuggestion.tsx @@ -8,13 +8,23 @@ import Avatar from '../../containers/Avatar'; import styles from './styles'; import { useTheme } from '../../theme'; -const Item = ({ item, onPress, text }: { item?: IAvatar; onPress: (value?: IAvatar) => void; text?: string }) => { +const Item = ({ + item, + onPress, + text, + testID +}: { + item?: IAvatar; + testID?: string; + onPress: (value?: IAvatar) => void; + text?: string; +}) => { const { colors } = useTheme(); return ( onPress(item)} style={[styles.avatarButton, { backgroundColor: colors.borderColor }]} > @@ -55,9 +65,11 @@ const AvatarSuggestion = ({ {I18n.t('Images_uploaded')} - {user?.username && resetAvatar ? : null} + {user?.username && resetAvatar ? ( + + ) : null} {avatarSuggestions.slice(0, 7).map(item => ( - + ))} diff --git a/e2e/tests/assorted/03-profile.spec.ts b/e2e/tests/assorted/03-profile.spec.ts index 6f0304951..8f7014992 100644 --- a/e2e/tests/assorted/03-profile.spec.ts +++ b/e2e/tests/assorted/03-profile.spec.ts @@ -46,6 +46,10 @@ describe('Profile screen', () => { await expect(element(by.id('profile-view-avatar')).atIndex(0)).toExist(); }); + it('should have avatar edit button', async () => { + await expect(element(by.id('avatar-edit-button'))).toExist(); + }); + it('should have name', async () => { await expect(element(by.id('profile-view-name'))).toExist(); }); @@ -62,31 +66,6 @@ describe('Profile screen', () => { await expect(element(by.id('profile-view-new-password'))).toExist(); }); - it('should have avatar url', async () => { - await expect(element(by.id('profile-view-avatar-url'))).toExist(); - }); - - it('should have reset avatar button', async () => { - await waitFor(element(by.id('profile-view-reset-avatar'))) - .toExist() - .whileElement(by.id('profile-view-list')) - .scroll(scrollDown, 'down'); - }); - - it('should have upload avatar button', async () => { - await waitFor(element(by.id('profile-view-upload-avatar'))) - .toExist() - .whileElement(by.id('profile-view-list')) - .scroll(scrollDown, 'down'); - }); - - it('should have avatar url button', async () => { - await waitFor(element(by.id('profile-view-avatar-url-button'))) - .toExist() - .whileElement(by.id('profile-view-list')) - .scroll(scrollDown, 'down'); - }); - it('should have submit button', async () => { await waitFor(element(by.id('profile-view-submit'))) .toExist() @@ -122,9 +101,24 @@ describe('Profile screen', () => { }); it('should reset avatar', async () => { - await element(by.type(scrollViewType)).atIndex(1).swipe('up'); - await element(by.id('profile-view-reset-avatar')).tap(); - await waitForToast(); + await element(by.type(scrollViewType)).atIndex(1).swipe('down'); + await element(by.id('avatar-edit-button')).tap(); + await waitFor(element(by.id('change-avatar-view-avatar'))) + .toBeVisible() + .withTimeout(2000); + await waitFor(element(by.id('reset-avatar-suggestion'))) + .toBeVisible() + .withTimeout(2000); + await element(by.id('reset-avatar-suggestion')).tap(); + await sleep(300); + await waitFor(element(by.id('change-avatar-view-submit'))) + .toBeVisible() + .withTimeout(2000); + await element(by.id('change-avatar-view-submit')).tap(); + await sleep(300); + await waitFor(element(by.id('profile-view'))) + .toBeVisible() + .withTimeout(2000); }); }); });