Skip to content

Commit 718fa35

Browse files
committed
example(routing): adding routing example and e2e tests
Closes angular#2650
1 parent c177d88 commit 718fa35

12 files changed

Lines changed: 2149 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: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import {verifyNoBrowserErrors} from 'angular2/src/test_lib/e2e_util';
2+
3+
4+
describe('routing inbox-app', function() {
5+
6+
afterEach(verifyNoBrowserErrors);
7+
8+
describe('index view', function() {
9+
var URL = 'examples/src/routing/';
10+
11+
it('should list out the current collection of items', function() {
12+
browser.get(URL);
13+
expect(element.all(by.css('.inbox-item-record')).count()).toEqual(200);
14+
});
15+
16+
it('should build a link which points to the detail page', function() {
17+
browser.get(URL);
18+
expect(element(by.css('#item-15')).getAttribute('href')).toMatch(/\/detail\/15$/);
19+
element(by.css('#item-15')).click();
20+
browser.sleep(200); // TODO: see #428
21+
expect(browser.getCurrentUrl()).toMatch(/\/detail\/15$/);
22+
});
23+
});
24+
25+
26+
describe('drafts view', function() {
27+
var URL = 'examples/src/routing/#/drafts';
28+
29+
it('should navigate to the drafts view when the drafts link is clicked', function() {
30+
browser.get(URL);
31+
element(by.linkText('Drafts')).click();
32+
browser.sleep(200); // TODO: see #428
33+
expect(element(by.css('.page-title')).getText()).toEqual('Drafts');
34+
});
35+
36+
it('should navigate to email details', function() {
37+
browser.get(URL);
38+
element(by.linkText('Drafts')).click();
39+
browser.sleep(200); // TODO: see #428
40+
expect(element.all(by.css('.inbox-item-record')).count()).toEqual(2);
41+
expect(element(by.css('#item-201')).getAttribute('href')).toMatch(/\/detail\/201$/);
42+
element(by.css('#item-201')).click();
43+
browser.sleep(200); // TODO: see #428
44+
expect(browser.getCurrentUrl()).toMatch(/\/detail\/201$/);
45+
});
46+
});
47+
48+
49+
describe('detail view', function() {
50+
var URL = 'examples/src/routing/';
51+
52+
it('should navigate to the detail view when an email is clicked', function() {
53+
browser.get(URL);
54+
browser.sleep(200); // TODO: see #428
55+
element(by.css('#item-10')).click();
56+
browser.sleep(200);
57+
expect(element(by.css('#record-id')).getText()).toEqual('ID: 10');
58+
});
59+
60+
it('should navigate back to the email inbox page when the back button is clicked', function() {
61+
browser.get(URL);
62+
browser.sleep(200); // TODO: see #428
63+
element(by.css('#item-10')).click();
64+
browser.sleep(200);
65+
element(by.css('.back-button')).click();
66+
browser.sleep(200);
67+
expect(browser.getCurrentUrl()).toMatch('/#');
68+
});
69+
})
70+
});
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)