diff --git a/.travis.yml b/.travis.yml index 35196cb0968..8866678cc2f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -46,7 +46,6 @@ matrix: allow_failures: - env: "MODE=saucelabs_optional" - env: "MODE=browserstack_optional" - - env: "MODE=e2e" install: - npm install diff --git a/angular-cli-build.js b/angular-cli-build.js index cd46f6fa694..28122f31979 100644 --- a/angular-cli-build.js +++ b/angular-cli-build.js @@ -25,7 +25,7 @@ module.exports = function(defaults) { /** - * Build the Broccoli Tree containing all the files used as the input to the Angular2App. + * Build the Broccoli Tree containing all the files used as the input to the Demo Angular2App. */ function _buildDemoAppInputTree() { return new MergeTree([ @@ -42,6 +42,26 @@ function _buildDemoAppInputTree() { ]); } + +/** + * Build the Broccoli Tree containing all the files used as the input to the e2e Angular2App. + */ +function _buildE2EAppInputTree() { + return new MergeTree([ + new Funnel('typings', { + destDir: 'typings' + }), + new Funnel('src', { + include: ['components/**/*', 'core/**/*'], + destDir: 'src/e2e-app' + }), + new Funnel('src/e2e-app', { + destDir: 'src/e2e-app' + }) + ]); +} + + /** * Build the Broccoli Tree that contains the Angular2 App. This picks between E2E, Example or Demo * app. @@ -49,12 +69,28 @@ function _buildDemoAppInputTree() { * @returns {Angular2App} */ function _buildAppTree(defaults) { - let inputNode = _buildDemoAppInputTree(); + let inputNode; + let sourceDir; + switch(process.env['MD_APP']) { + case 'e2e': + inputNode = _buildE2EAppInputTree(); + sourceDir = 'src/e2e-app'; + break; + default: + inputNode = _buildDemoAppInputTree(); + sourceDir = 'src/demo-app'; + } return new Angular2App(defaults, inputNode, { - sourceDir: 'src/demo-app', - tsCompiler: { - }, + sourceDir: sourceDir, + polyfills: [ + 'vendor/es6-shim/es6-shim.js', + 'vendor/reflect-metadata/Reflect.js', + 'vendor/systemjs/dist/system.src.js', + 'vendor/zone.js/dist/zone.js', + 'vendor/hammerjs/hammer.min.js' + ], + tsCompiler: {}, sassCompiler: { includePaths: [ 'src/core/style' @@ -67,7 +103,8 @@ function _buildAppTree(defaults) { 'es6-shim/es6-shim.js', 'reflect-metadata/*.js', 'rxjs/**/*.js', - '@angular/**/*.js' + '@angular/**/*.js', + 'hammerjs/*.min.+(js|js.map)' ] }); } diff --git a/e2e/components/button/button.e2e.js b/e2e/components/button/button.e2e.ts similarity index 99% rename from e2e/components/button/button.e2e.js rename to e2e/components/button/button.e2e.ts index 84c60f5e119..6862085cd7f 100644 --- a/e2e/components/button/button.e2e.js +++ b/e2e/components/button/button.e2e.ts @@ -13,5 +13,3 @@ describe('button', function () { }); }); }); - - diff --git a/e2e/index.e2e.ts b/e2e/index.e2e.ts index c645ad44cd7..4bc96fb8936 100644 --- a/e2e/index.e2e.ts +++ b/e2e/index.e2e.ts @@ -1,5 +1,3 @@ -/// - describe('hello, protractor', function () { describe('index', function () { browser.get('/'); @@ -8,4 +6,3 @@ describe('hello, protractor', function () { }); }); }); - diff --git a/e2e/tsconfig.json b/e2e/tsconfig.json index a965bbcf28d..82440caf18f 100644 --- a/e2e/tsconfig.json +++ b/e2e/tsconfig.json @@ -4,7 +4,6 @@ "emitDecoratorMetadata": true, "experimentalDecorators": true, "inlineSources": true, - "mapRoot": "", "module": "commonjs", "moduleResolution": "node", "noEmitOnError": true, @@ -15,7 +14,6 @@ "target": "es5" }, "files": [ - "index.e2e.ts", "e2e.d.ts" ] } diff --git a/package.json b/package.json index 8174da62035..e0a296da03a 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "tslint": "tslint -c tslint.json 'src/**/*.ts'", "typings": "typings install --ambient", "postinstall": "npm run typings", - "e2e": "protractor test/protractor.conf.js", + "e2e": "protractor", "inline-resources": "node ./scripts/release/inline-resources.js ./dist/components", "deploy": "firebase deploy" }, @@ -28,12 +28,13 @@ "@angular/common": "2.0.0-rc.1", "@angular/compiler": "2.0.0-rc.1", "@angular/core": "2.0.0-rc.1", - "@angular/router": "2.0.0-rc.1", "@angular/http": "2.0.0-rc.1", "@angular/platform-browser": "2.0.0-rc.1", "@angular/platform-browser-dynamic": "2.0.0-rc.1", + "@angular/router": "2.0.0-rc.1", "es6-promise": "^3.0.2", "es6-shim": "^0.35.0", + "hammerjs": "^2.0.8", "reflect-metadata": "0.1.3", "rxjs": "5.0.0-beta.6", "systemjs": "0.19.26", @@ -41,7 +42,7 @@ }, "devDependencies": { "add-stream": "^1.0.0", - "angular-cli": "^1.0.0-beta.4", + "angular-cli": "^1.0.0-beta.5", "broccoli-autoprefixer": "^4.1.0", "broccoli-funnel": "^1.0.1", "broccoli-merge-trees": "^1.1.1", @@ -64,7 +65,7 @@ "sass": "^0.5.0", "strip-ansi": "^3.0.0", "symlink-or-copy": "^1.0.1", - "ts-node": "^0.5.5", + "ts-node": "^0.7.3", "tslint": "^3.5.0", "typescript": "^1.9.0-dev", "typings": "^0.8.1", diff --git a/scripts/ci/build-and-test.sh b/scripts/ci/build-and-test.sh index 0e5ebecb812..3cf412720df 100755 --- a/scripts/ci/build-and-test.sh +++ b/scripts/ci/build-and-test.sh @@ -21,7 +21,7 @@ if is_lint; then elif is_e2e; then ng serve & sleep 20 - npm run e2e + ng e2e else karma start test/karma.conf.js --single-run --no-auto-watch --reporters='dots' fi diff --git a/src/demo-app/index.html b/src/demo-app/index.html index f5f78283e30..f5e774118e1 100644 --- a/src/demo-app/index.html +++ b/src/demo-app/index.html @@ -1,11 +1,17 @@ +{{!-- This file is an handlebar file that gets filled at build time. --}} Material2 - {{content-for 'head'}} + + {{!-- Add live-reload support, only in development. --}} + {{#unless environment.production}} + + {{/unless}} + @@ -16,14 +22,10 @@ Loading... - - - - - - - - + {{!-- Add all polyfill scripts. --}} + {{#each scripts.polyfills}} + + {{/each}} + {{/unless}} + + + + + + + + + + Loading... + + {{#each scripts.polyfills}} + + {{/each}} + + + + diff --git a/src/e2e-app/main.scss b/src/e2e-app/main.scss new file mode 100644 index 00000000000..36e9cd52c13 --- /dev/null +++ b/src/e2e-app/main.scss @@ -0,0 +1,2 @@ +@import "core/overlay/overlay"; +@import "core/live-announcer/live-announcer"; \ No newline at end of file diff --git a/src/e2e-app/main.ts b/src/e2e-app/main.ts new file mode 100644 index 00000000000..1fbdcef84c8 --- /dev/null +++ b/src/e2e-app/main.ts @@ -0,0 +1,24 @@ +import {bootstrap} from '@angular/platform-browser-dynamic'; +import {HAMMER_GESTURE_CONFIG} from '@angular/platform-browser'; +import {HTTP_PROVIDERS} from '@angular/http'; +import {ROUTER_PROVIDERS} from '@angular/router'; +import {provide} from '@angular/core'; +import {Renderer} from '@angular/core'; + +import {OVERLAY_CONTAINER_TOKEN} from '@angular2-material/core/overlay/overlay'; +import {MdLiveAnnouncer} from '@angular2-material/core/live-announcer/live-announcer'; +import {createOverlayContainer} from '@angular2-material/core/overlay/overlay-container'; +import {MdGestureConfig} from '@angular2-material/core/gestures/MdGestureConfig'; +import {MdIconRegistry} from '@angular2-material/icon/icon-registry'; + +import {E2EApp} from './e2e-app/e2e-app'; + +bootstrap(E2EApp, [ + ROUTER_PROVIDERS, + MdLiveAnnouncer, + provide(OVERLAY_CONTAINER_TOKEN, {useValue: createOverlayContainer()}), + HTTP_PROVIDERS, + MdIconRegistry, + Renderer, + provide(HAMMER_GESTURE_CONFIG, {useClass: MdGestureConfig}) +]); diff --git a/src/e2e-app/system-config.ts b/src/e2e-app/system-config.ts new file mode 100644 index 00000000000..d310607fd98 --- /dev/null +++ b/src/e2e-app/system-config.ts @@ -0,0 +1,89 @@ +/*********************************************************************************************** + * User Configuration. + **********************************************************************************************/ + +System.defaultJSExtensions = true; + + +const components = [ + 'button', + 'card', + 'checkbox', + 'grid-list', + 'icon', + 'input', + 'list', + 'progress-bar', + 'progress-circle', + 'radio', + 'sidenav', + 'slide-toggle', + 'tab-group', + 'toolbar' +]; + + +/** Map relative paths to URLs. */ +const map: any = { + '@angular2-material/core': '/core', +}; +components.forEach(name => map[`@angular2-material/${name}`] = `/components/${name}`); + + +/** User packages configuration. */ +const packages: any = { + '@angular2-material/core': { + format: 'cjs', + defaultExtension: 'js' + } +}; +components.forEach(name => { + packages[`@angular2-material/${name}`] = { + format: 'cjs', + defaultExtension: 'js' + }; +}); + +//////////////////////////////////////////////////////////////////////////////////////////////// +/*********************************************************************************************** + * Everything underneath this line is managed by the CLI. + **********************************************************************************************/ +const barrels: string[] = [ + // Angular specific barrels. + '@angular/core', + '@angular/common', + '@angular/compiler', + '@angular/http', + '@angular/router', + '@angular/platform-browser', + '@angular/platform-browser-dynamic', + + // Thirdparty barrels. + 'rxjs', + + // App specific barrels. + 'app', + 'app/shared', + /** @cli-barrel */ +]; + +const _cliSystemConfig = {}; +barrels.forEach((barrelName: string) => { + ( _cliSystemConfig)[barrelName] = { main: 'index' }; +}); + +/** Type declaration for ambient System. */ +declare var System: any; + +// Apply the CLI SystemJS configuration. +System.config({ + map: { + '@angular': 'vendor/@angular', + 'rxjs': 'vendor/rxjs', + 'main': 'main.js' + }, + packages: _cliSystemConfig +}); + +// Apply the user's configuration. +System.config({ map, packages }); diff --git a/src/e2e-app/tsconfig.json b/src/e2e-app/tsconfig.json new file mode 100644 index 00000000000..e5e1c4d8eea --- /dev/null +++ b/src/e2e-app/tsconfig.json @@ -0,0 +1,33 @@ +{ + "compilerOptions": { + "declaration": true, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "mapRoot": "", + "module": "commonjs", + "moduleResolution": "node", + "noEmitOnError": true, + "noImplicitAny": true, + "outDir": "../../dist/", + "rootDir": "..", + "sourceMap": true, + "target": "es5", + "inlineSources": true, + "stripInternal": true, + "baseUrl": "", + "paths": { + "@angular2-material/core/*": [ + "./core/*", + "../core/*" + ], + "@angular2-material/*": [ + "./components/*", + "../components/*" + ] + } + }, + "files": [ + "main.ts", + "typings.d.ts" + ] +} diff --git a/src/e2e-app/typings.d.ts b/src/e2e-app/typings.d.ts new file mode 100644 index 00000000000..3e0714ab420 --- /dev/null +++ b/src/e2e-app/typings.d.ts @@ -0,0 +1,4 @@ +/// + +declare var module: { id: string }; + diff --git a/test/packages b/test/packages deleted file mode 120000 index a16c4050155..00000000000 --- a/test/packages +++ /dev/null @@ -1 +0,0 @@ -../packages \ No newline at end of file diff --git a/test/protractor.conf.js b/test/protractor.conf.js index 5286336d8ea..9eafc3b9e31 100644 --- a/test/protractor.conf.js +++ b/test/protractor.conf.js @@ -1,7 +1,11 @@ +const fs = require('fs'); const path = require('path'); -/** Setup TypeScript for our tests. */ -require('ts-node/register'); +// Load ts-node to be able to execute TypeScript files with protractor. +require('ts-node').register({ + project: path.join(__dirname, '../e2e/') +}); + const E2E_BASE_URL = process.env['E2E_BASE_URL'] || 'http://localhost:4200'; const config = {