Skip to content

Commit

Permalink
chore: wip tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Burtey committed Jul 16, 2023
1 parent f704a93 commit 213224a
Show file tree
Hide file tree
Showing 16 changed files with 127 additions and 70 deletions.
2 changes: 1 addition & 1 deletion .storybook/storybook.requires.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const getStories = () => {
"./app/screens/earns-screen/earns-sections.stories.tsx": require("../app/screens/earns-screen/earns-sections.stories.tsx"),
"./app/screens/earns-screen/section-completed.stories.tsx": require("../app/screens/earns-screen/section-completed.stories.tsx"),
"./app/screens/email-login-screen/email-login-flow.stories.tsx": require("../app/screens/email-login-screen/email-login-flow.stories.tsx"),
"./app/screens/email-login-screen/email-login-validation.stories.tsx": require("../app/screens/email-login-screen/email-login-validation.stories.tsx"),
"./app/screens/email-login-screen/email-login-validate.stories.tsx": require("../app/screens/email-login-screen/email-login-validate.stories.tsx"),
"./app/screens/email-registration-screen/email-registration-initiate.stories.tsx": require("../app/screens/email-registration-screen/email-registration-initiate.stories.tsx"),
"./app/screens/email-registration-screen/email-registration-validate.stories.tsx": require("../app/screens/email-registration-screen/email-registration-validate.stories.tsx"),
"./app/screens/error-screen/error-screen.stories.tsx": require("../app/screens/error-screen/error-screen.stories.tsx"),
Expand Down
6 changes: 3 additions & 3 deletions app/i18n/en/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ const en: BaseTranslation = {
logInCreateAccount: "Log in / create account",
createAccount: "Create new account",
exploreWallet: "Explore wallet",
loginBackInWith: "Login back in with",
logBackInWith: "Log back in with",
headline: "Wallet powered by Galoy",
startTrialAccount: "Start with a trial account",
iUnderstand: "I understand, continue",
Expand Down Expand Up @@ -796,13 +796,13 @@ const en: BaseTranslation = {
header: "To confirm your email address, enter the code we just sent you on {email: string}",
success: "Email {email: string} confirmed successfully",
},
EmailLoginInputScreen: {
EmailLoginInitiateScreen: {
title: "Login via email",
header: "Enter your email address, and we'll send you an access code.",
invalidEmail: "Invalid email address. Are you sure you entered the right email?",
send: "Send code",
},
EmailLoginValidationScreen: {
EmailLoginValidateScreen: {
title: "Code confirmation",
header: "If there is an account attached to {email: string}, you should have received 6 digits code to enter below.\n\nIf you are not receiving anything, it's probably either because this is not the right email, the email is in your spam folder.",
success: "Email {email: string} confirmed successfully",
Expand Down
20 changes: 10 additions & 10 deletions app/i18n/i18n-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1397,9 +1397,9 @@ type RootTranslation = {
*/
exploreWallet: string
/**
* L​o​g​i​n​ ​b​a​c​k​ ​i​n​ ​w​i​t​h
* L​o​g​ ​b​a​c​k​ ​i​n​ ​w​i​t​h
*/
loginBackInWith: string
logBackInWith: string
/**
* W​a​l​l​e​t​ ​p​o​w​e​r​e​d​ ​b​y​ ​G​a​l​o​y
*/
Expand Down Expand Up @@ -2282,7 +2282,7 @@ type RootTranslation = {
*/
unverified: string
/**
* Y​o​u​r​ ​e​m​a​i​l​ ​i​s​ ​n​o​t​ ​v​e​r​i​f​i​e​d
* Y​o​u​r​ ​e​m​a​i​l​ ​i​s​ ​u​n​v​e​r​i​f​i​e​d
*/
emailUnverified: string
/**
Expand Down Expand Up @@ -2684,7 +2684,7 @@ type RootTranslation = {
*/
success: RequiredParams<'email'>
}
EmailLoginInputScreen: {
EmailLoginInitiateScreen: {
/**
* L​o​g​i​n​ ​v​i​a​ ​e​m​a​i​l
*/
Expand All @@ -2702,7 +2702,7 @@ type RootTranslation = {
*/
send: string
}
EmailLoginValidationScreen: {
EmailLoginValidateScreen: {
/**
* C​o​d​e​ ​c​o​n​f​i​r​m​a​t​i​o​n
*/
Expand Down Expand Up @@ -4661,9 +4661,9 @@ export type TranslationFunctions = {
*/
exploreWallet: () => LocalizedString
/**
* Login back in with
* Log back in with
*/
loginBackInWith: () => LocalizedString
logBackInWith: () => LocalizedString
/**
* Wallet powered by Galoy
*/
Expand Down Expand Up @@ -5509,7 +5509,7 @@ export type TranslationFunctions = {
*/
unverified: () => LocalizedString
/**
* Your email is not verified
* Your email is unverified
*/
emailUnverified: () => LocalizedString
/**
Expand Down Expand Up @@ -5901,7 +5901,7 @@ export type TranslationFunctions = {
*/
success: (arg: { email: string }) => LocalizedString
}
EmailLoginInputScreen: {
EmailLoginInitiateScreen: {
/**
* Login via email
*/
Expand All @@ -5919,7 +5919,7 @@ export type TranslationFunctions = {
*/
send: () => LocalizedString
}
EmailLoginValidationScreen: {
EmailLoginValidateScreen: {
/**
* Code confirmation
*/
Expand Down
8 changes: 4 additions & 4 deletions app/i18n/raw-i18n/source/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@
"logInCreateAccount": "Log in / create account",
"createAccount": "Create new account",
"exploreWallet": "Explore wallet",
"loginBackInWith": "Login back in with",
"logBackInWith": "Log back in with",
"headline": "Wallet powered by Galoy",
"startTrialAccount": "Start with a trial account",
"iUnderstand": "I understand, continue",
Expand Down Expand Up @@ -659,7 +659,7 @@
"removePhone": "Remove phone",
"removeEmail": "Remove email",
"unverified": " - Unverified",
"emailUnverified": "Your email is not verified",
"emailUnverified": "Your email is unverified",
"emailUnverifiedContent": "Ensure you can log back into your account by verifying your email. Do you want to do the verification now?"
},
"DefaultWalletScreen": {
Expand Down Expand Up @@ -782,13 +782,13 @@
"header": "To confirm your email address, enter the code we just sent you on {email: string}",
"success": "Email {email: string} confirmed successfully"
},
"EmailLoginInputScreen": {
"EmailLoginInitiateScreen": {
"title": "Login via email",
"header": "Enter your email address, and we'll send you an access code.",
"invalidEmail": "Invalid email address. Are you sure you entered the right email?",
"send": "Send code"
},
"EmailLoginValidationScreen": {
"EmailLoginValidateScreen": {
"title": "Code confirmation",
"header": "If there is an account attached to {email: string}, you should have received 6 digits code to enter below.\n\nIf you are not receiving anything, it's probably either because this is not the right email, the email is in your spam folder.",
"success": "Email {email: string} confirmed successfully"
Expand Down
16 changes: 8 additions & 8 deletions app/navigation/root-navigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ import {
EmailRegistrationValidateScreen,
} from "@app/screens/email-registration-screen"
import {
EmailLoginInputScreen,
EmailLoginValidationScreen,
EmailLoginInitiateScreen,
EmailLoginValidateScreen,
} from "@app/screens/email-login-screen"

const useStyles = makeStyles(({ colors }) => ({
Expand Down Expand Up @@ -337,19 +337,19 @@ export const RootStack = () => {
}}
/>
<RootNavigator.Screen
name="emailLoginInput"
component={EmailLoginInputScreen}
name="emailLoginInitiate"
component={EmailLoginInitiateScreen}
options={{
headerShown: true,
title: LL.EmailRegistrationInitiateScreen.title(),
title: LL.EmailLoginValidateScreen.title(),
}}
/>
<RootNavigator.Screen
name="emailLoginValidation"
component={EmailLoginValidationScreen}
name="emailLoginValidate"
component={EmailLoginValidateScreen}
options={{
headerShown: true,
title: LL.EmailRegistrationInitiateScreen.title(),
title: LL.EmailLoginValidateScreen.title(),
}}
/>
</RootNavigator.Navigator>
Expand Down
4 changes: 2 additions & 2 deletions app/navigation/stack-param-lists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ export type RootStackParamList = {
transactionLimitsScreen: undefined
emailRegistrationInitiate: undefined
emailRegistrationValidate: { email: string; emailRegistrationId: string }
emailLoginInput: undefined
emailLoginValidation: { email: string; emailLoginId: string }
emailLoginInitiate: undefined
emailLoginValidate: { email: string; emailLoginId: string }
}

export type ContactStackParamList = {
Expand Down
6 changes: 3 additions & 3 deletions app/screens/email-login-screen/email-login-flow.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
CaptchaRequestAuthCodeDocument,
UserEmailRegistrationInitiateDocument,
} from "../../graphql/generated"
import { EmailLoginInputScreen } from "./email-login-input"
import { EmailLoginInitiateScreen } from "./email-login-initiate"

const mocks = [
{
Expand Down Expand Up @@ -79,7 +79,7 @@ const mocks = [

export default {
title: "EmailLoginFlow",
component: EmailLoginInputScreen,
component: EmailLoginInitiateScreen,
decorators: [
(Story) => (
<MockedProvider mocks={mocks} cache={createCache()}>
Expand All @@ -89,4 +89,4 @@ export default {
],
}

export const Default = () => <EmailLoginInputScreen />
export const Default = () => <EmailLoginInitiateScreen />
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { View } from "react-native"
import validator from "validator"
import { Screen } from "../../components/screen"
import { useAppConfig } from "@app/hooks"
import { testProps } from "@app/utils/testProps"

const PLACEHOLDER_EMAIL = "[email protected]"
const useStyles = makeStyles(({ colors }) => ({
screenStyle: {
padding: 20,
Expand Down Expand Up @@ -47,7 +47,7 @@ const useStyles = makeStyles(({ colors }) => ({
},
}))

export const EmailLoginInputScreen: React.FC = () => {
export const EmailLoginInitiateScreen: React.FC = () => {
const styles = useStyles()
const {
appConfig: {
Expand All @@ -58,7 +58,7 @@ export const EmailLoginInputScreen: React.FC = () => {
const urlEmailCodeRequest = `${authUrl}/auth/email/code`

const navigation =
useNavigation<StackNavigationProp<RootStackParamList, "emailRegistrationInitiate">>()
useNavigation<StackNavigationProp<RootStackParamList, "emailLoginInitiate">>()

const [emailInput, setEmailInput] = React.useState<string>("")
const [errorMessage, setErrorMessage] = React.useState<string>("")
Expand All @@ -73,7 +73,7 @@ export const EmailLoginInputScreen: React.FC = () => {

const submit = async () => {
if (!validator.isEmail(emailInput)) {
setErrorMessage(LL.EmailLoginInputScreen.invalidEmail())
setErrorMessage(LL.EmailLoginInitiateScreen.invalidEmail())
return
}

Expand All @@ -92,7 +92,8 @@ export const EmailLoginInputScreen: React.FC = () => {
const emailLoginId = res.data.result

if (emailLoginId) {
navigation.navigate("emailLoginValidation", { emailLoginId, email: emailInput })
console.log({ emailLoginId })
navigation.navigate("emailLoginValidate", { emailLoginId, email: emailInput })
} else {
console.warn("no flow returned")
}
Expand Down Expand Up @@ -124,13 +125,14 @@ export const EmailLoginInputScreen: React.FC = () => {
>
<View style={styles.viewWrapper}>
<View style={styles.textContainer}>
<Text type={"p1"}>{LL.EmailLoginInputScreen.header()}</Text>
<Text type={"p1"}>{LL.EmailLoginInitiateScreen.header()}</Text>
</View>

<View style={styles.inputContainer}>
<Input
{...testProps(LL.EmailRegistrationInitiateScreen.placeholder())}
placeholder={LL.EmailRegistrationInitiateScreen.placeholder()}
autoCapitalize="none"
placeholder={PLACEHOLDER_EMAIL}
inputContainerStyle={styles.inputContainerStyle}
renderErrorMessage={false}
textContentType="emailAddress"
Expand All @@ -148,7 +150,7 @@ export const EmailLoginInputScreen: React.FC = () => {

<View style={styles.buttonsContainer}>
<GaloyPrimaryButton
title={LL.EmailLoginInputScreen.send()}
title={LL.EmailLoginInitiateScreen.send()}
loading={loading}
disabled={!emailInput}
onPress={submit}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,29 @@ import { Meta } from "@storybook/react"
import { MockedProvider } from "@apollo/client/testing"
import { createCache } from "../../graphql/cache"
import { StoryScreen } from "../../../.storybook/views"
import { EmailLoginValidationScreen } from "./email-login-validation"
import { EmailLoginValidateScreen } from "./email-login-validate"

const mocks = []

const route = {
key: "EmailLoginValidationScreen",
name: "emailLoginValidation",
key: "EmailLoginValidateScreen",
name: "emailLoginValidate",
params: {
phone: "+50365055543",
channel: "SMS",
},
} as const

export default {
title: "EmailLoginValidationScreen",
component: EmailLoginValidationScreen,
title: "EmailLoginValidateScreen",
component: EmailLoginValidateScreen,
decorators: [
(Story) => (
<MockedProvider mocks={mocks} cache={createCache()}>
<StoryScreen>{Story()}</StoryScreen>
</MockedProvider>
),
],
} as Meta<typeof EmailLoginValidationScreen>
} as Meta<typeof EmailLoginValidateScreen>

export const Main = () => <EmailLoginValidationScreen route={route} />
export const Main = () => <EmailLoginValidateScreen route={route} />
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { useCallback, useState } from "react"
import { ActivityIndicator, View } from "react-native"
import { Screen } from "../../components/screen"
import analytics from "@react-native-firebase/analytics"
import { testProps } from "@app/utils/testProps"

const useStyles = makeStyles(({ colors }) => ({
screenStyle: {
Expand Down Expand Up @@ -50,17 +51,19 @@ const useStyles = makeStyles(({ colors }) => ({
},
}))

type EmailLoginValidationScreenProps = {
route: RouteProp<RootStackParamList, "emailLoginValidation">
type EmailLoginValidateScreenProps = {
route: RouteProp<RootStackParamList, "emailLoginValidate">
}

export const EmailLoginValidationScreen: React.FC<EmailLoginValidationScreenProps> = ({
const placeholder = "000000"

export const EmailLoginValidateScreen: React.FC<EmailLoginValidateScreenProps> = ({
route,
}) => {
const styles = useStyles()
const { colors } = useTheme()
const navigation =
useNavigation<StackNavigationProp<RootStackParamList, "emailLoginValidation">>()
useNavigation<StackNavigationProp<RootStackParamList, "emailLoginValidate">>()

const [errorMessage, setErrorMessage] = React.useState<string>("")

Expand Down Expand Up @@ -147,11 +150,12 @@ export const EmailLoginValidationScreen: React.FC<EmailLoginValidationScreenProp
>
<View style={styles.viewWrapper}>
<View style={styles.textContainer}>
<Text type="h2">{LL.EmailLoginValidationScreen.header({ email })}</Text>
<Text type="h2">{LL.EmailLoginValidateScreen.header({ email })}</Text>
</View>

<Input
placeholder="000000"
{...testProps(placeholder)}
placeholder={placeholder}
containerStyle={styles.inputComponentContainerStyle}
inputContainerStyle={styles.inputContainerStyle}
inputStyle={styles.inputStyle}
Expand Down
4 changes: 2 additions & 2 deletions app/screens/email-login-screen/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from "./email-login-input"
export * from "./email-login-validation"
export * from "./email-login-initiate"
export * from "./email-login-validate"
Loading

0 comments on commit 213224a

Please sign in to comment.