refactor the e2e test
This commit is contained in:
parent
84b16b2d97
commit
84d0401e3c
|
@ -8,13 +8,23 @@ import Avatar from '../../containers/Avatar';
|
||||||
import styles from './styles';
|
import styles from './styles';
|
||||||
import { useTheme } from '../../theme';
|
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();
|
const { colors } = useTheme();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
key={item?.service}
|
key={item?.service}
|
||||||
testID={`${item?.service}-avatar-suggestion`}
|
testID={testID}
|
||||||
onPress={() => onPress(item)}
|
onPress={() => onPress(item)}
|
||||||
style={[styles.avatarButton, { backgroundColor: colors.borderColor }]}
|
style={[styles.avatarButton, { backgroundColor: colors.borderColor }]}
|
||||||
>
|
>
|
||||||
|
@ -55,9 +65,11 @@ const AvatarSuggestion = ({
|
||||||
<View style={{ flex: 1 }}>
|
<View style={{ flex: 1 }}>
|
||||||
<Text style={styles.itemLabel}>{I18n.t('Images_uploaded')}</Text>
|
<Text style={styles.itemLabel}>{I18n.t('Images_uploaded')}</Text>
|
||||||
<View style={styles.containerAvatarSuggestion}>
|
<View style={styles.containerAvatarSuggestion}>
|
||||||
{user?.username && resetAvatar ? <Item text={`@${user.username}`} onPress={resetAvatar} /> : null}
|
{user?.username && resetAvatar ? (
|
||||||
|
<Item text={`@${user.username}`} testID={`reset-avatar-suggestion`} onPress={resetAvatar} />
|
||||||
|
) : null}
|
||||||
{avatarSuggestions.slice(0, 7).map(item => (
|
{avatarSuggestions.slice(0, 7).map(item => (
|
||||||
<Item item={item} onPress={onPress} />
|
<Item item={item} testID={`${item?.service}-avatar-suggestion`} onPress={onPress} />
|
||||||
))}
|
))}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|
|
@ -46,6 +46,10 @@ describe('Profile screen', () => {
|
||||||
await expect(element(by.id('profile-view-avatar')).atIndex(0)).toExist();
|
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 () => {
|
it('should have name', async () => {
|
||||||
await expect(element(by.id('profile-view-name'))).toExist();
|
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();
|
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 () => {
|
it('should have submit button', async () => {
|
||||||
await waitFor(element(by.id('profile-view-submit')))
|
await waitFor(element(by.id('profile-view-submit')))
|
||||||
.toExist()
|
.toExist()
|
||||||
|
@ -122,9 +101,24 @@ describe('Profile screen', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should reset avatar', async () => {
|
it('should reset avatar', async () => {
|
||||||
await element(by.type(scrollViewType)).atIndex(1).swipe('up');
|
await element(by.type(scrollViewType)).atIndex(1).swipe('down');
|
||||||
await element(by.id('profile-view-reset-avatar')).tap();
|
await element(by.id('avatar-edit-button')).tap();
|
||||||
await waitForToast();
|
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);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue