Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: improve email testing #2480

Merged
merged 9 commits into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion android/fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,6 @@ platform :android do
browserstack_access_key: ENV["BROWSERSTACK_ACCESS_KEY"],
file_path: ENV["GRADLE_APK_OUTPUT_PATH"]
)
sh("GALOY_TEST_TOKENS=$GALOY_TEST_TOKENS && GALOY_TOKEN_2=$GALOY_TOKEN_2 && yarn test:browserstack:android")
sh("GALOY_TEST_TOKENS=$GALOY_TEST_TOKENS && GALOY_TOKEN_2=$GALOY_TOKEN_2 && MAILSLURP_API_KEY=$MAILSLURP_API_KEY && yarn test:browserstack:android")
end
end
9 changes: 4 additions & 5 deletions app/i18n/en/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,10 +429,9 @@ 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",
startWithTrialAccount: "Start with trial account",
registerPhoneAccount: "Register phone account",
trialAccountCreationFailed: "Trial account creation failed",
Expand Down Expand Up @@ -670,7 +669,7 @@ const en: BaseTranslation = {
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 @@ -796,13 +795,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
28 changes: 10 additions & 18 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 All @@ -1408,10 +1408,6 @@ type RootTranslation = {
* S​t​a​r​t​ ​w​i​t​h​ ​a​ ​t​r​i​a​l​ ​a​c​c​o​u​n​t
*/
startTrialAccount: string
/**
* I​ ​u​n​d​e​r​s​t​a​n​d​,​ ​c​o​n​t​i​n​u​e
*/
iUnderstand: string
/**
* S​t​a​r​t​ ​w​i​t​h​ ​t​r​i​a​l​ ​a​c​c​o​u​n​t
*/
Expand Down Expand Up @@ -2282,7 +2278,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 +2680,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 +2698,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 +4657,9 @@ export type TranslationFunctions = {
*/
exploreWallet: () => LocalizedString
/**
* Login back in with
* Log back in with
*/
loginBackInWith: () => LocalizedString
logBackInWith: () => LocalizedString
/**
* Wallet powered by Galoy
*/
Expand All @@ -4672,10 +4668,6 @@ export type TranslationFunctions = {
* Start with a trial account
*/
startTrialAccount: () => LocalizedString
/**
* I understand, continue
*/
iUnderstand: () => LocalizedString
/**
* Start with trial account
*/
Expand Down Expand Up @@ -5509,7 +5501,7 @@ export type TranslationFunctions = {
*/
unverified: () => LocalizedString
/**
* Your email is not verified
* Your email is unverified
*/
emailUnverified: () => LocalizedString
/**
Expand Down Expand Up @@ -5901,7 +5893,7 @@ export type TranslationFunctions = {
*/
success: (arg: { email: string }) => LocalizedString
}
EmailLoginInputScreen: {
EmailLoginInitiateScreen: {
/**
* Login via email
*/
Expand All @@ -5919,7 +5911,7 @@ export type TranslationFunctions = {
*/
send: () => LocalizedString
}
EmailLoginValidationScreen: {
EmailLoginValidateScreen: {
/**
* Code confirmation
*/
Expand Down
9 changes: 4 additions & 5 deletions app/i18n/raw-i18n/source/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -429,10 +429,9 @@
"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",
"startWithTrialAccount": "Start with trial account",
"registerPhoneAccount": "Register phone account",
"trialAccountCreationFailed": "Trial account creation failed",
Expand Down Expand Up @@ -659,7 +658,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 +781,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} />
Loading