-
Notifications
You must be signed in to change notification settings - Fork 22
/
spec.js
61 lines (49 loc) · 1.93 KB
/
spec.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
beforeEach(function() {
// do something useful
});
var subdomain = 'mppulkit1';
var baseUrl = 'https://'+subdomain+'.localtunnel.me/';
var login = {
username: element(by.model('userName')),
password: element(by.model('password')),
loginButton: element(by.id('login'))
};
describe('In Warehouse', function() {
it('anonymous users should you land on the login page by default', function() {
browser.get(baseUrl);
expect(browser.getLocationAbsUrl())
.toBe('/login');
});
it('users with appropriate credentials should be able to login', function() {
expect(browser.getLocationAbsUrl())
.toBe('/login');
waitForSometime(1000);
// fill in a username
login.username.sendKeys('[email protected]');
waitForSometime(1000);
// fill in a password
login.password.sendKeys('9732KilzSqEUGF');
waitForSometime(1000);
// click the login button
login.loginButton.click();
// validate that you land on the `store-landing` page
expect(browser.getLocationAbsUrl())
.toBe('/store-landing');
});
it('managers should be able to kick-off a job to generate a stock order on demand', function() {
expect(browser.getLocationAbsUrl())
.toBe('/store-landing');
element(by.buttonText('New Stock Order')).click();
expect(browser.getLocationAbsUrl())
.toBe('/create-manual-order');
var name = 'ordered on - ' + Date.now();
element(by.id('orderName')).sendKeys(name);
expect(element(by.id('orderName')).getAttribute('value')).toBe(name);
waitForSometime(3000);
});
});
var waitForSometime = function(milliSeconds){
var start = new Date().getTime();
var script = (milliSeconds)
? 'window.setTimeout(arguments[arguments.length - 1], '+ milliSeconds +');'
: 'window.setTimeout(arguments[arguments.length - 1], 3000);';
browser.executeAsyncScript(script)
.then(function() {
console.log('Elapsed time: ' + (new Date().getTime() - start) + ' ms');
});
};