-
Notifications
You must be signed in to change notification settings - Fork 10
/
includes.js
90 lines (73 loc) · 2.49 KB
/
includes.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
//This file has utility methods for the CasperJS tests in the test/ directory
errorCount = 0;
//This is designed to allow a test to logout
//only works with Phantom 1.x apparently, 2.x stops on first error
//casper.options.exitOnError = false;
siteName = 'Union Capital';
homeURL = "http://localhost:3000/login";
casper.options.logLevel = "debug";
casper.test.on('fail', function() {
if (errorCount ===0)
casper.capture('screenshots/fail.png');
errorCount++;
});
user = "[email protected]";
newPassword = "duncan";
parterAdmin = '[email protected]';
partnerAdminPassword = 'admin';
superAdmin = "[email protected]";
superAdminPassword = "admin";
newPartnerEvent = 'Health Clinic';
newPartnerEventDesc = 'A clinic on preventative care for KIPP Academy members';
newPartnerAddress = '75 Northern Ave, Boston, MA 02210';
casper.loginAsUser = function loginAsUser() {
this.waitForSelector("#loginSubmit", function() {
this.sendKeys("#userEmail", user);
this.sendKeys("#userPassword", newPassword);
this.click("#loginSubmit");
});
};
casper.loginAsPartnerAdmin = function loginAsPartnerAdmin() {
this.waitForSelector("#loginSubmit", function() {
this.sendKeys("#userEmail", parterAdmin);
this.sendKeys("#userPassword", partnerAdminPassword);
this.click("#loginSubmit");
});
};
casper.loginAsSuperAdmin = function loginAsSuperAdmin() {
this.waitForSelector("#loginSubmit", function() {
this.sendKeys("#userEmail", superAdmin);
this.sendKeys("#userPassword", superAdminPassword);
this.click("#loginSubmit");
});
};
casper.logout = function logout(test) {
casper.then(function() {
this.click("#login-dropdown-list");
});
casper.waitForSelector("#login-buttons-logout", function() {
this.click("#login-buttons-logout");
});
casper.waitWhileSelector("#login-buttons-logout", function() {
test.assertExists("#loginSubmit");
});
};
/*
addFakeGeolocation = function(self, latitude, longitude) {
self.evaluate(function() {
window.navigator.geolocation = function() {
var pub = {};
var current_pos = {
coords: {
latitude: window.__casper_params__.latitude,
longitude: window.__casper_params__.longitude
}
};
pub.getCurrentPosition = function(locationCallback,errorCallback) {
locationCallback(current_pos);
};
return pub;
}();
}, { latitude: latitude, longitude: longitude });
};
*/