Skip to content

Commit 4cfe92c

Browse files
matskobtford
authored andcommitted
example(routing): adding routing example and e2e tests
1 parent 9d27761 commit 4cfe92c

12 files changed

Lines changed: 2184 additions & 0 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
library examples.e2e_test.routing.routing_spec;
2+
3+
main() {
4+
5+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import {verifyNoBrowserErrors} from 'angular2/src/test_lib/e2e_util';
2+
3+
function waitForElement(selector) {
4+
var EC = (<any>protractor).ExpectedConditions;
5+
// Waits for the element with id 'abc' to be present on the dom.
6+
browser.wait(EC.presenceOf($(selector)), 10000);
7+
}
8+
9+
describe('routing inbox-app', function() {
10+
11+
afterEach(verifyNoBrowserErrors);
12+
13+
describe('index view', function() {
14+
var URL = 'examples/src/routing/';
15+
16+
it('should list out the current collection of items', function() {
17+
browser.get(URL);
18+
waitForElement('.inbox-item-record');
19+
expect(element.all(by.css('.inbox-item-record')).count()).toEqual(200);
20+
});
21+
22+
it('should build a link which points to the detail page', function() {
23+
browser.get(URL);
24+
waitForElement('#item-15');
25+
expect(element(by.css('#item-15')).getAttribute('href')).toMatch(/\/detail\/15$/);
26+
element(by.css('#item-15')).click();
27+
waitForElement('#record-id');
28+
expect(browser.getCurrentUrl()).toMatch(/\/detail\/15$/);
29+
});
30+
});
31+
32+
33+
describe('drafts view', function() {
34+
var URL = 'examples/src/routing/#/drafts';
35+
36+
it('should navigate to the drafts view when the drafts link is clicked', function() {
37+
browser.get(URL);
38+
waitForElement('.inbox-item-record');
39+
element(by.linkText('Drafts')).click();
40+
waitForElement('.page-title');
41+
expect(element(by.css('.page-title')).getText()).toEqual('Drafts');
42+
});
43+
44+
it('should navigate to email details', function() {
45+
browser.get(URL);
46+
element(by.linkText('Drafts')).click();
47+
waitForElement('.inbox-item-record');
48+
expect(element.all(by.css('.inbox-item-record')).count()).toEqual(2);
49+
expect(element(by.css('#item-201')).getAttribute('href')).toMatch(/\/detail\/201$/);
50+
element(by.css('#item-201')).click();
51+
waitForElement('#record-id');
52+
expect(browser.getCurrentUrl()).toMatch(/\/detail\/201$/);
53+
});
54+
});
55+
56+
57+
describe('detail view', function() {
58+
var URL = 'examples/src/routing/';
59+
60+
it('should navigate to the detail view when an email is clicked', function() {
61+
browser.get(URL);
62+
waitForElement('#item-10');
63+
element(by.css('#item-10')).click();
64+
waitForElement('#record-id');
65+
expect(element(by.css('#record-id')).getText()).toEqual('ID: 10');
66+
});
67+
68+
it('should navigate back to the email inbox page when the back button is clicked', function() {
69+
browser.get(URL);
70+
waitForElement('#item-10');
71+
element(by.css('#item-10')).click();
72+
waitForElement('.back-button');
73+
element(by.css('.back-button')).click();
74+
expect(browser.getCurrentUrl()).toMatch('/#');
75+
});
76+
})
77+
});
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
body {
2+
background:#eee;
3+
color:black;
4+
}
5+
6+
.inbox-list,
7+
.inbox-list li {
8+
list-style:none;
9+
padding:0;
10+
margin:0;
11+
}
12+
13+
.inbox-list a {
14+
padding:5px;
15+
display:block;
16+
}
17+
18+
inbox, drafts, inbox-side-menu {
19+
display:block;
20+
}
21+
22+
inbox-side-menu .link {
23+
display:block;
24+
text-align:center;
25+
padding:1em;
26+
}
27+
28+
inbox-side-menu .link.active {
29+
background:white;
30+
}
31+
32+
inbox-side-menu .link:hover {
33+
background:#eee;
34+
}
35+
36+
inbox-side-menu {
37+
position:fixed;
38+
left:0;
39+
top:0;
40+
bottom:0;
41+
width:200px;
42+
background:#ddd;
43+
}
44+
45+
inbox-side-menu a {
46+
display: block;
47+
}
48+
49+
inbox, drafts, inbox-detail {
50+
padding:1em;
51+
margin-left:200px;
52+
}
53+
54+
inbox-detail {
55+
display:block;
56+
margin-left:200px;
57+
}

0 commit comments

Comments
 (0)