-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmocha_plugin.js
More file actions
executable file
·169 lines (149 loc) · 7.13 KB
/
mocha_plugin.js
File metadata and controls
executable file
·169 lines (149 loc) · 7.13 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
/*
mocha -R spec mocha_plugin.js --server=
*/
/*Set Global Variables */
var url,server,browser,os,dev,browserVersion,username,password=null;
/*Get Required Libs */
var assert = require('assert'),
fs = require('fs'),
expect = require('chai').expect,
plugin = require('plugin.js'); //node_modules/plugin.js
var driver;
webdriver.WebDriver.prototype.saveScreenshot = function(filename) {
return driver.takeScreenshot().then(function(data) {
fs.writeFile(filename, data.replace(/^data:image\/png;base64,/,''), 'base64', function(err) {
if(err) throw err;
});
})
};
describe('plugin', function() {
this.timeout(900000);
before(function(done) {
var capabilities = {
'build' : 'Beta',
'project' : 'Plugin',
'platform': pluginConfig.platform,
'browserName' : pluginConfig.browser,
'browserVersion':pluginConfig.browserVersion,
'browserstack.user' : 'paulcommons',
'browserstack.key' : '65VD4KEAKkQdjh1uEaoh',
'browserstack.debug' : 'true',
'acceptSslCerts' : 'true',
'resolution': pluginConfig.resolution
}
driver = new webdriver.Builder().
usingServer(pluginConfig.server).
withCapabilities(capabilities).
build();
done();
});
/*
it('should get iframe', function(done) {
driver.get('http://plugin.retrotax-aci.com/');
//NEED TO CLEAR INPUT VALUE BEFORE INSERTING ANYTHIN
driver.findElement(webdriver.By.name('apikey')).clear();
driver.findElement(webdriver.By.name('apikey')).sendKeys(pluginConfig.apikey);
//driver.findElement(webdriver.By.name('authorization_code')).sendKeys('51DB13');
//driver.findElement(webdriver.By.name('framework')).clear();
//driver.findElement(webdriver.By.name('framework')).sendKeys('bootstrap');
driver.findElement(webdriver.By.id('retrotax_plugin_trigger')).click();
setTimeout(function() {
driver.switchTo().frame("_bftn_iframe");
setTimeout(function() {
driver.findElement(webdriver.By.id('lastname')).sendKeys('Your Address Name');
driver.findElement(webdriver.By.id('firstname')).sendKeys('Your Last Name');
driver.isElementPresent(webdriver.By.id('lastname'))
//isDisplayed()
driver.saveScreenshot('tests/screenshots/'+Math.floor(Date.now() / 1000)+'plugin.png');
}, 3000);
}, 20000); //20 secs
});
*/
/*
it('should supply first name in form and not display firstname field in iframe', function(done) {
driver.get('http://plugin.retrotax-aci.com/');
driver.findElement(webdriver.By.name('apikey')).clear();
driver.findElement(webdriver.By.name('apikey')).sendKeys(pluginConfig.apikey);
driver.findElement(webdriver.By.name('hide_fields')).clear();
driver.findElement(webdriver.By.name('hide_fields')).sendKeys('true');
driver.findElement(webdriver.By.name('first_name')).clear();
driver.findElement(webdriver.By.name('first_name')).sendKeys('Testing');
driver.findElement(webdriver.By.id('retrotax_plugin_trigger')).click();
setTimeout(function() {
driver.switchTo().frame("_bftn_iframe");
setTimeout(function() {
driver.isElementPresent(webdriver.By.id('firstname'));
driver.findElement(webdriver.By.id('firstname')).isDisplayed().then(function(bool){
expect(bool).to.be.false;
if(bool){
driver.saveScreenshot('tests/screenshots/'+Math.floor(Date.now() / 1000)+'plugin.png');
setTimeout(function() { done();}, 3000);
}else{
done();
}
});
}, 3000);
}, 20000); //20 secs
});
it('should supply last name in form and not display lastname field in iframe', function(done) {
driver.get('http://plugin.retrotax-aci.com/');
driver.findElement(webdriver.By.name('apikey')).clear();
driver.findElement(webdriver.By.name('apikey')).sendKeys(pluginConfig.apikey);
driver.findElement(webdriver.By.name('hide_fields')).clear();
driver.findElement(webdriver.By.name('hide_fields')).sendKeys('true');
driver.findElement(webdriver.By.name('last_name')).clear();
driver.findElement(webdriver.By.name('last_name')).sendKeys('Testing');
driver.findElement(webdriver.By.id('retrotax_plugin_trigger')).click();
setTimeout(function() {
driver.switchTo().frame("_bftn_iframe");
setTimeout(function() {
driver.isElementPresent(webdriver.By.id('lastname'));
driver.findElement(webdriver.By.id('lastname')).isDisplayed().then(function(bool){
expect(bool).to.be.false;
if(bool){
driver.saveScreenshot('tests/screenshots/'+Math.floor(Date.now() / 1000)+'plugin.png');
setTimeout(function() { done();}, 3000);
}else{
done();
}
});
}, 3000);
}, 20000); //20 secs
});
*/
it('should supply address name in form and not display address OR address2 field in iframe', function(done) {
driver.get('http://plugin.retrotax-aci.com/');
driver.findElement(webdriver.By.name('apikey')).clear();
driver.findElement(webdriver.By.name('apikey')).sendKeys(pluginConfig.apikey);
driver.findElement(webdriver.By.name('hide_fields')).clear();
driver.findElement(webdriver.By.name('hide_fields')).sendKeys('false');
driver.findElement(webdriver.By.name('last_name')).clear();
driver.findElement(webdriver.By.name('last_name')).sendKeys('Testing');
driver.findElement(webdriver.By.id('retrotax_plugin_trigger')).click();
setTimeout(function() {
driver.switchTo().frame("_bftn_iframe");
setTimeout(function() {
driver.findElement(webdriver.By.id('lastname')).isDisplayed().then(function(bool){
expect(bool).to.be.false;
if(bool){
driver.saveScreenshot('tests/screenshots/'+Math.floor(Date.now() / 1000)+'plugin.png');
setTimeout(function() { done();}, 3000);
}else{
done();
}
});
}, 3000);
}, 30000); //30 secs
});
after(function(done) { driver.quit(); done();});
});
//TODO: sethide_fields to true and set a value in first_name field and it should not be displayed
//TODO: sethide_fields to true and set a value in city field and it should not be displayed
//TODO: sethide_fields to true and set a value in state field and it should not be displayed
//TODO: sethide_fields to true and set a value in zip field and it should not be displayed
//TODO: sethide_fields to true and set a value in address field and it (and address2) should not be displayed
//TODO: sethide_fields to true and set a value in dob field and it should not be displayed
//TODO: repeat all of the above but set framework to 'bootstrap', not the default 'material-design'
//TODO: set rehire to true and question section should not be displayed
//TODO: set plugin_type to ats - authorization section and hiring manager section should NOT be displayed
//TODO: set plugin_type to obs - authorization section and hiring manager section should be displayed