build: convert examples package to bazel (#28733)

* build: switch example e2e tests to bazel

* No longer builds the example e2e tests using "tsc". The examples are now built with Bazel and can therefore be built with Ivy by using the `--define=compile=aot` switch.
* No longer runs the example e2e tests using the protractor CLI. example e2e tests are executed with the Bazel protractor rule and can therefore run incrementally.

* test: disable failing ivy example e2e tests

*Note for patch branch:* We had to disable more examples in Ivy because
the patch branch does not contain all Ivy/ngtsc fixes.
This commit is contained in:
Paul Gschwendtner
2019-02-15 00:25:00 +01:00
committed by Miško Hevery
parent b6dffa9763
commit ac6b2b4dc3
103 changed files with 1049 additions and 521 deletions

View File

@ -0,0 +1,14 @@
package(default_visibility = ["//visibility:public"])
load("//packages/examples/upgrade:upgrade_example.bzl", "create_upgrade_example_targets")
create_upgrade_example_targets(
name = "full",
srcs = glob(
["**/*.ts"],
exclude = ["**/*_spec.ts"],
),
assets = ["styles.css"],
e2e_srcs = glob(["e2e_test/*_spec.ts"]),
entry_module = "@angular/examples/upgrade/static/ts/full/module",
)

View File

@ -6,48 +6,52 @@
* found in the LICENSE file at https://angular.io/license
*/
import {fixmeIvy} from '@angular/private/testing';
import {browser, by, element} from 'protractor';
import {verifyNoBrowserErrors} from '../../../../../_common/e2e_util';
import {verifyNoBrowserErrors} from '../../../../../test-utils';
function loadPage() {
browser.rootEl = 'example-app';
browser.get('/upgrade/static/ts/full/');
browser.get('/');
}
describe('upgrade/static (full)', () => {
beforeEach(loadPage);
afterEach(verifyNoBrowserErrors);
fixmeIvy('Disabled because the patch branch does not contain all Ivy fixes.')
.describe('upgrade/static (full)', () => {
beforeEach(loadPage);
afterEach(verifyNoBrowserErrors);
it('should render the `ng2-heroes` component', () => {
expect(element(by.css('h1')).getText()).toEqual('Heroes');
expect(element.all(by.css('p')).get(0).getText()).toEqual('There are 3 heroes.');
});
it('should render the `ng2-heroes` component', () => {
expect(element(by.css('h1')).getText()).toEqual('Heroes');
expect(element.all(by.css('p')).get(0).getText()).toEqual('There are 3 heroes.');
});
it('should render 3 ng1-hero components', () => {
const heroComponents = element.all(by.css('ng1-hero'));
expect(heroComponents.count()).toEqual(3);
});
it('should render 3 ng1-hero components', () => {
const heroComponents = element.all(by.css('ng1-hero'));
expect(heroComponents.count()).toEqual(3);
});
it('should add a new hero when the "Add Hero" button is pressed', () => {
const addHeroButton = element.all(by.css('button')).last();
expect(addHeroButton.getText()).toEqual('Add Hero');
addHeroButton.click();
const heroComponents = element.all(by.css('ng1-hero'));
expect(heroComponents.last().element(by.css('h2')).getText()).toEqual('Kamala Khan');
});
fixmeIvy('unknown; <ng1Hero> component does not seem to render name & description')
.it('should add a new hero when the "Add Hero" button is pressed', () => {
const addHeroButton = element.all(by.css('button')).last();
expect(addHeroButton.getText()).toEqual('Add Hero');
addHeroButton.click();
const heroComponents = element.all(by.css('ng1-hero'));
expect(heroComponents.last().element(by.css('h2')).getText()).toEqual('Kamala Khan');
});
it('should remove a hero when the "Remove" button is pressed', () => {
let firstHero = element.all(by.css('ng1-hero')).get(0);
expect(firstHero.element(by.css('h2')).getText()).toEqual('Superman');
fixmeIvy('unknown; <ng1Hero> component does not seem to render name & description')
.it('should remove a hero when the "Remove" button is pressed', () => {
let firstHero = element.all(by.css('ng1-hero')).get(0);
expect(firstHero.element(by.css('h2')).getText()).toEqual('Superman');
const removeHeroButton = firstHero.element(by.css('button'));
expect(removeHeroButton.getText()).toEqual('Remove');
removeHeroButton.click();
const removeHeroButton = firstHero.element(by.css('button'));
expect(removeHeroButton.getText()).toEqual('Remove');
removeHeroButton.click();
const heroComponents = element.all(by.css('ng1-hero'));
expect(heroComponents.count()).toEqual(2);
const heroComponents = element.all(by.css('ng1-hero'));
expect(heroComponents.count()).toEqual(2);
firstHero = element.all(by.css('ng1-hero')).get(0);
expect(firstHero.element(by.css('h2')).getText()).toEqual('Wonder Woman');
});
});
firstHero = element.all(by.css('ng1-hero')).get(0);
expect(firstHero.element(by.css('h2')).getText()).toEqual('Wonder Woman');
});
});

View File

@ -0,0 +1,13 @@
package(default_visibility = ["//visibility:public"])
load("//packages/examples/upgrade:upgrade_example.bzl", "create_upgrade_example_targets")
create_upgrade_example_targets(
name = "lite-multi-shared",
srcs = glob(
["**/*.ts"],
exclude = ["**/*_spec.ts"],
),
e2e_srcs = glob(["e2e_test/*_spec.ts"]),
entry_module = "@angular/examples/upgrade/static/ts/lite-multi-shared/module",
)

View File

@ -8,7 +8,7 @@
import {browser, by, element} from 'protractor';
import {verifyNoBrowserErrors} from '../../../../../_common/e2e_util';
import {verifyNoBrowserErrors} from '../../../../../test-utils';
describe('upgrade/static (lite with multiple downgraded modules and shared root module)', () => {
@ -16,7 +16,7 @@ describe('upgrade/static (lite with multiple downgraded modules and shared root
const compB = element(by.css('ng2-b'));
const compC = element(by.css('ng2-c'));
beforeEach(() => browser.get('/upgrade/static/ts/lite-multi-shared/'));
beforeEach(() => browser.get('/'));
afterEach(verifyNoBrowserErrors);
it('should share the same injectable instance across downgraded modules A and B', () => {

View File

@ -0,0 +1,13 @@
package(default_visibility = ["//visibility:public"])
load("//packages/examples/upgrade:upgrade_example.bzl", "create_upgrade_example_targets")
create_upgrade_example_targets(
name = "lite-multi",
srcs = glob(
["**/*.ts"],
exclude = ["**/*_spec.ts"],
),
e2e_srcs = glob(["e2e_test/*_spec.ts"]),
entry_module = "@angular/examples/upgrade/static/ts/lite-multi/module",
)

View File

@ -8,14 +8,14 @@
import {browser, by, element} from 'protractor';
import {verifyNoBrowserErrors} from '../../../../../_common/e2e_util';
import {verifyNoBrowserErrors} from '../../../../../test-utils';
describe('upgrade/static (lite with multiple downgraded modules)', () => {
const navButtons = element.all(by.css('nav button'));
const mainContent = element(by.css('main'));
beforeEach(() => browser.get('/upgrade/static/ts/lite-multi/'));
beforeEach(() => browser.get('/'));
afterEach(verifyNoBrowserErrors);
it('should correctly bootstrap multiple downgraded modules', () => {

View File

@ -0,0 +1,14 @@
package(default_visibility = ["//visibility:public"])
load("//packages/examples/upgrade:upgrade_example.bzl", "create_upgrade_example_targets")
create_upgrade_example_targets(
name = "lite",
srcs = glob(
["**/*.ts"],
exclude = ["e2e_test/*"],
),
assets = ["styles.css"],
e2e_srcs = glob(["e2e_test/*.ts"]),
entry_module = "@angular/examples/upgrade/static/ts/lite/module",
)

View File

@ -6,14 +6,15 @@
* found in the LICENSE file at https://angular.io/license
*/
import {fixmeIvy} from '@angular/private/testing';
import {ElementArrayFinder, ElementFinder, browser, by, element} from 'protractor';
import {verifyNoBrowserErrors} from '../../../../../test-utils';
import {verifyNoBrowserErrors} from '../../../../../_common/e2e_util';
import {addCustomMatchers} from './e2e_util';
function loadPage() {
browser.rootEl = 'example-app';
browser.get('/upgrade/static/ts/lite/');
browser.get('/');
}
describe('upgrade/static (lite)', () => {
@ -58,32 +59,35 @@ describe('upgrade/static (lite)', () => {
it('should initially not render the heroes', () => expectHeroes(false));
it('should toggle the heroes when clicking the "show/hide" button', () => {
showHideBtn.click();
expectHeroes(true);
fixmeIvy('unknown; <ng1Hero> component does not seem to render name & description')
.it('should toggle the heroes when clicking the "show/hide" button', () => {
showHideBtn.click();
expectHeroes(true);
showHideBtn.click();
expectHeroes(false);
});
showHideBtn.click();
expectHeroes(false);
});
it('should add a new hero when clicking the "add" button', () => {
showHideBtn.click();
ng2HeroesAddBtn.click();
fixmeIvy('unknown; <ng1Hero> component does not seem to render name & description')
.it('should add a new hero when clicking the "add" button', () => {
showHideBtn.click();
ng2HeroesAddBtn.click();
expectHeroes(true, 4, 'Added hero Kamala Khan');
expect(ng1Heroes.last()).toHaveName('Kamala Khan');
});
expectHeroes(true, 4, 'Added hero Kamala Khan');
expect(ng1Heroes.last()).toHaveName('Kamala Khan');
});
it('should remove a hero when clicking its "remove" button', () => {
showHideBtn.click();
fixmeIvy('unknown; <ng1Hero> component does not seem to render name & description')
.it('should remove a hero when clicking its "remove" button', () => {
showHideBtn.click();
const firstHero = ng1Heroes.first();
expect(firstHero).toHaveName('Superman');
const firstHero = ng1Heroes.first();
expect(firstHero).toHaveName('Superman');
const removeBtn = firstHero.element(by.buttonText('Remove'));
removeBtn.click();
const removeBtn = firstHero.element(by.buttonText('Remove'));
removeBtn.click();
expectHeroes(true, 2, 'Removed hero Superman');
expect(ng1Heroes.first()).not.toHaveName('Superman');
});
expectHeroes(true, 2, 'Removed hero Superman');
expect(ng1Heroes.first()).not.toHaveName('Superman');
});
});