forked from wevote/WebApp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ReadyPageMobileBrowser.js
284 lines (260 loc) · 10.2 KB
/
ReadyPageMobileBrowser.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
import { driver, expect } from '@wdio/globals';
import ReadyPage from '../page_objects/ready.page';
import webAppConfig from '../../../src/js/config';
const waitTime = 10000;
/* eslint-disable no-undef */
// This eslint-disable turns off warnings for describe() and it()
// We don't need those warnings, because describe() and it() are available at runtime
// https://webdriver.io/docs/pageobjects
describe('ReadyPage', () => {
// Ready_001 and Ready_003
it('verifyElectionCountDownRedirect and verifyViewUpcomingBallotRedirect', async () => {
await ReadyPage.load();
await driver.pause(waitTime);
await driver.execute(() => {
const electionCountDownTitle = document.querySelector('#electionCountDownTitle');
electionCountDownTitle.click();
});
await driver.pause(waitTime);
await driver.waitUntil(async () => {
const currentUrl = await driver.getUrl();
return currentUrl.includes('ballot');
}, {
timeout: 10000,
timeoutMsg: 'Expected URL to contain "ballot" not found, timeout after 10000ms',
});
await driver.switchWindow('Ballot - WeVote');
await driver.pause(waitTime);
await expect(driver).not.toHaveUrl(expect.stringContaining('ready'));
console.log('Verified verifyElectionCountDownRedirect');
await ReadyPage.wevoteLogo.click();
await ReadyPage.viewUpcomingBallotButton.click();
await expect(driver).not.toHaveUrl(expect.stringContaining('ready'));
});
// // Ready_002
// // it('updateBallotAddress', async () => {
// // await ReadyPage.load();
// // await ReadyPage.updateBallotAddress('New York, NY, USA');
// // await expect(ReadyPage.ballotForAddress).toHaveText('New York, NY, USA');
// // });
// // Ready_003 - merged with ready_001
// // it('verifyViewUpcomingBallotRedirect', async () => {
// // await ReadyPage.load();
// // await ReadyPage.viewUpcomingBallotButton.findAndClick();
// // await driver.pause(waitTime);
// // await expect(driver).not.toHaveUrl(expect.stringContaining('ready'));
// // });
// Ready_004
it('toggleIssueFollowing', async () => {
await ReadyPage.load();
await ReadyPage.followIssueButtons[0].click();
await expect(ReadyPage.toggleFollowMenuButtons).toBeElementsArrayOfSize(1);
await driver.pause(waitTime);
await ReadyPage.toggleFollowMenuButtons[0].click();
await ReadyPage.unfollowIssueButtons[0].click();
await driver.pause(waitTime);
await expect(ReadyPage.toggleFollowMenuButtons).toBeElementsArrayOfSize(0);
});
// Ready_005
it('unfurlIssues', async () => {
await ReadyPage.load();
await driver.pause(waitTime);
await expect(ReadyPage.followIssueButtons).toBeElementsArrayOfSize(6);
await driver.execute(() => {
const showMoreIssues = document.querySelector('[id*="showMoreReadyPageValuesList"]');
showMoreIssues.click();
});
await driver.pause(waitTime);
await expect(ReadyPage.followIssueButtons).toBeElementsArrayOfSize({ gte: 6 });
});
// Ready_006
it('toggleIntroduction', async () => {
await ReadyPage.load();
await driver.execute(() => {
const showMore = document.querySelector('#toggleContentButton-showMoreReadyIntroductionCompressed');
showMore.click();
});
await driver.pause(waitTime);
await expect(ReadyPage.introductionStepText).toBeElementsArrayOfSize(3);
});
// Ready_007
it('toggleFinePrint', async () => {
await ReadyPage.load();
await driver.execute(() => {
const showMore = document.querySelector('#toggleContentButton-showMoreReadyFinePrintCompressed');
showMore.click();
});
await driver.pause(waitTime);
await expect(ReadyPage.finePrintStepText).toBeElementsArrayOfSize(4);
});
// Ready_009 and Ready_016
it('verifyPrivacyLinkRedirected', async () => {
await ReadyPage.load();
await driver.pause(waitTime);
await driver.execute(() => {
const privacyLink = document.querySelector('#footerLinkPrivacy');
privacyLink.click();
});
await driver.pause(waitTime);
await expect(driver).toHaveUrl(expect.stringContaining('privacy'));
console.log('Verified Privacy link on the ready page');
await ReadyPage.wevoteLogoRedirectReadyPage.click();
await driver.pause(waitTime);
await driver.execute(() => {
const termsLink = document.querySelector('#footerLinkTermsOfUse');
termsLink.click();
});
await driver.pause(waitTime);
const url = await driver.getUrl();
await expect(url).toContain('terms');
console.log('Verified Terms link on the ready page');
});
// Ready_010 and Ready_011
it('verifyHowItWorksModalWindowOpen and verifyHowItWorksModalWindowClosed', async () => {
await ReadyPage.load();
await driver.pause(waitTime);
await driver.execute(() => {
const howItWorksLink = document.querySelector('#footerLinkHowItWorks');
howItWorksLink.click();
});
await driver.pause(waitTime);
await expect(ReadyPage.howItWorksTitle).toHaveText('1. Choose your interests');
await ReadyPage.closeHowItWorksModalWindow();
await driver.pause();
await expect(ReadyPage.elementHowItWorksWindow).not.toBeDisplayed();
});
// // Ready_011 merged with Ready_010
// // it('verifyHowItWorksModalWindowClosed', async () => {
// // await ReadyPage.load();
// // await driver.pause(waitTime);
// // await ReadyPage.clickHowItWorksLink();
// // await driver.pause(waitTime);
// // await ReadyPage.howItWorksTitle.isDisplayed();
// // await ReadyPage.closeHowItWorksModalWindow();
// // await driver.pause();
// // await expect(ReadyPage.elementHowItWorksWindow).not.toBeDisplayed();
// // });
// // Ready_012 this case can be deprecated as it is covered as part of Ready_013
// // it('verifyHowItWorksModalWindowNextButton', async () => {
// // await ReadyPage.load();
// // await driver.pause(5000);
// // await ReadyPage.clickHowItWorksLink();
// // await driver.pause(5000);
// // const expectedResult = await ReadyPage.checkTitleOfHowItWorksWindow();
// // await expect(ReadyPage.howItWorksTitle).toHaveText(expectedResult);
// // });
// Ready_013
it('verifyHowItWorksModalWindowNextGetStartedButton', async () => {
await ReadyPage.load();
await driver.pause(waitTime);
await driver.execute(() => {
const howItWorksLink = document.querySelector('#footerLinkHowItWorks');
howItWorksLink.click();
});
await driver.pause(waitTime);
await driver.execute(() => {
const nextButton = document.querySelector('[id*="annotatedSlideShowStep"]');
nextButton.click();
nextButton.click();
nextButton.click();
nextButton.click();
});
await driver.pause(waitTime);
await ReadyPage.clickGetStartedButton();
await driver.pause(waitTime);
await expect(ReadyPage.getTitleSignUpPopUp).toHaveText('Sign In or Join');
});
// Ready_014
it('verifyHowItWorksModalWindowBackButton', async () => {
await ReadyPage.load();
await driver.pause(waitTime);
await driver.execute(() => {
const howItWorksLink = document.querySelector('#footerLinkHowItWorks');
howItWorksLink.click();
});
await driver.pause(waitTime);
const expectedResult = await ReadyPage.getTitleOfHowItWorksWindowAfterBackButton();
await expect(ReadyPage.howItWorksTitle).toHaveText(expectedResult);
});
// Ready_015
it('verifyHelpLink', async () => {
await ReadyPage.load();
await driver.pause(waitTime);
await driver.execute(() => {
const helpLink = document.querySelector('#footerLinkWeVoteHelp');
helpLink.click();
});
await driver.pause(waitTime);
await driver.switchWindow('https://help.wevote.us/hc/en-us');
await driver.pause(waitTime);
const url = await driver.getUrl();
await expect(url).toContain('help');
});
// // Ready_016 merged with Ready_009
// it('verifyTermsLink', async () => {
// await ReadyPage.load();
// await driver.pause(waitTime);
// await driver.execute(() => {
// const helpLink = document.querySelector('#footerLinkTermsOfUse');
// helpLink.click();
// });
// await driver.pause(waitTime);
// await driver.switchWindow(`${webAppConfig.WE_VOTE_URL_PROTOCOL + webAppConfig.WE_VOTE_HOSTNAME}/more/terms`);
// await driver.pause(waitTime);
// const url = await driver.getUrl();
// await expect(url).toContain('terms');
// });
// Ready_017
it('verifyTeamLink', async () => {
await ReadyPage.load();
await driver.pause(waitTime);
await driver.execute(() => {
const teamLink = document.querySelector('#footerLinkTeam');
teamLink.click();
});
await driver.pause(waitTime);
await driver.switchWindow(`${webAppConfig.WE_VOTE_URL_PROTOCOL + webAppConfig.WE_VOTE_HOSTNAME}/more/about`);
await driver.pause(waitTime);
const url = await driver.getUrl();
await expect(url).toContain('about');
});
// Ready_018
it('verifyCreditsAndThanksLink', async () => {
await ReadyPage.load();
await driver.pause(waitTime);
await driver.execute(() => {
const creditsLink = document.querySelector('#footerLinkCredits');
creditsLink.click();
}); await driver.pause(waitTime);
await driver.switchWindow(`${webAppConfig.WE_VOTE_URL_PROTOCOL + webAppConfig.WE_VOTE_HOSTNAME}/more/credits`);
await driver.pause(waitTime);
const url = await driver.getUrl();
await expect(url).toContain('credits');
});
// Ready_019
it('verifyVolunteeringOpportunitiesLink', async () => {
await ReadyPage.load();
await driver.pause(waitTime);
await driver.execute(() => {
const volunteerLink = document.querySelector('#footerLinkVolunteer');
volunteerLink.click();
});
await driver.pause(waitTime);
await driver.switchWindow('https://wevote.applytojob.com/apply');
await driver.pause(waitTime);
const url = await driver.getUrl();
await expect(url).toContain('apply');
});
// Ready_020
it('verifyDonateLinkRedirected', async () => {
await ReadyPage.load();
await driver.pause(waitTime);
await driver.execute(() => {
const donateLink = document.querySelector('#footerMainLinkDonate');
donateLink.click();
});
await driver.pause(waitTime);
const url = await driver.getUrl();
await expect(url).toContain('donate');
});
});