forked from wevote/WebApp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignedin.page.js
338 lines (280 loc) · 11.1 KB
/
signedin.page.js
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
import { $, $$, expect, driver } from '@wdio/globals';
import Page from './page';
const waitTime = 3000;
class SignedIn extends Page {
get signInButton() {
return $('//*[contains(@id, "signIn")]');
}
get signInWithTwitterButton() {
return $('//*[contains(@id, "twitterSignIn-splitIconButton")]');
}
get signInWithAppleButton() {
return $('//*[contains(@id, "appleSignInText")]');
}
get signInWithEmailOption() {
return $('//*[contains(@id, "enterVoterEmailAddress-label") and contains(@id, "enterVoterEmailAddress")]');
}
get signInWithPhoneNumberOption() {
return $('//*[contains(@id, "enterVoterPhone-label") and contains(@id, "enterVoterPhone")]');
}
get deleteIconAfterUploadingPhoto() {
return $('[data-testid = "DeleteIcon"]');
}
get firstNameInput() {
return $('//*[contains(@id,"first-name-domainDesktop")]');
}
get lastNameInput() {
return $('//*[contains(@id,"last-name-domainDesktop")]');
}
get organizationNameInput() {
return $('//*[contains(@id,"organization-name-domainDesktop")]');
}
get websiteInput() {
return $('//*[contains(@id,"organizationWebsiteTextArea-domainDesktop-label")]');
}
get descriptionInput() {
return $('//*[contains(@id,"organizationDescriptionTextArea-domainDesktop")]');
}
get typeOfProfile() {
return $('//*[contains(@id,"typeOfProfileText")]');
}
// async clickOnDragDropBoxToUploadPhoto() { //photo upload on hold for now
// //return $('[data-testid = "AccountCircleIcon"]');
// const localFilePath = '/Users/ayusheedash/MyProjects/wevote_profile_image.jpg';
// const remoteFilePath = await driver.uploadFile(localFilePath);
// const fileInput = await $('[data-testid = "AccountCircleIcon"]');
// await fileInput.setValue(remoteFilePath);
// }
async enterPhoneNumberInPhoneNumberInput() {
await $('#enterVoterPhone').setValue("808-935-8555");
}
async clickOnSendCodeOption() {
await $('#desktopSmsSendCode').click();
}
get bellIconNotificationsSettingsText() {
return $('//*[contains(@id, "notificationsHeader") or contains(@id, "noActivities")]');
}
get notificationTitleText() {
return $('//*[contains(@id, "notificationTitleText")]');
}
get notificationBellIcon() {
return $('[data-testid = "NotificationsIcon"]');
}
get notificationMailIcon() {
return $('[data-testid = "MailOutlineIcon"]');
}
get addEmailAddressLink() {
return $('//*[contains(@id, "addEmailLink")]');
}
get howItWorksTitleText() {
return $('//*[contains(@id, "howWeVoteWorksTitleText")]');
}
get sideBarText() {
return $('//*[contains(@id, "profileSideBarText")]');
}
async enterVerificationCode() {
const verificationCode = '123456';
await $('#digit1').setValue(verificationCode[0]);
await $('#digit2').setValue(verificationCode[1]);
await $('#digit3').setValue(verificationCode[2]);
await $('#digit4').setValue(verificationCode[3]);
await $('#digit5').setValue(verificationCode[4]);
await $('#digit6').setValue(verificationCode[5]);
}
async clickOnVerifyButtonForCodeVerification() {
await $('#emailVerifyButton').click();
}
async clickOnProfilePhotoPlaceholder() {
await $('#profileAvatarHeaderBar').click();
}
async clickOnTermsOfServiceFooterLink() {
await $('#openTermsOfService').click();
}
async clickOnPrivacyPolicyFooterLink() {
await $('#openPrivacyPolicy').click();
}
async clickOnFAQLinkInNameAndPhoto() {
await $('#profileFAQ').click();
}
async clickOnBellIconForNotifications() {
await $('#headerNotificationMenuIcon').click();
}
async clickOnSecurityAndSignIn() {
await $('#securityAndSignIn').click();
}
async clickOnRemovePhoto() {
await $('//*[contains(@id, "removePhotoLink")]').click();
}
async clickOnSavePhoto() {
await $('#saveEditYourPhotoBottom').click();
}
async enterAndRemoveFirstName() {
const elem = await $('//input[@name="firstName"]');
await elem.click();
console.log(await elem.getValue());
await driver.execute((elem) => {
elem.value = null;
}, elem);
driver.pause(waitTime);
console.log("after Deletion",await elem.getValue());
await elem.setValue('Automated');
const entered = await elem.getValue();
driver.pause(waitTime);
await expect(entered).toBe('Automated');
console.log("Entered first name");
}
async enterAndRemoveLastName() {
const elem = await $('//input[@name="lastName"]');
await elem.click();
console.log(await elem.getValue());
await driver.execute((elem) => {
elem.value = null;
}, elem);
driver.pause(waitTime);
console.log("after deletion",await elem.getValue());
await elem.setValue('Test');
const entered = await elem.getValue();
driver.pause(waitTime);
await expect(entered).toBe('Test');
console.log("Entered Last name");
}
async enterAndRemoveOrganisationWebsite() {
const elem = await $('//input[@name="organizationWebsite"]');
await elem.scrollIntoView();
await elem.click();
console.log(await elem.getValue());
await driver.execute((elem) => {
elem.value = null;
}, elem);
driver.pause(waitTime);
console.log("after deletion",await elem.getValue());
await elem.setValue('automated');
const entered = await elem.getValue();
driver.pause(waitTime);
await expect(entered).toBe('automated');
console.log("Entered Organisation Website");
}
async enterAndRemoveOrganisationDescription() {
const elem = await $('//textarea[@name="organizationDescription"]');
await elem.scrollIntoView({block:'center'});
await elem.click();
console.log(await elem.getValue());
await driver.execute((elem) => {
elem.value = null;
}, elem);
driver.pause(waitTime);
console.log("after deletion",await elem.getValue());
await elem.setValue('automated');
driver.pause(waitTime);
const entered = await elem.getValue();
await expect(entered).toBe('automated');
console.log("Entered Organisation Description");
}
async enterAndRemoveOrganisationName() {
const elem = await $('//input[@name="organizationName"]');
await elem.scrollIntoView({block:'center'});
await elem.click();
console.log(await elem.getValue());
await driver.execute((elem) => {
elem.value = null;
}, elem);
driver.pause(waitTime);
console.log("after deletion",await elem.getValue());
await elem.setValue('automated');
driver.pause(waitTime);
const entered = await elem.getValue();
await expect(entered).toBe('automated');
console.log("Entered Organisation Name");
}
async clickOnEachOptionInTypeOfProfile() {
const ids = ['organizationTypeIdC3', 'organizationTypeIdC4', 'organizationTypeIdPAC', 'organizationTypeIdNonprofit',
'organizationTypeIdGroup', 'organizationTypeIdPolitician', 'organizationTypeIdNews', 'organizationTypeIdCompany', 'organizationTypeIdUnknown',
'organizationTypeIdIndividual'
];
const textProfileTypes = ['Nonprofit 501(c)(3)', 'Nonprofit 501(c)(4)', 'Political Action Committee', 'Nonprofit (Type Not Specified)', 'Group or Club (10+ people)',
'Politician', 'News Organization', 'Company', 'Not specified (Individual vs. Organization)', 'Individual'
];
for (let i = 0; i < ids.length; i++) {
const id = ids[i];
const text = textProfileTypes[i];
await $('#edit-domainDesktop').click();
await $(`#${id}`).click();
const textToBeDisplayed = await $(`//*[text()="${text}"]`);
await expect(textToBeDisplayed).toBeDisplayed();
}
}
async clickOnYourPrivacyAndData() {
await $('#yourData').click();
}
async clickOnImportContactsLink() {
await $('#importContactsLink').click();
}
async clickOnDeleteYourAccountLink() {
await $('#deleteAllAccountDataLink').click();
}
async clickOnNotifications() {
await $('#settingsNotifications').click();
}
async clickOnDiscuss() {
await $('#settingsDiscuss').click();
}
async verifyAlreadyAddedEmailIdIfPresent() {
if (await $('//*[contains(@id, "emailVerifyTitle")]').isDisplayed()) {
const sendVerificationLink = await $('//*[contains(@id, "sendVerificationCodeAgain"]');
const trashIcon = await $('[data-testid="DeleteIcon"]');
const emailId = await $('//*[text()="[email protected]"]');
expect (sendVerificationLink).toBeDisplayed();
expect (trashIcon).toBeDisplayed();
expect (emailId).toBeDisplayed();
} else {
await this.addEmailAddressLink;
}
}
async clickOnHowItWorksLink() {
await $('#footerLinkHowItWorks').click();
}
async clickOnAboutAndFAQLink() {
await $('//*[contains(@id, "footerLinkAbout")]').click();
}
async clickOnHelpLink() {
await $('#footerLinkWeVoteHelp').click();
}
async clickOnPrivacyLink() {
await $('#footerLinkPrivacy').click();
}
async clickOnTermsLink() {
await $('#footerLinkTerms').click();
}
async clickOnTeamLink() {
await $('#footerLinkTeam').click();
}
async clickOnCreditAndThanksLink() {
await $('#footerLinkCredit').click();
}
async closeTheHowItWorksDialogBox() {
await $('[data-testid="CloseIcon"]').click();
}
async clickOnSignOutFromSideBar() {
await $('#signOut_Settings').click();
}
async clickOnSignOutFromSecuritySignIn() {
await $('#signOut_securitySignIn').click();
}
async privacyDataTopics() {
await expect($('//*[contains(@id, "yourAddressBookText")]')).toBeDisplayed();
await expect($('//*[contains(@id, "deleteAccountText")]')).toBeDisplayed();
}
async notificationTypes() {
await expect($('//*[contains(@id, "notificationTitleText")]')).toBeDisplayed();
await expect($('//*[contains(@id, "newFriendRequest_notification")]')).toBeDisplayed();
await expect($('//*[contains(@id, "friendsOpinion_yourBallot_notification")]')).toBeDisplayed();
await expect($('//*[contains(@id, "friendsOpinion_allRegions_notification")]')).toBeDisplayed();
await expect($('//*[contains(@id, "friendsActivity_notification")]')).toBeDisplayed();
await expect($('//*[contains(@id, "weVote_newsletter_notification")]')).toBeDisplayed();
}
async deleteAccountOptions() {
await $('//*[contains(@id, "deleteAllAccountDataButton")]');
await $('//*[contains(@id, "deleteAllAccountDataCancelButton")]');
}
}
export default new SignedIn();