Skip to content

Commit

Permalink
Improve shouldSetHeight condition, remove dead code
Browse files Browse the repository at this point in the history
- Change ternary to normal logic operator
- Remove unused test (no admin login)
- Remove dead code from admin login
  • Loading branch information
rottabonus committed Feb 13, 2024
1 parent d33c170 commit b637e80
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 123 deletions.
106 changes: 0 additions & 106 deletions e2e/signInTest.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ import {
APISignUpMentee,
APIDeleteAccounts,
signIn,
getAdminCredentials,
scrollDownAndTap,
waitAndTypeText,
forceLogout,
} from './helpers';

Expand Down Expand Up @@ -41,107 +38,4 @@ describe('SignIn', () => {
mentee.email,
);
});

xit('admin succesfully', async () => {
const signInView = element(by.id('onboarding.signIn.view'));

await scrollDownAndTap(
'onboarding.welcome.button',
'onboarding.welcome.view',
);
await scrollDownAndTap(
'onboarding.mentorlist.start',
'onboarding.mentorlist.view',
);
await scrollDownAndTap('onboarding.sign.in', 'onboarding.mentorlist.view');

await element(by.text('Admin-login')).tap();

const { user, pass, token } = getAdminCredentials();

await waitAndTypeText('onboarding.signUp.userName', `${user}`, true);

await signInView.tap({ x: 1, y: 1 });

await waitAndTypeText('onboarding.signUp.password', `${pass}`, true);

await signInView.tap({ x: 1, y: 1 });

await waitAndTypeText('onboarding.signIn.mfa', `${token}`, true);

await signInView.tap({ x: 1, y: 1 });

await waitFor(element(by.id('onboarding.signUp.button')))
.toBeVisible()
.withTimeout(5000);

await scrollDownAndTap(
'onboarding.signUp.button',
'onboarding.signUp.view',
0,
0,
);
await element(by.id('tabs.settings')).tap();
await expect(element(by.id('main.settings.account.userName'))).toHaveText(
user,
);
});

xit('mentee can login even if fill mfa', async () => {
const mentee = accountFixtures.mentees[0];
await APISignUpMentee(mentee);

const signInView = element(by.id('onboarding.signIn.view'));

await scrollDownAndTap(
'onboarding.welcome.button',
'onboarding.welcome.view',
);
await scrollDownAndTap(
'onboarding.mentorlist.start',
'onboarding.mentorlist.view',
);
await scrollDownAndTap('onboarding.sign.in', 'onboarding.mentorlist.view');

await element(by.text('Admin-login')).tap();

await waitAndTypeText(
'onboarding.signUp.userName',
`${mentee.loginName}`,
true,
);

await signInView.tap({ x: 1, y: 1 });

await waitAndTypeText(
'onboarding.signUp.password',
`${mentee.password}`,
true,
);

await signInView.tap({ x: 1, y: 1 });

await waitAndTypeText('onboarding.signIn.mfa', `000000`, true);

await signInView.tap({ x: 1, y: 1 });

await waitFor(element(by.id('onboarding.signUp.button')))
.toBeVisible()
.withTimeout(5000);

await scrollDownAndTap(
'onboarding.signUp.button',
'onboarding.signUp.view',
0,
0,
);

await element(by.id('tabs.settings')).tap();
await expect(
element(by.id('main.settings.account.displayName')),
).toHaveText(mentee.displayName);
await expect(element(by.id('main.settings.account.email'))).toHaveText(
mentee.email,
);
});
});
17 changes: 2 additions & 15 deletions src/Screens/Onboarding/SignIn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import { StackRoutes } from '..';

import OnboardingBackground from '../components/OnboardingBackground';
import LoginCard from '../components/LoginCard';
import fonts from '../components/fonts';
import colors from '../components/colors';

export type SignInRoute = {
'Onboarding/SignIn': {};
Expand All @@ -41,8 +39,8 @@ const SignIn = (props: Props) => {
props.navigation.goBack();
};

const onLogin = (creds: authApi.Credentials) => {
props.login(creds);
const onLogin = (credentials: authApi.Credentials) => {
props.login(credentials);
};

return (
Expand All @@ -64,17 +62,6 @@ const styles = RN.StyleSheet.create({
card: {
flex: 1,
},
infoContainer: {
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
paddingVertical: 8,
},
infoText: {
...fonts.regular,
color: colors.darkestBlue,
},
});

export default ReactRedux.connect<
Expand Down
3 changes: 1 addition & 2 deletions src/lib/use-layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ export default function (

const isKeyboardVisible = useIsKeyboardShown();

const shouldSetHeight =
keyboardShouldNotSetHeight && isKeyboardVisible ? false : true;
const shouldSetHeight = !(keyboardShouldNotSetHeight && isKeyboardVisible);

const onLayout = (event: RN.LayoutChangeEvent) => {
const { width, height } = event.nativeEvent.layout;
Expand Down

0 comments on commit b637e80

Please sign in to comment.