Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit ec4c1ed

Browse files
teropawardbell
authored andcommitted
docs(upgrade): add E2E tests, update PhoneCat dependencies
closes #1070 Separates UpgradeAdapter reference guide examples from the PhoneCat tutorial examples and update dependencies for phonecat upgrade examples
1 parent 1ba1407 commit ec4c1ed

File tree

245 files changed

+843
-617
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

245 files changed

+843
-617
lines changed

public/docs/_examples/protractor.config.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ exports.config = {
3232

3333
// doesn't seem to work.
3434
// resultJsonOutputFile: "foo.json",
35-
35+
3636
onPrepare: function() {
3737
//// SpecReporter
3838
//var SpecReporter = require('jasmine-spec-reporter');
@@ -60,6 +60,12 @@ exports.config = {
6060
global.describeIf = describeIf;
6161
global.itIf = itIf;
6262
global.sendKeys = sendKeys;
63+
64+
// Allow changing bootstrap mode to NG1 for upgrade tests
65+
global.setProtractorToNg1Mode = function() {
66+
browser.useAllAngular2AppRoots = false;
67+
browser.rootEl = 'body';
68+
};
6369
},
6470

6571
jasmineNodeOpts: {
@@ -187,4 +193,3 @@ function Reporter(options) {
187193
}
188194

189195
}
190-
Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
describe('Upgrade Tests', function () {
2+
3+
// Protractor doesn't support the UpgradeAdapter's asynchronous
4+
// bootstrap with Angular 1 at the moment. Get around it by
5+
// waiting for an element to get `ng-scope` class.
6+
function waitForNg1AsyncBootstrap() {
7+
browser.ignoreSynchronization = true;
8+
browser.driver.wait(function() {
9+
return element(by.css('.ng-scope')).isPresent();
10+
}, 5000);
11+
}
12+
13+
describe('NG1 Auto-bootstrap', function() {
14+
15+
beforeAll(function () {
16+
browser.get('/index-ng-app.html');
17+
setProtractorToNg1Mode();
18+
});
19+
20+
it('bootstraps as expected', function () {
21+
expect(element(by.css('#message')).getText()).toEqual('Hello world');
22+
});
23+
24+
});
25+
26+
describe('NG1 JavaScript Bootstrap', function() {
27+
28+
beforeAll(function () {
29+
browser.get('/index-bootstrap.html');
30+
setProtractorToNg1Mode();
31+
});
32+
33+
it('bootstraps as expected', function () {
34+
expect(element(by.css('#message')).getText()).toEqual('Hello world');
35+
});
36+
37+
});
38+
39+
describe('NG1-2 Hybrid Bootstrap', function() {
40+
41+
beforeAll(function () {
42+
browser.get('/index-1-2-hybrid-bootstrap.html');
43+
setProtractorToNg1Mode();
44+
});
45+
46+
it('bootstraps as expected', function () {
47+
expect(element(by.css('#message')).getText()).toEqual('Hello world');
48+
});
49+
50+
});
51+
52+
describe('NG1-2 Hybrid Bootstrap with Shared UpgradeAdapter', function() {
53+
54+
beforeAll(function () {
55+
browser.get('/index-1-2-hybrid-shared-adapter-bootstrap.html');
56+
setProtractorToNg1Mode();
57+
});
58+
59+
it('bootstraps as expected', function () {
60+
expect(element(by.css('#message')).getText()).toEqual('Hello world');
61+
});
62+
63+
});
64+
65+
describe('Upgraded static component', function() {
66+
67+
beforeAll(function () {
68+
browser.get('/index-upgrade-static.html');
69+
setProtractorToNg1Mode();
70+
waitForNg1AsyncBootstrap();
71+
});
72+
73+
it('renders', function () {
74+
expect(element(by.css('h2')).getText()).toEqual('Windstorm details!');
75+
});
76+
77+
});
78+
79+
80+
describe('Upgraded component with IO', function() {
81+
82+
beforeAll(function () {
83+
browser.get('/index-upgrade-io.html');
84+
setProtractorToNg1Mode();
85+
waitForNg1AsyncBootstrap();
86+
});
87+
88+
it('has inputs', function () {
89+
expect(element(by.css('h2')).getText()).toEqual('Windstorm details!');
90+
});
91+
92+
it('has outputs', function () {
93+
element(by.buttonText('Delete')).click();
94+
expect(element(by.css('h2')).getText()).toEqual('Ex-Windstorm details!');
95+
});
96+
97+
});
98+
99+
100+
describe('Downgraded static component', function() {
101+
102+
beforeAll(function () {
103+
browser.get('/index-downgrade-static.html');
104+
setProtractorToNg1Mode();
105+
waitForNg1AsyncBootstrap();
106+
});
107+
108+
it('renders', function () {
109+
expect(element(by.css('h2')).getText()).toEqual('Windstorm details!');
110+
});
111+
112+
});
113+
114+
describe('Downgraded component with IO', function() {
115+
116+
beforeAll(function () {
117+
browser.get('/index-downgrade-io.html');
118+
setProtractorToNg1Mode();
119+
waitForNg1AsyncBootstrap();
120+
});
121+
122+
it('has inputs', function () {
123+
expect(element.all(by.css('h2')).first().getText()).toEqual('Windstorm details!');
124+
});
125+
126+
it('has outputs', function () {
127+
element.all(by.buttonText('Delete')).first().click();
128+
expect(element.all(by.css('h2')).first().getText()).toEqual('Ex-Windstorm details!');
129+
});
130+
131+
it('supports ng-repeat', function () {
132+
expect(element.all(by.css('hero-detail')).count()).toBe(3);
133+
});
134+
135+
});
136+
137+
138+
describe('Downgraded component with content projection', function() {
139+
140+
beforeAll(function () {
141+
browser.get('/index-1-to-2-projection.html');
142+
setProtractorToNg1Mode();
143+
waitForNg1AsyncBootstrap();
144+
});
145+
146+
it('can be transcluded into', function () {
147+
expect(element(by.css('hero-detail')).getText()).toContain('Specific powers of controlling winds');
148+
});
149+
150+
});
151+
152+
153+
describe('Upgraded component with transclusion', function() {
154+
155+
beforeAll(function () {
156+
browser.get('/index-2-to-1-transclusion.html');
157+
setProtractorToNg1Mode();
158+
waitForNg1AsyncBootstrap();
159+
});
160+
161+
it('can be projected into', function () {
162+
expect(element(by.css('hero-detail')).getText()).toContain('Specific powers of controlling winds');
163+
});
164+
165+
});
166+
167+
168+
describe('Upgrading NG1 Providers', function() {
169+
170+
beforeAll(function () {
171+
browser.get('/index-1-to-2-providers.html');
172+
setProtractorToNg1Mode();
173+
waitForNg1AsyncBootstrap();
174+
});
175+
176+
it('works', function () {
177+
expect(element(by.css('h2')).getText()).toBe('1: Windstorm');
178+
});
179+
180+
});
181+
182+
183+
describe('Downgrading NG2 Providers', function() {
184+
185+
beforeAll(function () {
186+
browser.get('/index-2-to-1-providers.html');
187+
setProtractorToNg1Mode();
188+
waitForNg1AsyncBootstrap();
189+
});
190+
191+
it('works', function () {
192+
expect(element(by.css('h2')).getText()).toBe('1: Windstorm');
193+
});
194+
195+
});
196+
197+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/*.js

public/docs/_examples/upgrade/ts/adapter/app/js/1-2-hybrid-bootstrap/app.module.ts renamed to public/docs/_examples/upgrade-adapter/ts/app/1-2-hybrid-bootstrap/app.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import {UpgradeAdapter} from 'angular2/upgrade';
66
// #enddocregion bootstrap
77

88
angular.module('heroApp', [])
9-
.run(() => console.log('running'));
9+
.controller('MainCtrl', function() {
10+
this.message = 'Hello world';
11+
});
1012

1113
// #docregion bootstrap
1214

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import {upgradeAdapter} from './upgrade_adapter';
66
declare var angular:any;
77

88
angular.module('heroApp', [])
9-
.run(() => console.log('running'));
9+
.controller('MainCtrl', function() {
10+
this.message = 'Hello world';
11+
});
1012

1113
// #docregion bootstrap
1214

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
declare var angular:any;
2+
3+
angular.module('heroApp', [])
4+
.controller('MainCtrl', function() {
5+
this.message = 'Hello world';
6+
});
7+
8+
document.addEventListener('DOMContentLoaded', function() {
9+
// #docregion bootstrap
10+
angular.bootstrap(document.body, ['heroApp'], {strictDi: true});
11+
// #enddocregion bootstrap
12+
});
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
declare var angular:any;
2+
3+
angular.module('heroApp', [])
4+
.controller('MainCtrl', function() {
5+
this.message = 'Hello world';
6+
});

0 commit comments

Comments
 (0)