Skip to content

Commit

Permalink
Fix e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rottabonus committed Jan 14, 2024
1 parent 9e541c0 commit 13955e1
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 39 deletions.
8 changes: 4 additions & 4 deletions e2e/browseMentorsTest.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('Browse mentors', () => {
try {
await expect(
element(by.text(accountFixtures.mentors[i].displayName)),
).toBeVisible();
).toBeVisible(50);
mentorsFound[accountFixtures.mentors[i].displayName] = true;
} catch (error) {
continue;
Expand All @@ -70,7 +70,7 @@ describe('Browse mentors', () => {
try {
await expect(
element(by.text(accountFixtures.mentors[i].displayName)),
).toBeVisible();
).toBeVisible(50);
mentorsFound[accountFixtures.mentors[i].displayName] = true;
} catch (error) {
continue;
Expand All @@ -83,7 +83,7 @@ describe('Browse mentors', () => {
try {
await expect(
element(by.text(accountFixtures.mentors[i].displayName)),
).toBeVisible();
).toBeVisible(50);
mentorsFound[accountFixtures.mentors[i].displayName] = true;
} catch (error) {
continue;
Expand Down Expand Up @@ -186,7 +186,7 @@ describe('Browse mentors', () => {

await signIn(mentor);

await expect(element(by.text(mentor.displayName))).toBeVisible();
await expect(element(by.text(mentor.displayName))).toBeVisible(50);
await element(by.text('Show mentor')).atIndex(0).tap();

await element(by.text('Chat')).tap();
Expand Down
6 changes: 3 additions & 3 deletions e2e/filterSkillTest.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('Skill filter', () => {
try {
await expect(
element(by.text(accountFixtures.mentors[i].displayName)),
).toBeVisible();
).toBeVisible(50);
mentorsFound[accountFixtures.mentors[i].displayName] = true;
} catch (error) {
continue;
Expand All @@ -64,7 +64,7 @@ describe('Skill filter', () => {
try {
await expect(
element(by.text(accountFixtures.mentors[i].displayName)),
).toBeVisible();
).toBeVisible(50);
mentorsFound[accountFixtures.mentors[i].displayName] = true;
} catch (error) {
continue;
Expand All @@ -77,7 +77,7 @@ describe('Skill filter', () => {
try {
await expect(
element(by.text(accountFixtures.mentors[i].displayName)),
).toBeVisible();
).toBeVisible(50);
mentorsFound[accountFixtures.mentors[i].displayName] = true;
} catch (error) {
continue;
Expand Down
2 changes: 1 addition & 1 deletion e2e/hideInactiveMentorsTest.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const findMentor = async (mentorIndexes: any, mentorsFound: any) => {
try {
await expect(
element(by.text(accountFixtures.mentors[Number(i)].displayName)),
).toBeVisible();
).toBeVisible(50);
found[accountFixtures.mentors[Number(i)].displayName] = true;
} catch (error) {
continue;
Expand Down
1 change: 1 addition & 0 deletions e2e/signInTest.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ describe('SignIn', () => {
0,
);

await element(by.id('tabs.settings')).tap();
await expect(
element(by.id('main.settings.account.displayName')),
).toHaveText(mentee.displayName);
Expand Down
2 changes: 1 addition & 1 deletion e2e/statusMessageTest.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe('Show status message', () => {

for (const mentorName of Object.keys(statusMessages)) {
try {
await expect(element(by.text(mentorName))).toBeVisible();
await expect(element(by.text(mentorName))).toBeVisible(50);
await expect(
element(by.text(statusMessages[mentorName])),
).toBeVisible();
Expand Down
6 changes: 5 additions & 1 deletion src/Screens/Main/BuddyList/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ const Button = ({ style, buddyId, name, onPress, ...viewProps }: Props) => {
</RN.Text>
</RN.View>
<RN.View style={styles.blob}>
<UnseenDot hasUnseen={hasNewMessages} style={styles.dot} />
<UnseenDot
hasUnseen={hasNewMessages}
style={styles.dot}
testID="main.buddyList.button.unseenDot"
/>
{mentor?.is_vacationing ? (
<RN.Image
source={require('../../images/umbrella-beach.svg')}
Expand Down
6 changes: 5 additions & 1 deletion src/Screens/Main/BuddyList/Title.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ export const Title: React.FC<Props> = ({
source={require('../../images/three-dot-menu.svg')}
style={styles.kebabIcon}
/>
<UnseenDot hasUnseen={hasUnseenArchivedMessages} style={styles.dot} />
<UnseenDot
hasUnseen={hasUnseenArchivedMessages}
style={styles.dot}
testID="main.chat.kebabicon.unseenDot"
/>
</>
</RN.TouchableHighlight>
</RN.SafeAreaView>
Expand Down
2 changes: 1 addition & 1 deletion src/Screens/Onboarding/Email.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const Email = ({ navigation, route }: Props) => {
onPress={goBack}
noShadow={true}
style={styles.backButton}
emphasis="low"
emphasis="medium"
/>
<Button
style={styles.nextButton}
Expand Down
2 changes: 1 addition & 1 deletion src/Screens/components/Modal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const Modal: React.FC<Props> = props => {
onPress={props.onSecondaryPress}
messageId={props.secondaryButtonMessage ?? 'meta.ok'}
style={[styles.button, styles.secondaryButton]}
emphasis="low"
emphasis="medium"
/>
)}
{props.onPrimaryPress && (
Expand Down
2 changes: 1 addition & 1 deletion src/Screens/components/Modal/modalProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const props = {
icon: require('../../images/error_icon.svg'),
},
success: {
backgroundColor: colors.green,
backgroundColor: colors.greenLight,
icon: require('../../images/success_icon.svg'),
},
info: {
Expand Down
1 change: 1 addition & 0 deletions src/Screens/components/colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const colors = {

// greens
green: '#75C550',
greenLight: '#81BC70',
};

export default colors;
31 changes: 6 additions & 25 deletions src/api/mentors.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as t from 'io-ts';
import * as TE from 'fp-ts/lib/TaskEither';

import isFinnishPhone from '../lib/isFinnishPhone';
import * as http from '../lib/http';

import * as config from './config';
Expand Down Expand Up @@ -95,25 +94,6 @@ export const fetchMentors: () => TE.TaskEither<
fromMentorList,
);

export function compareLang(a: Mentor, b: Mentor) {
if (isFinnishPhone) {
return 0;
}

const lang = 'Italian';
const hasLang = ({ languages }: Mentor) => languages.includes(lang);

if (hasLang(a) && !hasLang(b)) {
return -1;
}

if (!hasLang(a) && hasLang(b)) {
return 1;
}

return 0;
}

const compareIds = (userId: string | undefined, a: Mentor, b: Mentor) => {
const x: number = userId ? userId.charCodeAt(0) : 0;
const y = a.buddyId.charCodeAt(0);
Expand All @@ -122,11 +102,15 @@ const compareIds = (userId: string | undefined, a: Mentor, b: Mentor) => {
return Math.abs(x - z) - Math.abs(x - y);
};

const sortMe = (myUserId: string | undefined, a: Mentor, _b: Mentor) => {
const sortMe = (myUserId: string | undefined, a: Mentor, b: Mentor) => {
if (a.buddyId === myUserId) {
return -1;
}

if (b.buddyId === myUserId) {
return 1;
}

return 0;
};

Expand All @@ -145,9 +129,6 @@ const sortVacationing = (a: Mentor, b: Mentor) => {
export const compare =
(userId: string | undefined) => (a: Mentor, b: Mentor) => {
return (
sortMe(userId, a, b) ||
sortVacationing(a, b) ||
compareLang(a, b) ||
compareIds(userId, a, b)
sortVacationing(a, b) || sortMe(userId, a, b) || compareIds(userId, a, b)
);
};

0 comments on commit 13955e1

Please sign in to comment.