-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsignup.e2e.js
More file actions
204 lines (174 loc) · 8.47 KB
/
Copy pathsignup.e2e.js
File metadata and controls
204 lines (174 loc) · 8.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
import { driver, expect, $ } from '@wdio/globals';
import OnboardingProfilePicScreen from '../pageobjects/Onboarding/OnboardingProfilePicScreen.page';
import SignupStep1Page from '../pageobjects/SignUp/SignupStep1.page';
import SignupStep2Page from '../pageobjects/SignUp/SignupStep2.page';
import SignupStep3Page from '../pageobjects/SignUp/SignupStep3.page';
import StartScreen from '../pageobjects/StartScreen.page';
import { fetchOTP } from '../utils/fetchOTP';
describe('Signup Flow', () => {
describe('Step 1 - Account Information', () => {
before(async () => {
await StartScreen.openSignupScreen();
});
it('should display step 1 screen correctly', async () => {
await SignupStep1Page.screenTitle.waitForDisplayed();
await expect(await SignupStep1Page.isDisplayed()).toBe(true);
});
it('should validate name field - empty name', async () => {
await SignupStep1Page.enterName('.');
await SignupStep1Page.enterName('');
await expect(await SignupStep1Page.isEmptyNameErrorMessageDisplayed()).toBe(true);
});
it('should validate name field - name too short', async () => {
await SignupStep1Page.enterName('A');
await expect(await SignupStep1Page.isNameErrorMessageDisplayed()).toBe(true);
});
it('should validate email field - empty email', async () => {
await SignupStep1Page.enterEmail('.');
await SignupStep1Page.enterEmail('');
await expect(await SignupStep1Page.isEmptyEmailErrorMessageDisplayed()).toBe(true);
});
it('should validate email field - invalid email format', async () => {
await SignupStep1Page.enterEmail('invalid-email');
await expect(await SignupStep1Page.isEmailErrorMessageDisplayed()).toBe(true);
});
it('should validate date of birth - age under 13', async () => {
await SignupStep1Page.selectDateOfBirth(0);
await expect(await SignupStep1Page.isDobErrorMessageDisplayed()).toBe(true);
});
it('should enable next button when form is valid', async () => {
await SignupStep1Page.enterName(SignupStep1Page.testName);
await SignupStep1Page.enterEmail(SignupStep1Page.testEmail);
await SignupStep1Page.selectDateOfBirth();
await expect(await SignupStep1Page.isValidEmailMessageDisplayed()).toBe(true);
await expect(await SignupStep1Page.isNameErrorMessageDisplayed()).toBe(false);
await expect(await SignupStep1Page.isDobErrorMessageDisplayed()).toBe(false);
await expect(await SignupStep1Page.isNextButtonEnabled()).toBe(true);
});
it('should proceed to step 2 with valid form data', async () => {
await SignupStep1Page.clickNext();
await SignupStep2Page.screenTitle.waitForDisplayed();
await expect(await SignupStep2Page.isDisplayed()).toBe(true);
});
});
describe('Step 2 - OTP Verification', () => {
it('should display step 2 screen correctly', async () => {
await expect(await SignupStep2Page.isDisplayed()).toBe(true);
await expect(await SignupStep2Page.isResendCodeButtonDisplayed()).toBe(true);
});
it('should validate OTP field - empty code', async () => {
await SignupStep2Page.enterOTP('0');
await SignupStep2Page.enterOTP('');
await expect(await SignupStep2Page.isEmptyCodeErrorMessageDisplayed()).toBe(true);
});
it('should validate OTP field - code too short', async () => {
await SignupStep2Page.enterOTP('123');
await expect(await SignupStep2Page.isShortCodeErrorMessageDisplayed()).toBe(true);
});
it('should only allow numeric input in OTP field', async () => {
await SignupStep2Page.enterOTP('abc123def');
const inputValue = await SignupStep2Page.otpInput.getText();
await expect(inputValue).toEqual('123');
});
it('should limit OTP input to 6 digits', async () => {
await SignupStep2Page.enterOTP('1234567890');
const inputValue = await SignupStep2Page.otpInput.getText();
await expect(inputValue).toEqual('123456');
});
it('should handle resend OTP functionality', async () => {
await SignupStep2Page.clickResendCode();
await expect(await SignupStep2Page.isResendCodeMessageDisplayed()).toBe(true);
});
it('should proceed to step 3 with valid OTP', async () => {
const otp = await fetchOTP(SignupStep1Page.testEmail, 'registration');
await SignupStep2Page.completeStep2(otp);
await SignupStep3Page.screenTitle.waitForDisplayed();
await expect(await SignupStep3Page.isDisplayed()).toBe(true);
});
});
describe('Step 3 - Password Creation', () => {
it('should display step 3 screen correctly', async () => {
await SignupStep3Page.screenTitle.waitForDisplayed();
await expect(await SignupStep3Page.isDisplayed()).toBe(true);
});
it('should validate password field - empty password', async () => {
await SignupStep3Page.enterPassword('.');
await SignupStep3Page.enterPassword('');
await expect(await SignupStep3Page.isEmptyPasswordErrorMessageDisplayed()).toBe(true);
});
it('should validate password field - password too short', async () => {
await SignupStep3Page.enterPassword('123');
await expect(await SignupStep3Page.isShortPasswordErrorMessageDisplayed()).toBe(true);
});
it('should complete signup and navigate to onboarding screen', async () => {
await SignupStep3Page.completeStep3(SignupStep1Page.testPassword);
await OnboardingProfilePicScreen.screenTitle.waitForDisplayed();
await expect(await OnboardingProfilePicScreen.isDisplayed()).toBe(true);
});
});
describe('Edge Cases', () => {
before(async () => {
await driver.reloadSession();
await driver.pause(1500);
const scheme = 'raven';
const packageName = 'space.cmp27.raven';
const metroUrl = 'http://10.0.2.2:8081';
const deepLinkUrl = `${scheme}://expo-development-client/?url=${encodeURIComponent(metroUrl)}`;
await driver.execute('mobile: deepLink', {
url: deepLinkUrl,
package: packageName,
});
try {
const closeButton = await $('~Close');
await closeButton.waitForDisplayed();
await closeButton.click();
await driver.pause(3000);
} catch {
// It didn't appear, carry on.
}
await StartScreen.welcomeText.waitForDisplayed();
await StartScreen.openSignupScreen();
});
it('should show an error when email already exists', async () => {
await SignupStep1Page.enterName(SignupStep1Page.testName);
await SignupStep1Page.enterEmail(SignupStep1Page.testEmail);
await driver.pause(1500);
await expect(await SignupStep1Page.isEmailExistsErrorMessageDisplayed()).toBe(true);
});
it('should preserve form data when navigating back', async () => {
await SignupStep1Page.completeStep1(
SignupStep1Page.generateTestName(),
SignupStep1Page.generateTestEmail()
);
await SignupStep2Page.screenTitle.waitForDisplayed();
await SignupStep2Page.goBack();
await SignupStep1Page.screenTitle.waitForDisplayed();
await expect(await SignupStep1Page.emailInput.getText()).toEqual(SignupStep1Page.testEmail);
});
it('should handle invalid OTP attempts', async () => {
await SignupStep1Page.clickNext();
await SignupStep2Page.screenTitle.waitForDisplayed();
const correctOTP = await fetchOTP(SignupStep1Page.testEmail, 'registration');
const wrongOTP = correctOTP.slice(0, 5) + (correctOTP[5] === '1' ? '2' : '1');
await SignupStep2Page.enterOTP(wrongOTP);
await SignupStep2Page.clickNext();
await expect(await SignupStep2Page.isInvalidCodeErrorMessageDisplayed()).toBe(true);
});
it('should handle extremely long names', async () => {
await SignupStep2Page.goBack();
await SignupStep1Page.screenTitle.waitForDisplayed();
await SignupStep1Page.enterName('a'.repeat(101));
await expect(await SignupStep1Page.isLongNameErrorMessageDisplayed()).toBe(true);
});
it('should handle extremely long emails', async () => {
await SignupStep1Page.enterEmail('a'.repeat(101) + '@example.com');
await expect(await SignupStep1Page.isLongEmailErrorMessageDisplayed()).toBe(true);
});
it('should handle special characters in name', async () => {
const specialName = "#José María-O'Connor";
await SignupStep1Page.enterName(specialName);
await expect(await SignupStep1Page.nameInput.getText()).toEqual(specialName);
await expect(await SignupStep1Page.isNameErrorMessageDisplayed()).toBe(false);
});
});
});