-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathr2.js
368 lines (344 loc) · 12.2 KB
/
r2.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
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
/* global browser, by, expectedUrl, timeout, element, expect, protractor */
/**
* @file
* Steps
*
* Provide step functions for functional testing.
* This file is created and modified automatically by the Gherkin compiler.
*
* Note, therefore, that most of this file might be changed automatically
* when you run the compiler again. This @file header will not be affected,
* but all of the function header comments are (re)generated automatically.
*
* Be assured that no functions will be deleted and the compiler will
* not alter code within a function unless you make it look like a function header.
*
* You may also add statements just below this header.
*/
exports.v = []; // miscellaneous data
exports.v.parse = '';
var wait = 20000;
var count = 0;
var del = .5;
var EC = protractor.ExpectedConditions;
/**
* Add additional setup for any or all features or tests
*/
exports.extraSetup = function () {
var createdItemUrl;
var doneOnce;
if (doneOnce === undefined) {
doneOnce = true;
browser.manage().timeouts().pageLoadTimeout(40000);
browser.manage().timeouts().implicitlyWait(25000);
browser.driver.get("http://localhost:8100", 500);
browser.waitForAngular();
browser.getCurrentUrl().then(function (url) {
createdItemUrl = url;
});
browser.getSession().then(function (session) {
console.log('SessionID=' + session.getId());
});
browser.driver.get("http://localhost:8100/#/app/login", 500);
}
;
var waitForElement = function (selector, waitFor) {
waitFor = waitFor || 50000;
browser.driver.manage().timeouts().implicitlyWait(waitFor);
browser.driver.findElement(by.css(selector));
browser.driver.manage().timeouts().implicitlyWait(0);
};
/**
* we scan personal QR (ARG)
*
* in: MAKE ParseQRCode WeScanAValidOldPersonalCard
* MAKE ParseQRCode WeScanAValidPersonalCard
*/
exports.weScanPersonalQR = function (qr) {
exports.v['qr'] = qr;
var parts = qr.split(/[/\\.-]/);
console.log(parts[5].length, qr.indexOf('HTTP://'));
browser.wait(browser.executeScript("document.getElementById('scan').click();"), wait)
.then(function () {
if (parts[5].length <= 4) {
browser.wait(element(by.id('oldURL')).click(), wait);
} else if (qr.indexOf('HTTP://') !== -1) {
browser.wait(element(by.id('newURL')).click(), wait);
}
})
.then(function () {
console.log("document.getElementById('" + qr + "').click();");
element(by.id("customQR")).sendKeys(qr);
var link = element(by.id("accountInfoButton"));
var isClickable = EC.elementToBeClickable(link);
browser.wait(isClickable, wait)
.then(link.click());
console.log('weScanQR');
})
.then(browser.executeScript('return window.find("isCompany:true");'))
.then(function () {
browser.wait(browser.driver.get("https://otherrealm.org"), wait)
.then(browser.wait(browser.driver.get("http://localhost:8100/#/app/home"), wait))
.then(browser.wait(browser.executeScript("document.getElementById('scan').click();"), wait))
.then(function () {
element(by.id("customQR")).sendKeys('H6VM010WeHlioM5JZv1O9G');
var link = element(by.id("demoAccountLogin"));
var isClickable = EC.elementToBeClickable(link);
browser.wait(isClickable, wait)
.then(link.click());
}).then(browser.wait(browser.executeScript('window.scrollTo(0,document.body.scrollHeight)')
.then(function () {
var button = element(by.id('scan'));
var isClickable = EC.elementToBeClickable(button);
browser.driver.wait(isClickable, wait); //wait for an element to become clickable
browser.driver.wait(button.click(), wait);
}), wait))
.then(function () {
element(by.id("customQR")).sendKeys(qr);
var link = element(by.id("accountInfoButton"));
var isClickable = EC.elementToBeClickable(link);
browser.wait(isClickable, wait)
.then(link.click());
});
return expect(browser.wait(EC.textToBePresentInElement(element(by.id("url")), qr), wait)).toBe(true);
});
};
/**
* we scan company QR (ARG)
*
* in: MAKE ParseQRCode WeScanAValidOldCompanyCard
* MAKE ParseQRCode WeScanAValidCompanyCard
*/
exports.weScanCompanyQR = function (qr) {
exports.v['qr'] = qr;
var parts = qr.split(/[/\\.-]/);
console.log(parts[5].length, qr.indexOf('HTTP://'));
browser.wait(browser.executeScript("document.getElementById('scan').click();"), wait)
.then(function () {
if (parts[5].length <= 4) {
browser.wait(element(by.id('oldURL')).click(), wait);
} else if (qr.indexOf('HTTP://') !== -1) {
browser.wait(element(by.id('newURL')).click(), wait);
}
})
.then(function () {
console.log("document.getElementById('" + qr + "').click();");
element(by.id("customQR")).sendKeys(qr);
var link = element(by.id("accountInfoButton"));
var isClickable = EC.elementToBeClickable(link);
browser.wait(isClickable, wait)
.then(link.click());
console.log('weScanQR');
})
.then(browser.executeScript('return window.find("isCompany:true");'))
.then(function () {
return expect(browser.wait(EC.textToBePresentInElement(element(by.id("url")), qr), wait)).toBe(true);
});
};
/**
* account is personal
*
* in: TEST ParseQRCode WeScanAValidOldPersonalCard
* TEST ParseQRCode WeScanAValidPersonalCard
*/
exports.accountIsPersonal = function () {
return expect(browser.wait(EC.textToBePresentInElement(element(by.id("isPersonal")), 'true'), wait)).toBe(true);
};
/**
* account is company
*
* in: TEST ParseQRCode WeScanAValidOldCompanyCard
* TEST ParseQRCode WeScanAValidCompanyCard
*/
exports.accountIsCompany = function () {
return expect(browser.wait(EC.textToBePresentInElement(element(by.id("isCompany")), 'true'), wait)).toBe(true);
};
/**
* account ID is (ARG)
*
* in: TEST ParseQRCode WeScanAValidOldPersonalCard
* TEST ParseQRCode WeScanAValidOldCompanyCard
* TEST ParseQRCode WeScanAValidPersonalCard
* TEST ParseQRCode WeScanAValidCompanyCard
*/
exports.accountIDIs = function (id) {
return expect(browser.driver.wait(EC.textToBePresentInElement(element(by.id("memberId")), id), wait)).toBe(true);
};
/**
* security code is (ARG)
*
* in: TEST ParseQRCode WeScanAValidOldPersonalCard
* TEST ParseQRCode WeScanAValidOldCompanyCard
* TEST ParseQRCode WeScanAValidPersonalCard
* TEST ParseQRCode WeScanAValidCompanyCard
*/
exports.securityCodeIs = function (securityCode) {
return expect(browser.driver.wait(EC.textToBePresentInElement(element(by.id("unencryptedCode")), securityCode), wait)).toBe(true);
};
/**
* show page (ARG)
*
* in: MAKE Transact Setup
* TEST Transact WeIdentifyAndChargeACustomer
*/
exports.showPage = function (p) {
if (count++ === 0) {
browser.executeScript('window.scrollTo(0,document.body.scrollHeight)').then(function () {
var button = element(by.id('scan'));
var isClickable = EC.elementToBeClickable(button);
browser.driver.wait(isClickable, wait); //wait for an element to become clickable
button.click();
});
element(by.id("customQR")).sendKeys('H6VM010WeHlioM5JZv1O9G');
var exp;
var link = element(by.id("demoAccountLogin"));
var isClickable = EC.elementToBeClickable(link);
browser.wait(isClickable, wait)
.then(link.click());
}
return expect(browser.wait(EC.urlContains(p.toLowerCase()), wait)).toBe(true);
};
/**
* show button (ARG)
*
* in: TEST Transact Setup
* TEST Transact WeIdentifyAndChargeACustomer
*/
exports.showButton = function (arg1) {
var button = expect(element(by.cssContainingText('.button', arg1)).getText()).toEqual(arg1);
return browser.wait(button, wait);
};
/**
* show back button
*
* in: TEST Transact WeIdentifyAndChargeACustomer
*/
exports.showBackButton = function () {
return browser.wait(expect(browser.executeScript("return document.getElementById('testing').innerHTML")).toBe('Back'));
};
/**
* button (ARG) pressed
*
* in: MAKE Transact WeIdentifyAndChargeACustomer
*/
exports.buttonPressed = function (arg1) {
var button = element(by.cssContainingText('.button', arg1.toString())).getText();
var link = element(by.cssContainingText('.button', arg1.toString())).getText();
var isClickable = EC.or(EC.elementToBeClickable(link), EC.elementToBeClickable(button));
browser.wait(isClickable, wait);
link.click();
return isClickable;
};
/**
* show scanner
*
* in: TEST Transact WeIdentifyAndChargeACustomer
*/
exports.showScanner = function () {
return expect(browser.driver.wait(EC.or(EC.urlContains('demo-people'), EC.urlContains('qr')), wait)).toBe(true);
};
/**
* scanner sees QR (ARG)
*
* in: MAKE Transact WeIdentifyAndChargeACustomer
*/
exports.scannerSeesQR = function (arg1) {
var QR = element(by.id("customQR"));
var infoB = element(by.id('accountInfoButton'));
var link = element(by.id("demoAccountLogin"));
var isClickable1 = EC.elementToBeClickable(infoB);
var isClickable2 = EC.elementToBeClickable(link);
console.log(arg1);
var url;
browser.wait(QR.sendKeys(arg1), wait)
.then(browser.wait(isClickable1, wait))
.then(infoB.click())
.then(function () {
return browser.wait(url = element(by.binding("customPerson.accountInfo.url")), wait);
}).then(QR.sendKeys(arg1))
.then(browser.wait(isClickable2, wait))
.then(link.click())
.then(function () {
return browser.wait(expect(url.getText()).toEqual('url:' + arg1), wait);
});
};
/**
* show photo of member (ARG)
*
* in: TEST Transact WeIdentifyAndChargeACustomer
*/
exports.showPhotoOfMember = function (arg1) {
return expect(browser.driver.wait(element(by.id('ItemPreview')).isPresent(), wait)).toBe(true);
};
/**
* show text (ARG)
*
* in: TEST Transact WeIdentifyAndChargeACustomer
*/
exports.showText = function (arg1) {
return expect(browser.wait(EC.textToBePresentInElement(element(by.id('customerPage')), arg1), wait)).toBe(true);
};
/**
* show number keypad
*
* in: TEST Transact WeIdentifyAndChargeACustomer
*/
exports.showNumberKeypad = function () {
return expect(browser.driver.wait(element(by.id('keypad')).isPresent(), wait)).toBe(true);
};
/**
* show amount (ARG)
*
* in: TEST Transact WeIdentifyAndChargeACustomer
*/
exports.showAmount = function (arg1) {
return expect(browser.driver.wait(element(by.id('displayAmount')).getText(), wait)).toEqual(arg1.toString());
};
/**
* show dropdown with (ARG) selected
*
* in: TEST Transact WeIdentifyAndChargeACustomer
*/
exports.showDropdownWithSelected = function (arg1) {
return expect(browser.driver.wait(element(by.options('c | translate for c in categories')).getText(), wait)).toEqual(arg1.toString());
};
/**
* show message (ARG) titled (ARG)
*
* in: TEST Transact WeIdentifyAndChargeACustomer
*/
exports.showMessageTitled = function (arg1, arg2, arg3) {
var note;
var headding;
var backHome;
browser.ignoreSynchronization = true;
browser.wait(EC.urlContains('http://localhost:8100/#/app/transaction-result/success/'), wait)
.then(function () {
browser.wait((note = element(by.id('note'))), 50000)
.then(function () {
browser.wait((headding = element(by.id('headingSuccess'))), 50000)
.then(function () {
browser.wait((backHome = element(by.id('backHome'))), 50000)
.then(function () {
return browser.wait(EC.and(EC.textToBePresentInElement(note, arg2), EC.textToBePresentInElement(headding, arg3), EC.textToBePresentInElement(backHome, arg1)), 50000);
});
});
});
});
return true;
};
/**
* message button (ARG) pressed
*
* in:
*/
exports.messageButtonPressed = function (arg1) {
browser.ignoreSynchronization = true;
var button = element(by.id('backHome'));
var isClickable = EC.elementToBeClickable(button);
browser.wait(isClickable, wait)
.then(browser.wait(browser.executeScript("arguments[0].click();", button.getWebElement()), wait))
.then(function () {
return isClickable;
});
};