Skip to content

Commit 94533dd

Browse files
committed
signup flow - trouble with modal scroll
1 parent 46c40d6 commit 94533dd

File tree

5 files changed

+118
-7
lines changed

5 files changed

+118
-7
lines changed

SmartClothingApp/App.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ import {
2020
import SplashScreen from "react-native-splash-screen";
2121

2222

23+
// For Testing purposes only
24+
import { LogBox } from "react-native";
2325
// Ignore all log notifications if it's in the test environment
24-
if (__DEV__ && process.env.NODE_ENV === 'test') {
25-
LogBox.ignoreAllLogs();
26-
}
26+
LogBox.ignoreAllLogs();
2727

2828

2929
const store = configureStore();
+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
2+
3+
4+
function delay(time) {
5+
return new Promise(resolve => setTimeout(resolve, time));
6+
}
7+
8+
9+
describe('Sign-up flow', () => {
10+
beforeAll(async () => {
11+
await device.launchApp({
12+
newInstance: true,
13+
launchArgs: { isDetoxTest: true }
14+
});
15+
});
16+
17+
it('should allow a user to sign up and delete the account after', async () => {
18+
19+
await new Promise(resolve => setTimeout(resolve, 10000));
20+
21+
// Wait for the sign-up link to be visible
22+
await waitFor(element(by.id('signup-link'))).toBeVisible().withTimeout(10000);
23+
24+
// Introduce a delay (e.g., 2000 milliseconds)
25+
await new Promise(resolve => setTimeout(resolve, 10000));
26+
await element(by.id('signup-link')).tap();
27+
28+
await waitFor(element(by.id('signup-fname-input'))).toBeVisible().withTimeout(5000);
29+
await element(by.id('signup-fname-input')).typeText('TestFirstName');
30+
31+
await waitFor(element(by.id('signup-lname-input')))
32+
.toBeVisible()
33+
.whileElement(by.id('scrollViewId'))
34+
.scroll(400, 'down');
35+
await element(by.id('signup-lname-input')).typeText('TestLastName');
36+
37+
await waitFor(element(by.id('signup-email-input'))).toBeVisible().withTimeout(5000);
38+
// const testEmail = `test${new Date().getTime()}@example.com`; // Dynamic email to avoid conflicts
39+
await element(by.id('signup-email-input')).typeText('[email protected]');
40+
//await element(by.id('signup-email-input')).typeText(`test${Date.now()}@example.com`);
41+
42+
await waitFor(element(by.id('signup-password-input'))).toBeVisible().withTimeout(5000);
43+
await element(by.id('signup-password-input')).typeText('password123');
44+
45+
await waitFor(element(by.id('signup-repassword-input'))).toBeVisible().withTimeout(5000);
46+
await element(by.id('signup-repassword-input')).typeText('password123');
47+
48+
if (device.getPlatform() === 'android') {
49+
await device.pressBack(); // to close the keyboard
50+
}
51+
52+
// Accepting terms and conditions
53+
await element(by.id('signup-terms-checkbox')).tap();
54+
//await element(by.id('signup-terms-checkbox')).tap();
55+
56+
// Use the delay function before scrolling
57+
await delay(30000); // Waits for 50 seconds
58+
59+
await waitFor(element(by.id('signup-terms-modal')))
60+
.toBeVisible()
61+
.whileElement(by.id('scrollViewModal'))
62+
.scrollTo('bottom');
63+
//.scroll(400, 'down');
64+
//await element(by.id('signup-terms-modal-checkbox')).tap();
65+
await element(by.id('signup-terms-checkbox')).tap();
66+
67+
// await waitFor(element(by.id('signup-terms-modal'))).toBeVisible().withTimeout(5000);
68+
69+
await element(by.id('close-modal-button')).tap();
70+
71+
72+
73+
// Attempt to scroll a significant distance down
74+
//await element(by.id('scrollViewModal')).scroll(200, 'down');
75+
76+
// await waitFor(element(by.id('signup-terms-modal-checkbox')))
77+
// .toBeVisible()
78+
// .whileElement(by.id('scrollViewModal'))
79+
// .scroll(400, 'down');
80+
81+
//await element(by.id('signup-terms-modal-checkbox')).tap();
82+
83+
await waitFor(element(by.id('signup-submit-button'))).toBeVisible().withTimeout(5000);
84+
await element(by.id('signup-submit-button')).tap();
85+
86+
// Assuming you navigate to a "success" screen after sign up
87+
await waitFor(element(by.id('signup-success-message'))).toBeVisible().withTimeout(10000);
88+
89+
// Here, you should add validation that the sign-up was successful
90+
// For example, checking for a welcome message or successful navigation
91+
92+
// **Teardown - Deleting the test account**
93+
// This step assumes you have a mechanism to trigger account deletion via an API or direct backend call
94+
// The implementation of this would be specific to your backend and not provided here
95+
}, 300000);
96+
97+
afterAll(async () => {
98+
// Cleanup: delete the account if your test created one.
99+
// This is pseudocode and would need to be adapted to your application's context.
100+
// await deleteTestAccount(testEmail, 'password123');
101+
});
102+
});

SmartClothingApp/src/components/ToSModal/ToSModal.jsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ const ToSModal = (props) => {
2020
transparent={true}
2121
visible={props.visible}
2222
onRequestClose={props.toggleModalVisibility}
23+
testID="signup-terms-modal"
2324
>
2425
<View style={styles.centeredView}>
2526
<View style={styles.modalView}>
26-
<ScrollView>
27+
<ScrollView testID="scrollViewModal">
2728
<Text style={styles.modalTextTitle}>
2829
Smart Textile Clothing Devices App - Terms of Use
2930
</Text>
@@ -189,6 +190,7 @@ const ToSModal = (props) => {
189190
onPress={() => {
190191
props.setIsTermsAccepted(!props.isTermsAccepted);
191192
}}
193+
testID="signup-terms-modal-checkbox"
192194
/>
193195
<Text style={styles.modalText}>{"I Agree"}</Text>
194196
</View>

SmartClothingApp/src/screens/SigninScreen/index.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ const SigninScreen = ({ navigation }) => {
177177
</Button>
178178
</View>
179179
{/* <GoogleButton /> */}
180-
<Button mode="text" onPress={() => navigation.navigate("SignUp")}>
180+
<Button mode="text" onPress={() => navigation.navigate("SignUp")} testID="signup-link">
181181
Don't have an account? Sign Up
182182
</Button>
183183
</ScrollView>

SmartClothingApp/src/screens/SignupScreen/index.jsx

+9-2
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ const SignupScreen = ({ navigation }) => {
150150
};
151151

152152
return (
153-
<ScrollView>
153+
<ScrollView testID="scrollViewId">
154154
<HeroSection />
155155
<View style={styles.content}>
156156
<ToSModal
@@ -160,6 +160,7 @@ const SignupScreen = ({ navigation }) => {
160160
closeModal={() => closeModal("modal1")}
161161
onRequestClose={toggleModalVisibility}
162162
toggleModalVisibility={toggleModalVisibility}
163+
testID="signup-terms-modal"
163164
></ToSModal>
164165
<Text
165166
variant="headlineMedium"
@@ -183,6 +184,7 @@ const SignupScreen = ({ navigation }) => {
183184
handleClearErrors();
184185
}}
185186
error={error.fname.length > 0}
187+
testID="signup-fname-input"
186188
/>
187189
<HelperText type="error" visible={error.fname.length > 0}>
188190
{error.fname}
@@ -198,6 +200,7 @@ const SignupScreen = ({ navigation }) => {
198200
handleClearErrors();
199201
}}
200202
error={error.lname.length > 0}
203+
testID="signup-lname-input"
201204
/>
202205
<HelperText type="error" visible={error.lname.length > 0}>
203206
{error.lname}
@@ -213,6 +216,7 @@ const SignupScreen = ({ navigation }) => {
213216
handleClearErrors();
214217
}}
215218
error={error.email.length > 0}
219+
testID="signup-email-input"
216220
/>
217221
<HelperText type="error" visible={error.email.length > 0}>
218222
{error.email}
@@ -232,6 +236,7 @@ const SignupScreen = ({ navigation }) => {
232236
error.password.length > 0 || user.password != user.repassword
233237
}
234238
style={styles.textInput}
239+
testID="signup-password-input"
235240
/>
236241
<Icon
237242
name={lockStatusPassword === "locked" ? "lock" : "unlock-alt"}
@@ -256,6 +261,7 @@ const SignupScreen = ({ navigation }) => {
256261
}}
257262
error={user.password != user.repassword}
258263
style={styles.textInput}
264+
testID="signup-repassword-input"
259265
/>
260266
<Icon
261267
name={lockStatusRepassword === "locked" ? "lock" : "unlock-alt"}
@@ -275,6 +281,7 @@ const SignupScreen = ({ navigation }) => {
275281
onPress={() => {
276282
handleAgreement();
277283
}}
284+
testID="signup-terms-checkbox"
278285
/>
279286
<Text style={error.accepted?.length > 0 ? styles.errorText : null}>
280287
{error.accepted?.length > 0 ? error.accepted : "User Agreement"}
@@ -307,7 +314,7 @@ const SignupScreen = ({ navigation }) => {
307314
</View>
308315
{/* <GoogleButton /> */}
309316
<View style={{ marginVertical: verticalScale(10) }}>
310-
<Button mode="text" onPress={() => navigation.navigate("SignIn")}>
317+
<Button mode="text" onPress={() => navigation.navigate("SignIn")} testID="signup-submit-button">
311318
Already have an account? Sign in.
312319
</Button>
313320
</View>

0 commit comments

Comments
 (0)