Skip to content

Commit 18d6197

Browse files
committed
Add end to end tests with mocks
1 parent 8b4b5fc commit 18d6197

File tree

9 files changed

+1241
-7
lines changed

9 files changed

+1241
-7
lines changed

.travis.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
language: node_js
22
node_js:
3-
- "0.10"
4-
3+
- '4'
54
before_script:
6-
- /bin/env
7-
- /bin/ps auxf
5+
- env
6+
- ps auxf
87
- hostname
98
- uname -a
9+
- npm install -g protractor
10+
script: e2e/run.sh
11+
addons:
12+
sauce_connect:
13+
username: "fanatic"
14+
access_key:
15+
secure: Yhe4v48+JYDcaByL3/ZZf2qUbCYx9p1WjNa6nR6lW3Q7BJbLFERzyvTMoLyGfDRHNlnLE3cRfZM6NHNmAb8s8idtzilnC+RYEGLLi2KlGz2p6Xp9fKg0rkhIMGbuwQ4Z0pQMHeuYYCEp69/HKocQcaqiYtCtiLz4UTft+Tq0VQI=

e2e/mocks/get-users.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
request: {
3+
path: '/users/1',
4+
method: 'GET'
5+
},
6+
response: {
7+
data: {
8+
userName: 'pro-mock',
9+
10+
}
11+
}
12+
}

e2e/protractor.conf.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
exports.config = {
2+
baseUrl: 'http://localhost:8888/',
3+
//seleniumAddress: 'http://localhost:4444/wd/hub',
4+
specs: ['specs/*.js'],
5+
6+
// Sauce Labs Setup
7+
sauceUser: process.env.SAUCE_USERNAME,
8+
sauceKey: process.env.SAUCE_ACCESS_KEY,
9+
10+
// restartBrowserBetweenTests: true,
11+
12+
onPrepare: function(){
13+
var caps = browser.getCapabilities()
14+
},
15+
16+
multiCapabilities: [{
17+
browserName: 'firefox',
18+
version: '32',
19+
platform: 'OS X 10.10',
20+
name: "firefox-tests",
21+
shardTestFiles: true,
22+
maxInstances: 2,
23+
'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER
24+
}, {
25+
browserName: 'chrome',
26+
version: '41',
27+
platform: 'Windows 7',
28+
name: "chrome-tests",
29+
shardTestFiles: true,
30+
maxInstances: 2,
31+
'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER
32+
}],
33+
34+
onComplete: function() {
35+
var printSessionId = function(jobName){
36+
browser.getSession().then(function(session) {
37+
console.log('SauceOnDemandSessionID=' + session.getId() + ' job-name=' + jobName);
38+
});
39+
}
40+
printSessionId("Insert Job Name Here");
41+
}
42+
};

e2e/run.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
if [[ "$(basename `pwd`)" == "e2e" ]]; then
4+
echo "Run from the root of the project instead"
5+
echo "./e2e/run.sh"
6+
exit 1
7+
fi
8+
9+
python -m SimpleHTTPServer 8888 &
10+
http_pid=$!
11+
12+
function finish {
13+
kill -9 $http_pid
14+
}
15+
trap finish EXIT
16+
17+
protractor e2e/protractor.conf.js

e2e/specs/browser.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
describe('swift-ui homepage', function() {
2+
beforeEach(function () {
3+
browser.driver.get('http://localhost:8888/index.html');
4+
});
5+
6+
it('should log in', function() {
7+
//browser.pause();
8+
// Allow page to load
9+
browser.sleep(10000);
10+
11+
expect(browser.driver.getTitle()).toEqual('Swift UI');
12+
browser.driver.findElement(by.id('loginButton')).click();
13+
14+
// Wait for login
15+
browser.sleep(1000);
16+
17+
var loginText = browser.driver.findElement(by.css('#login-entry .navbar-text'));
18+
expect(loginText.getText()).toEqual('Signed in as test:tester');
19+
});
20+
21+
it('should list accounts and details', function() {
22+
browser.sleep(10000);
23+
browser.driver.findElement(by.id('loginButton')).click();
24+
25+
// Wait for login
26+
browser.sleep(2000);
27+
28+
//browser.pause();
29+
30+
var account = browser.driver.findElement(by.css('#test[rel="account"] a'));
31+
expect(account.getText()).toEqual(' test');
32+
account.click();
33+
34+
// Wait for account details to laod
35+
browser.sleep(1000);
36+
37+
var breadcrumb = browser.driver.findElement(by.css('.breadcrumb > li:first-child'));
38+
expect(breadcrumb.getText()).toEqual('test');
39+
40+
var header = browser.driver.findElement(by.css('.page-header > h1 > small'));
41+
expect(header.getText()).toEqual('Account');
42+
43+
var metadata = browser.driver.findElement(by.css('#Color.metadata'));
44+
expect(metadata.getText()).toEqual('blue');
45+
});
46+
});

js/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ var appConfig = {
22
"auth": {
33
"username": "test:tester",
44
"key": "testing",
5-
"endpoint": "http://192.168.2.77:8080/auth/v1.0"
5+
"endpoint": "http://example.com:8080/auth/v1.0"
66
}
77
};
88

0 commit comments

Comments
 (0)