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
This commit is contained in:
Tero Parviainen 2016-04-11 15:36:53 +03:00 committed by Ward Bell
parent 1ba1407385
commit ec4c1edff4
245 changed files with 843 additions and 617 deletions

View File

@ -32,7 +32,7 @@ exports.config = {
// doesn't seem to work.
// resultJsonOutputFile: "foo.json",
onPrepare: function() {
//// SpecReporter
//var SpecReporter = require('jasmine-spec-reporter');
@ -60,6 +60,12 @@ exports.config = {
global.describeIf = describeIf;
global.itIf = itIf;
global.sendKeys = sendKeys;
// Allow changing bootstrap mode to NG1 for upgrade tests
global.setProtractorToNg1Mode = function() {
browser.useAllAngular2AppRoots = false;
browser.rootEl = 'body';
};
},
jasmineNodeOpts: {
@ -187,4 +193,3 @@ function Reporter(options) {
}
}

View File

@ -0,0 +1,197 @@
describe('Upgrade Tests', function () {
// Protractor doesn't support the UpgradeAdapter's asynchronous
// bootstrap with Angular 1 at the moment. Get around it by
// waiting for an element to get `ng-scope` class.
function waitForNg1AsyncBootstrap() {
browser.ignoreSynchronization = true;
browser.driver.wait(function() {
return element(by.css('.ng-scope')).isPresent();
}, 5000);
}
describe('NG1 Auto-bootstrap', function() {
beforeAll(function () {
browser.get('/index-ng-app.html');
setProtractorToNg1Mode();
});
it('bootstraps as expected', function () {
expect(element(by.css('#message')).getText()).toEqual('Hello world');
});
});
describe('NG1 JavaScript Bootstrap', function() {
beforeAll(function () {
browser.get('/index-bootstrap.html');
setProtractorToNg1Mode();
});
it('bootstraps as expected', function () {
expect(element(by.css('#message')).getText()).toEqual('Hello world');
});
});
describe('NG1-2 Hybrid Bootstrap', function() {
beforeAll(function () {
browser.get('/index-1-2-hybrid-bootstrap.html');
setProtractorToNg1Mode();
});
it('bootstraps as expected', function () {
expect(element(by.css('#message')).getText()).toEqual('Hello world');
});
});
describe('NG1-2 Hybrid Bootstrap with Shared UpgradeAdapter', function() {
beforeAll(function () {
browser.get('/index-1-2-hybrid-shared-adapter-bootstrap.html');
setProtractorToNg1Mode();
});
it('bootstraps as expected', function () {
expect(element(by.css('#message')).getText()).toEqual('Hello world');
});
});
describe('Upgraded static component', function() {
beforeAll(function () {
browser.get('/index-upgrade-static.html');
setProtractorToNg1Mode();
waitForNg1AsyncBootstrap();
});
it('renders', function () {
expect(element(by.css('h2')).getText()).toEqual('Windstorm details!');
});
});
describe('Upgraded component with IO', function() {
beforeAll(function () {
browser.get('/index-upgrade-io.html');
setProtractorToNg1Mode();
waitForNg1AsyncBootstrap();
});
it('has inputs', function () {
expect(element(by.css('h2')).getText()).toEqual('Windstorm details!');
});
it('has outputs', function () {
element(by.buttonText('Delete')).click();
expect(element(by.css('h2')).getText()).toEqual('Ex-Windstorm details!');
});
});
describe('Downgraded static component', function() {
beforeAll(function () {
browser.get('/index-downgrade-static.html');
setProtractorToNg1Mode();
waitForNg1AsyncBootstrap();
});
it('renders', function () {
expect(element(by.css('h2')).getText()).toEqual('Windstorm details!');
});
});
describe('Downgraded component with IO', function() {
beforeAll(function () {
browser.get('/index-downgrade-io.html');
setProtractorToNg1Mode();
waitForNg1AsyncBootstrap();
});
it('has inputs', function () {
expect(element.all(by.css('h2')).first().getText()).toEqual('Windstorm details!');
});
it('has outputs', function () {
element.all(by.buttonText('Delete')).first().click();
expect(element.all(by.css('h2')).first().getText()).toEqual('Ex-Windstorm details!');
});
it('supports ng-repeat', function () {
expect(element.all(by.css('hero-detail')).count()).toBe(3);
});
});
describe('Downgraded component with content projection', function() {
beforeAll(function () {
browser.get('/index-1-to-2-projection.html');
setProtractorToNg1Mode();
waitForNg1AsyncBootstrap();
});
it('can be transcluded into', function () {
expect(element(by.css('hero-detail')).getText()).toContain('Specific powers of controlling winds');
});
});
describe('Upgraded component with transclusion', function() {
beforeAll(function () {
browser.get('/index-2-to-1-transclusion.html');
setProtractorToNg1Mode();
waitForNg1AsyncBootstrap();
});
it('can be projected into', function () {
expect(element(by.css('hero-detail')).getText()).toContain('Specific powers of controlling winds');
});
});
describe('Upgrading NG1 Providers', function() {
beforeAll(function () {
browser.get('/index-1-to-2-providers.html');
setProtractorToNg1Mode();
waitForNg1AsyncBootstrap();
});
it('works', function () {
expect(element(by.css('h2')).getText()).toBe('1: Windstorm');
});
});
describe('Downgrading NG2 Providers', function() {
beforeAll(function () {
browser.get('/index-2-to-1-providers.html');
setProtractorToNg1Mode();
waitForNg1AsyncBootstrap();
});
it('works', function () {
expect(element(by.css('h2')).getText()).toBe('1: Windstorm');
});
});
});

View File

@ -0,0 +1 @@
**/*.js

View File

@ -6,7 +6,9 @@ import {UpgradeAdapter} from 'angular2/upgrade';
// #enddocregion bootstrap
angular.module('heroApp', [])
.run(() => console.log('running'));
.controller('MainCtrl', function() {
this.message = 'Hello world';
});
// #docregion bootstrap

View File

@ -6,7 +6,9 @@ import {upgradeAdapter} from './upgrade_adapter';
declare var angular:any;
angular.module('heroApp', [])
.run(() => console.log('running'));
.controller('MainCtrl', function() {
this.message = 'Hello world';
});
// #docregion bootstrap

View File

@ -0,0 +1,12 @@
declare var angular:any;
angular.module('heroApp', [])
.controller('MainCtrl', function() {
this.message = 'Hello world';
});
document.addEventListener('DOMContentLoaded', function() {
// #docregion bootstrap
angular.bootstrap(document.body, ['heroApp'], {strictDi: true});
// #enddocregion bootstrap
});

View File

@ -0,0 +1,6 @@
declare var angular:any;
angular.module('heroApp', [])
.controller('MainCtrl', function() {
this.message = 'Hello world';
});

View File

@ -0,0 +1,5 @@
import {Hero} from '../Hero';
export class MainController {
hero = new Hero(1, 'Windstorm', 'Specific powers of controlling winds');
}

View File

@ -0,0 +1,11 @@
import {Heroes} from './heroes';
// #docregion
export const heroDetailComponent = {
template: `
<h2>{{$ctrl.hero.id}}: {{$ctrl.hero.name}}</h2>
`,
controller: ['heroes', function(heroes:Heroes) {
this.hero = heroes.get()[0];
}]
};

View File

@ -16,5 +16,5 @@ const HeroDetail = upgradeAdapter.upgradeNg1Component('heroDetail');
directives: [HeroDetail]
})
export class ContainerComponent {
hero = new Hero(1, 'Windstorm', 'a descr');
hero = new Hero(1, 'Windstorm', 'Specific powers of controlling winds');
}

View File

@ -4,7 +4,7 @@ export const heroDetailComponent = {
hero: '='
},
template: `
<h2>{{hero.name}}</h2>
<h2>{{$ctrl.hero.name}}</h2>
<div>
<ng-transclude></ng-transclude>
</div>

View File

@ -7,6 +7,6 @@ export class MainController {
new Hero(3, 'Spiderman')
]
onDelete(hero:Hero) {
console.log('del', hero);
hero.name = 'Ex-' + hero.name;
}
}

View File

@ -17,7 +17,7 @@ const HeroDetail = upgradeAdapter.upgradeNg1Component('heroDetail');
})
export class ContainerComponent {
hero = new Hero(1, 'Windstorm');
heroDeleted(event) {
console.log(event);
heroDeleted(hero:Hero) {
hero.name = 'Ex-' + hero.name;
}
}

View File

@ -0,0 +1,17 @@
// #docregion
export const heroDetail = {
bindings: {
hero: '=',
deleted: '&'
},
template: `
<h2>{{$ctrl.hero.name}} details!</h2>
<div><label>id: </label>{{$ctrl.hero.id}}</div>
<button ng-click="$ctrl.onDelete()">Delete</button>
`,
controller: function() {
this.onDelete = () => {
this.deleted(this.hero);
};
}
};

View File

@ -0,0 +1,34 @@
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="styles.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.js"></script>
<script src="node_modules/es6-shim/es6-shim.min.js"></script>
<script src="node_modules/systemjs/dist/system-polyfills.js"></script>
<script src="node_modules/angular2/es6/dev/src/testing/shims_for_IE.js"></script>
<script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="node_modules/rxjs/bundles/Rx.js"></script>
<script src="node_modules/angular2/bundles/angular2.dev.js"></script>
<script src="node_modules/angular2/bundles/upgrade.dev.js"></script>
<script>
System.config({
packages: {
app: {
format: 'register',
defaultExtension: 'js'
}
}
});
System.import('app/1-2-hybrid-bootstrap/app.module')
.then(null, console.error.bind(console));
</script>
</head>
<body>
<div id="message" ng-controller="MainCtrl as mainCtrl">{{ mainCtrl.message }}</div>
</body>
</html>

View File

@ -0,0 +1,34 @@
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="styles.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.js"></script>
<script src="node_modules/es6-shim/es6-shim.min.js"></script>
<script src="node_modules/systemjs/dist/system-polyfills.js"></script>
<script src="node_modules/angular2/es6/dev/src/testing/shims_for_IE.js"></script>
<script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="node_modules/rxjs/bundles/Rx.js"></script>
<script src="node_modules/angular2/bundles/angular2.dev.js"></script>
<script src="node_modules/angular2/bundles/upgrade.dev.js"></script>
<script>
System.config({
packages: {
app: {
format: 'register',
defaultExtension: 'js'
}
}
});
System.import('app/1-2-hybrid-shared-adapter-bootstrap/app.module')
.then(null, console.error.bind(console));
</script>
</head>
<body>
<div id="message" ng-controller="MainCtrl as mainCtrl">{{ mainCtrl.message }}</div>
</body>
</html>

View File

@ -0,0 +1,43 @@
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="styles.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.js"></script>
<script src="node_modules/es6-shim/es6-shim.min.js"></script>
<script src="node_modules/systemjs/dist/system-polyfills.js"></script>
<script src="node_modules/angular2/es6/dev/src/testing/shims_for_IE.js"></script>
<script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="node_modules/rxjs/bundles/Rx.js"></script>
<script src="node_modules/angular2/bundles/angular2.dev.js"></script>
<script src="node_modules/angular2/bundles/upgrade.dev.js"></script>
<script>
System.config({
packages: {
app: {
format: 'register',
defaultExtension: 'js'
}
}
});
System.import('app/1-to-2-projection/app.module')
.then(null, console.error.bind(console));
</script>
</head>
<body>
<hero-app>
<!-- #docregion usecomponent -->
<div ng-controller="MainController as mainCtrl">
<hero-detail [hero]="mainCtrl.hero">
<!-- Everything here will get projected -->
<p>{{mainCtrl.hero.description}}</p>
</hero-detail>
</div>
<!-- #enddocregion usecomponent -->
</hero-app>
</body>
</html>

View File

@ -0,0 +1,37 @@
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="styles.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.js"></script>
<script src="node_modules/es6-shim/es6-shim.min.js"></script>
<script src="node_modules/systemjs/dist/system-polyfills.js"></script>
<script src="node_modules/angular2/es6/dev/src/testing/shims_for_IE.js"></script>
<script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="node_modules/rxjs/bundles/Rx.js"></script>
<script src="node_modules/angular2/bundles/angular2.dev.js"></script>
<script src="node_modules/angular2/bundles/upgrade.dev.js"></script>
<script>
System.config({
packages: {
app: {
format: 'register',
defaultExtension: 'js'
}
}
});
System.import('app/1-to-2-providers/app.module')
.then(null, console.error.bind(console));
</script>
</head>
<body>
<hero-app>
<hero-detail>
</hero-detail>
</hero-app>
</body>
</html>

View File

@ -0,0 +1,37 @@
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="styles.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.js"></script>
<script src="node_modules/es6-shim/es6-shim.min.js"></script>
<script src="node_modules/systemjs/dist/system-polyfills.js"></script>
<script src="node_modules/angular2/es6/dev/src/testing/shims_for_IE.js"></script>
<script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="node_modules/rxjs/bundles/Rx.js"></script>
<script src="node_modules/angular2/bundles/angular2.dev.js"></script>
<script src="node_modules/angular2/bundles/upgrade.dev.js"></script>
<script>
System.config({
packages: {
app: {
format: 'register',
defaultExtension: 'js'
}
}
});
System.import('app/2-to-1-providers/app.module')
.then(null, console.error.bind(console));
</script>
</head>
<body>
<hero-app>
<hero-detail>
</hero-detail>
</hero-app>
</body>
</html>

View File

@ -0,0 +1,36 @@
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="styles.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.js"></script>
<script src="node_modules/es6-shim/es6-shim.min.js"></script>
<script src="node_modules/systemjs/dist/system-polyfills.js"></script>
<script src="node_modules/angular2/es6/dev/src/testing/shims_for_IE.js"></script>
<script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="node_modules/rxjs/bundles/Rx.js"></script>
<script src="node_modules/angular2/bundles/angular2.dev.js"></script>
<script src="node_modules/angular2/bundles/upgrade.dev.js"></script>
<script>
System.config({
packages: {
app: {
format: 'register',
defaultExtension: 'js'
}
}
});
System.import('app/2-to-1-transclusion/app.module')
.then(null, console.error.bind(console));
</script>
</head>
<body>
<hero-app>
<my-container></my-container>
</hero-app>
</body>
</html>

View File

@ -0,0 +1,11 @@
<!-- #docregion -->
<!DOCTYPE HTML>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.js"></script>
<script src="app/1-bootstrap/app.module.js"></script>
</head>
<body>
<div id="message" ng-controller="MainCtrl as mainCtrl">{{ mainCtrl.message }}</div>
</body>
</html>

View File

@ -0,0 +1,50 @@
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="styles.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.js"></script>
<script src="node_modules/es6-shim/es6-shim.min.js"></script>
<script src="node_modules/systemjs/dist/system-polyfills.js"></script>
<script src="node_modules/angular2/es6/dev/src/testing/shims_for_IE.js"></script>
<script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="node_modules/rxjs/bundles/Rx.js"></script>
<script src="node_modules/angular2/bundles/angular2.dev.js"></script>
<script src="node_modules/angular2/bundles/upgrade.dev.js"></script>
<script>
System.config({
packages: {
app: {
format: 'register',
defaultExtension: 'js'
}
}
});
System.import('app/downgrade-io/app.module')
.then(null, console.error.bind(console));
</script>
</head>
<body>
<hero-app>
<!-- #docregion usecomponent -->
<div ng-controller="MainController as mainCtrl">
<hero-detail [hero]="mainCtrl.hero"
(deleted)="mainCtrl.onDelete($event)">
</hero-detail>
</div>
<!-- #enddocregion usecomponent -->
<!-- #docregion userepeatedcomponent -->
<div ng-controller="MainController as mainCtrl">
<hero-detail [hero]="hero"
(deleted)="mainCtrl.onDelete($event)"
ng-repeat="hero in mainCtrl.heroes">
</hero-detail>
</div>
<!-- #enddocregion userepeatedcomponent-->
</hero-app>
</body>
</html>

View File

@ -0,0 +1,38 @@
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="styles.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.js"></script>
<script src="node_modules/es6-shim/es6-shim.min.js"></script>
<script src="node_modules/systemjs/dist/system-polyfills.js"></script>
<script src="node_modules/angular2/es6/dev/src/testing/shims_for_IE.js"></script>
<script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="node_modules/rxjs/bundles/Rx.js"></script>
<script src="node_modules/angular2/bundles/angular2.dev.js"></script>
<script src="node_modules/angular2/bundles/upgrade.dev.js"></script>
<script>
System.config({
packages: {
app: {
format: 'register',
defaultExtension: 'js'
}
}
});
System.import('app/downgrade-static/app.module')
.then(null, console.error.bind(console));
</script>
</head>
<body>
<hero-app>
<!-- #docregion usecomponent -->
<hero-detail></hero-detail>
<!-- #enddocregion usecomponent -->
</hero-app>
</body>
</html>

View File

@ -2,10 +2,10 @@
<!DOCTYPE HTML>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.js"></script>
<script src="app/1-ng-app/app.module.js"></script>
</head>
<body ng-app="heroApp" ng-strict-di>
<div ng-view></div>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0-rc.0/angular.js"></script>
<script src="js/1-ng-app/app.module.js"></script>
<div id="message" ng-controller="MainCtrl as mainCtrl">{{ mainCtrl.message }}</div>
</body>
</html>

View File

@ -0,0 +1,36 @@
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="styles.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.js"></script>
<script src="node_modules/es6-shim/es6-shim.min.js"></script>
<script src="node_modules/systemjs/dist/system-polyfills.js"></script>
<script src="node_modules/angular2/es6/dev/src/testing/shims_for_IE.js"></script>
<script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="node_modules/rxjs/bundles/Rx.js"></script>
<script src="node_modules/angular2/bundles/angular2.dev.js"></script>
<script src="node_modules/angular2/bundles/upgrade.dev.js"></script>
<script>
System.config({
packages: {
app: {
format: 'register',
defaultExtension: 'js'
}
}
});
System.import('app/upgrade-io/app.module')
.then(null, console.error.bind(console));
</script>
</head>
<body>
<hero-app>
<my-container></my-container>
</hero-app>
</body>
</html>

View File

@ -0,0 +1,36 @@
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="styles.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.js"></script>
<script src="node_modules/es6-shim/es6-shim.min.js"></script>
<script src="node_modules/systemjs/dist/system-polyfills.js"></script>
<script src="node_modules/angular2/es6/dev/src/testing/shims_for_IE.js"></script>
<script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="node_modules/rxjs/bundles/Rx.js"></script>
<script src="node_modules/angular2/bundles/angular2.dev.js"></script>
<script src="node_modules/angular2/bundles/upgrade.dev.js"></script>
<script>
System.config({
packages: {
app: {
format: 'register',
defaultExtension: 'js'
}
}
});
System.import('app/upgrade-static/app.module')
.then(null, console.error.bind(console));
</script>
</head>
<body>
<hero-app>
<my-container></my-container>
</hero-app>
</body>
</html>

View File

@ -6,15 +6,15 @@
"license": "MIT",
"private": true,
"dependencies": {
"angular": "1.5.0",
"angular-mocks": "1.5.0",
"angular": "1.5.3",
"angular-mocks": "1.5.3",
"jquery": "~2.1.1",
"bootstrap": "~3.1.1",
"angular-route": "1.5.0",
"angular-resource": "1.5.0",
"angular-animate": "1.5.0"
"angular-route": "1.5.3",
"angular-resource": "1.5.3",
"angular-animate": "1.5.3"
},
"resolutions": {
"angular": "1.5.0"
"angular": "1.5.3"
}
}

View File

@ -6,7 +6,7 @@
"repository": "https://github.com/angular/angular-phonecat",
"license": "MIT",
"dependencies": {
"systemjs": "0.19.22"
"systemjs": "0.19.25"
},
"devDependencies": {
"karma": "^0.12.16",
@ -18,8 +18,8 @@
"tmp": "0.0.23",
"bower": "^1.3.1",
"shelljs": "^0.2.6",
"typescript": "1.8.2",
"typings": "^0.6.8"
"typescript": "1.8.9",
"typings": "^0.7.12"
},
"scripts": {
"postinstall": "bower install",

Some files were not shown because too many files have changed in this diff Show More