Skip to content

Commit a17fe62

Browse files
committed
sign in/up invalid e2e tests
1 parent 94533dd commit a17fe62

File tree

3 files changed

+86
-2
lines changed

3 files changed

+86
-2
lines changed
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
describe('Sign-in with Invalid Credentials', () => {
2+
beforeAll(async () => {
3+
await device.launchApp({
4+
newInstance: true,
5+
launchArgs: { isDetoxTest: true },
6+
});
7+
});
8+
9+
it('should display an error for invalid credentials', async () => {
10+
// Navigate to the sign-in screen and input invalid credentials
11+
await waitFor(element(by.id('email-input')))
12+
.toBeVisible()
13+
.withTimeout(5000);
14+
await element(by.id('email-input')).tap();
15+
await element(by.id('email-input')).typeText('[email protected]');
16+
17+
await waitFor(element(by.id('password-input')))
18+
.toBeVisible()
19+
.whileElement(by.id('scrollViewId')) // Replace with your ScrollView's testID
20+
.scroll(400, 'down');
21+
await element(by.id('password-input')).tap();
22+
await element(by.id('password-input')).typeText('wrongPassword');
23+
24+
// To close the keyboard (temp until figure out how to disable log warnings)
25+
if (device.getPlatform() === 'android') {
26+
await device.pressBack();
27+
}
28+
29+
// Submit the form
30+
await waitFor(element(by.id('sign-in-button')))
31+
.toBeVisible()
32+
.withTimeout(5000);
33+
await element(by.id('sign-in-button')).tap();
34+
35+
// Verify that an error message is displayed
36+
await waitFor(element(by.text('Invalid credentials')))
37+
.toBeVisible()
38+
.withTimeout(5000);
39+
});
40+
});
41+

SmartClothingApp/e2e/SignUpFlow.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ describe('Sign-up flow', () => {
5959
await waitFor(element(by.id('signup-terms-modal')))
6060
.toBeVisible()
6161
.whileElement(by.id('scrollViewModal'))
62-
.scrollTo('bottom');
63-
//.scroll(400, 'down');
62+
.scroll(400, 'down');
63+
//.scrollTo('bottom');
6464
//await element(by.id('signup-terms-modal-checkbox')).tap();
6565
await element(by.id('signup-terms-checkbox')).tap();
6666

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
describe('Sign-up with Invalid Credentials', () => {
2+
beforeAll(async () => {
3+
await device.launchApp({
4+
newInstance: true,
5+
launchArgs: { isDetoxTest: true },
6+
});
7+
});
8+
9+
it('should not allow sign up without accepting TOS', async () => {
10+
// Navigate to the sign-up screen and fill in the details except for TOS
11+
await new Promise(resolve => setTimeout(resolve, 10000));
12+
13+
await waitFor(element(by.id('signup-link')))
14+
.toBeVisible()
15+
.withTimeout(5000);
16+
await element(by.id('signup-link')).tap();
17+
18+
await element(by.id('signup-fname-input')).typeText('John');
19+
await waitFor(element(by.id('signup-lname-input')))
20+
.toBeVisible()
21+
.whileElement(by.id('scrollViewId'))
22+
.scroll(400, 'down');
23+
await element(by.id('signup-lname-input')).typeText('Doe');
24+
await element(by.id('signup-email-input')).typeText(`johndoe${Date.now()}@example.com`);
25+
await element(by.id('signup-password-input')).typeText('password123');
26+
await element(by.id('signup-repassword-input')).typeText('password123');
27+
28+
if (device.getPlatform() === 'android') {
29+
await device.pressBack();
30+
}
31+
32+
// Attempt to submit the form without accepting TOS
33+
await element(by.id('signup-submit-button')).tap();
34+
35+
// Verify that an error message is displayed or the user remains on the sign-up page
36+
await waitFor(element(by.id('signup-submit-button')))
37+
.toBeVisible()
38+
.withTimeout(10000); // Adjust according to your app's error handling
39+
await element(by.id('signup-submit-button')).tap();
40+
// Optionally, check for a specific error message if your app provides one
41+
});
42+
});
43+

0 commit comments

Comments
 (0)