build: run playground e2e examples with bazel (#28490)

PR Close #28490
This commit is contained in:
Paul Gschwendtner 2019-02-01 14:46:38 +01:00 committed by Matias Niemelä
parent 5a257d02a6
commit ee74835619
44 changed files with 258 additions and 34 deletions

View File

@ -21,7 +21,7 @@ ts_library(
"largetable_perf.spec.ts",
],
deps = [
"//modules/e2e_util:lib",
"//modules/e2e_util",
"//packages:types",
"@ngdeps//protractor",
],

View File

@ -21,7 +21,7 @@ ts_library(
"tree_perf.spec.ts",
],
deps = [
"//modules/e2e_util:lib",
"//modules/e2e_util",
"//packages:types",
"@ngdeps//protractor",
],

View File

@ -3,7 +3,7 @@ package(default_visibility = ["//visibility:public"])
load("//tools:defaults.bzl", "ts_library")
ts_library(
name = "lib",
name = "e2e_util",
testonly = 1,
srcs = glob(["*.ts"]),
deps = [

View File

@ -0,0 +1 @@
exports_files(["start-server.js"])

View File

@ -0,0 +1,7 @@
load("//modules/playground/e2e_test:example_test.bzl", "example_test")
example_test(
name = "async",
srcs = glob(["**/*.ts"]),
server = "//modules/playground/src/async:devserver",
)

View File

@ -6,12 +6,13 @@
* found in the LICENSE file at https://angular.io/license
*/
import {verifyNoBrowserErrors} from 'e2e_util/e2e_util';
import {$, browser} from 'protractor';
import {promise} from 'selenium-webdriver';
import {verifyNoBrowserErrors} from '../../../e2e_util/e2e_util';
describe('async', () => {
const URL = 'all/playground/src/async/index.html';
const URL = '/';
beforeEach(() => browser.get(URL));

View File

@ -0,0 +1,31 @@
load("//packages/bazel:index.bzl", "protractor_web_test_suite")
load("//tools:defaults.bzl", "ts_library")
def example_test(name, srcs, server, data = []):
ts_library(
name = "%s_lib" % name,
testonly = True,
srcs = srcs,
tsconfig = "//modules/playground:tsconfig-e2e.json",
deps = [
"//modules/e2e_util",
"//packages/private/testing",
"@ngdeps//@types/jasminewd2",
"@ngdeps//@types/selenium-webdriver",
"@ngdeps//protractor",
],
)
protractor_web_test_suite(
name = "protractor_tests",
data = ["//packages/bazel/src/protractor/utils"] + data,
on_prepare = "//modules/playground/e2e_test:start-server.js",
server = server,
deps = [
":%s_lib" % name,
"@ngdeps//protractor",
"@ngdeps//selenium-webdriver",
"@ngdeps//yargs",
"@ngdeps//source-map",
],
)

View File

@ -0,0 +1,7 @@
load("//modules/playground/e2e_test:example_test.bzl", "example_test")
example_test(
name = "hello_world",
srcs = glob(["**/*.ts"]),
server = "//modules/playground/src/hello_world:devserver",
)

View File

@ -14,7 +14,7 @@ describe('hello world', function() {
afterEach(verifyNoBrowserErrors);
describe('hello world app', function() {
const URL = 'all/playground/src/hello_world/index.html';
const URL = '/';
it('should greet', function() {
browser.get(URL);

View File

@ -0,0 +1,7 @@
load("//modules/playground/e2e_test:example_test.bzl", "example_test")
example_test(
name = "http",
srcs = glob(["**/*.ts"]),
server = "//modules/playground/src/http:devserver",
)

View File

@ -6,15 +6,16 @@
* found in the LICENSE file at https://angular.io/license
*/
import {verifyNoBrowserErrors} from 'e2e_util/e2e_util';
import {browser} from 'protractor';
import {verifyNoBrowserErrors} from '../../../e2e_util/e2e_util';
describe('http', function() {
afterEach(verifyNoBrowserErrors);
describe('fetching', function() {
const URL = 'all/playground/src/http/index.html';
const URL = '/';
it('should fetch and display people', function() {
browser.get(URL);

View File

@ -0,0 +1,7 @@
load("//modules/playground/e2e_test:example_test.bzl", "example_test")
example_test(
name = "jsonp",
srcs = glob(["**/*.ts"]),
server = "//modules/playground/src/jsonp:devserver",
)

View File

@ -6,15 +6,16 @@
* found in the LICENSE file at https://angular.io/license
*/
import {verifyNoBrowserErrors} from 'e2e_util/e2e_util';
import {browser} from 'protractor';
import {verifyNoBrowserErrors} from '../../../e2e_util/e2e_util';
describe('jsonp', function() {
afterEach(verifyNoBrowserErrors);
describe('fetching', function() {
const URL = 'all/playground/src/jsonp/index.html';
const URL = '/';
it('should fetch and display people', function() {
browser.get(URL);

View File

@ -0,0 +1,7 @@
load("//modules/playground/e2e_test:example_test.bzl", "example_test")
example_test(
name = "key_events",
srcs = glob(["**/*.ts"]),
server = "//modules/playground/src/key_events:devserver",
)

View File

@ -6,14 +6,15 @@
* found in the LICENSE file at https://angular.io/license
*/
import {verifyNoBrowserErrors} from 'e2e_util/e2e_util';
import {browser, by, element, protractor} from 'protractor';
import {verifyNoBrowserErrors} from '../../../e2e_util/e2e_util';
const Key = protractor.Key;
describe('key_events', function() {
const URL = 'all/playground/src/key_events/index.html';
const URL = '/';
afterEach(verifyNoBrowserErrors);
beforeEach(() => { browser.get(URL); });

View File

@ -0,0 +1,7 @@
load("//modules/playground/e2e_test:example_test.bzl", "example_test")
example_test(
name = "model_driven_forms",
srcs = glob(["**/*.ts"]),
server = "//modules/playground/src/model_driven_forms:devserver",
)

View File

@ -6,14 +6,15 @@
* found in the LICENSE file at https://angular.io/license
*/
import {verifyNoBrowserErrors} from 'e2e_util/e2e_util';
import {browser, by, element} from 'protractor';
import {verifyNoBrowserErrors} from '../../../e2e_util/e2e_util';
describe('Model-Driven Forms', function() {
afterEach(verifyNoBrowserErrors);
const URL = 'all/playground/src/model_driven_forms/index.html';
const URL = '/';
it('should display errors', function() {
browser.get(URL);

View File

@ -0,0 +1,7 @@
load("//modules/playground/e2e_test:example_test.bzl", "example_test")
example_test(
name = "order_management",
srcs = glob(["**/*.ts"]),
server = "//modules/playground/src/order_management:devserver",
)

View File

@ -6,11 +6,12 @@
* found in the LICENSE file at https://angular.io/license
*/
import {verifyNoBrowserErrors} from 'e2e_util/e2e_util';
import {browser} from 'protractor';
import {verifyNoBrowserErrors} from '../../../e2e_util/e2e_util';
describe('Order Management CRUD', function() {
const URL = 'all/playground/src/order_management/index.html';
const URL = '/';
it('should work', function() {
browser.get(URL);

View File

@ -0,0 +1,7 @@
load("//modules/playground/e2e_test:example_test.bzl", "example_test")
example_test(
name = "person_management",
srcs = glob(["**/*.ts"]),
server = "//modules/playground/src/person_management:devserver",
)

View File

@ -6,11 +6,12 @@
* found in the LICENSE file at https://angular.io/license
*/
import {verifyNoBrowserErrors} from 'e2e_util/e2e_util';
import {browser} from 'protractor';
import {verifyNoBrowserErrors} from '../../../e2e_util/e2e_util';
describe('Person Management CRUD', function() {
const URL = 'all/playground/src/person_management/index.html';
const URL = '/';
it('should work', function() {
browser.get(URL);

View File

@ -0,0 +1,7 @@
load("//modules/playground/e2e_test:example_test.bzl", "example_test")
example_test(
name = "relative_assets",
srcs = glob(["**/*.ts"]),
server = "//modules/playground/src/relative_assets:devserver",
)

View File

@ -6,9 +6,10 @@
* found in the LICENSE file at https://angular.io/license
*/
import {verifyNoBrowserErrors} from 'e2e_util/e2e_util';
import {$, ExpectedConditions, browser, by, element} from 'protractor';
import {verifyNoBrowserErrors} from '../../../e2e_util/e2e_util';
function waitForElement(selector: string) {
// Waits for the element with id 'abc' to be present on the dom.
browser.wait(ExpectedConditions.presenceOf($(selector)), 20000);
@ -18,7 +19,7 @@ describe('relative assets relative-app', () => {
afterEach(verifyNoBrowserErrors);
const URL = 'all/playground/src/relative_assets/';
const URL = '/';
it('should load in the templateUrl relative to the my-cmp component', () => {
browser.get(URL);

View File

@ -0,0 +1,7 @@
load("//modules/playground/e2e_test:example_test.bzl", "example_test")
example_test(
name = "routing",
srcs = glob(["**/*.ts"]),
server = "//modules/playground/src/routing:devserver",
)

View File

@ -6,9 +6,10 @@
* found in the LICENSE file at https://angular.io/license
*/
import {verifyNoBrowserErrors} from 'e2e_util/e2e_util';
import {$, ExpectedConditions, browser, by, element} from 'protractor';
import {verifyNoBrowserErrors} from '../../../e2e_util/e2e_util';
function waitForElement(selector: string) {
// Waits for the element with id 'abc' to be present on the dom.
browser.wait(ExpectedConditions.presenceOf($(selector)), 20000);
@ -19,7 +20,7 @@ describe('routing inbox-app', () => {
afterEach(verifyNoBrowserErrors);
describe('index view', () => {
const URL = 'all/playground/src/routing/';
const URL = '/';
it('should list out the current collection of items', () => {
browser.get(URL);

View File

@ -0,0 +1,11 @@
load("//modules/playground/e2e_test:example_test.bzl", "example_test")
example_test(
name = "sourcemap",
srcs = glob(["**/*.ts"]),
data = [
"//modules/playground/src/sourcemap",
"//modules/playground/src/sourcemap:index.ts",
],
server = "//modules/playground/src/sourcemap:devserver",
)

View File

@ -13,7 +13,7 @@ const fs = require('fs');
const sourceMap = require('source-map');
describe('sourcemaps', function() {
const URL = 'all/playground/src/sourcemap/index.html';
const URL = '/';
it('should map sources', function() {
browser.get(URL);
@ -36,7 +36,7 @@ describe('sourcemaps', function() {
const content =
fs.readFileSync('dist/all/playground/src/sourcemap/index.js').toString('utf8');
fs.readFileSync(require.resolve('../../src/sourcemap/index.js')).toString('utf8');
const marker = '//# sourceMappingURL=data:application/json;base64,';
const index = content.indexOf(marker);
const sourceMapData =
@ -46,7 +46,7 @@ describe('sourcemaps', function() {
const originalPosition = decoder.originalPositionFor({line: errorLine, column: errorColumn});
const sourceCodeLines = fs.readFileSync('modules/playground/src/sourcemap/index.ts', {
const sourceCodeLines = fs.readFileSync(require.resolve('../../src/sourcemap/index.ts'), {
encoding: 'UTF-8'
}).split('\n');
expect(sourceCodeLines[originalPosition.line - 1])

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
const protractorUtils = require('@angular/bazel/protractor-utils');
const protractor = require('protractor');
module.exports = async function(config) {
const {port} = await protractorUtils.runServer(config.workspace, config.server, '-port', []);
const serverUrl = `http://localhost:${port}`;
protractor.browser.baseUrl = serverUrl;
};

View File

@ -0,0 +1,7 @@
load("//modules/playground/e2e_test:example_test.bzl", "example_test")
example_test(
name = "svg",
srcs = glob(["**/*.ts"]),
server = "//modules/playground/src/svg:devserver",
)

View File

@ -6,12 +6,13 @@
* found in the LICENSE file at https://angular.io/license
*/
import {verifyNoBrowserErrors} from 'e2e_util/e2e_util';
import {browser, by, element} from 'protractor';
import {verifyNoBrowserErrors} from '../../../e2e_util/e2e_util';
describe('SVG', function() {
const URL = 'all/playground/src/svg/index.html';
const URL = '/';
afterEach(verifyNoBrowserErrors);
beforeEach(() => { browser.get(URL); });

View File

@ -0,0 +1,7 @@
load("//modules/playground/e2e_test:example_test.bzl", "example_test")
example_test(
name = "template_driven_forms",
srcs = glob(["**/*.ts"]),
server = "//modules/playground/src/template_driven_forms:devserver",
)

View File

@ -6,14 +6,15 @@
* found in the LICENSE file at https://angular.io/license
*/
import {verifyNoBrowserErrors} from 'e2e_util/e2e_util';
import {browser, by, element} from 'protractor';
import {verifyNoBrowserErrors} from '../../../e2e_util/e2e_util';
describe('Template-Driven Forms', function() {
afterEach(verifyNoBrowserErrors);
const URL = 'all/playground/src/template_driven_forms/index.html';
const URL = '/';
it('should display errors', function() {
browser.get(URL);

View File

@ -0,0 +1,7 @@
load("//modules/playground/e2e_test:example_test.bzl", "example_test")
example_test(
name = "upgrade",
srcs = glob(["**/*.ts"]),
server = "//modules/playground/src/upgrade:devserver",
)

View File

@ -0,0 +1,7 @@
load("//modules/playground/e2e_test:example_test.bzl", "example_test")
example_test(
name = "animations",
srcs = glob(["**/*.ts"]),
server = "//modules/playground/src/web_workers/animations:devserver",
)

View File

@ -6,10 +6,13 @@
* found in the LICENSE file at https://angular.io/license
*/
import {verifyNoBrowserErrors} from 'e2e_util/e2e_util';
import {browser, by, element, protractor} from 'protractor';
// TODO(matsko): make this test work again with new view engine.
import {verifyNoBrowserErrors} from '../../../../e2e_util/e2e_util';
// Disabled because with ViewEngine animations within webworkers is not supported.
// See: https://github.com/angular/angular/issues/18610
xdescribe('WebWorkers Animations', function() {
afterEach(() => {
verifyNoBrowserErrors();

View File

@ -0,0 +1,7 @@
load("//modules/playground/e2e_test:example_test.bzl", "example_test")
example_test(
name = "input",
srcs = glob(["**/*.ts"]),
server = "//modules/playground/src/web_workers/input:devserver",
)

View File

@ -0,0 +1,7 @@
load("//modules/playground/e2e_test:example_test.bzl", "example_test")
example_test(
name = "kitchen_sink",
srcs = glob(["**/*.ts"]),
server = "//modules/playground/src/web_workers/kitchen_sink:devserver",
)

View File

@ -0,0 +1,7 @@
load("//modules/playground/e2e_test:example_test.bzl", "example_test")
example_test(
name = "message_broker",
srcs = glob(["**/*.ts"]),
server = "//modules/playground/src/web_workers/message_broker:devserver",
)

View File

@ -0,0 +1,7 @@
load("//modules/playground/e2e_test:example_test.bzl", "example_test")
example_test(
name = "router",
srcs = glob(["**/*.ts"]),
server = "//modules/playground/src/web_workers/router:devserver",
)

View File

@ -0,0 +1,7 @@
load("//modules/playground/e2e_test:example_test.bzl", "example_test")
example_test(
name = "todo",
srcs = glob(["**/*.ts"]),
server = "//modules/playground/src/web_workers/todo:devserver",
)

View File

@ -0,0 +1,7 @@
load("//modules/playground/e2e_test:example_test.bzl", "example_test")
example_test(
name = "zippy_component",
srcs = glob(["**/*.ts"]),
server = "//modules/playground/src/zippy_component:devserver",
)

View File

@ -6,15 +6,16 @@
* found in the LICENSE file at https://angular.io/license
*/
import {verifyNoBrowserErrors} from 'e2e_util/e2e_util';
import {browser, by, element} from 'protractor';
import {verifyNoBrowserErrors} from '../../../e2e_util/e2e_util';
describe('Zippy Component', function() {
afterEach(verifyNoBrowserErrors);
describe('zippy', function() {
const URL = 'all/playground/src/zippy_component/index.html';
const URL = '/';
beforeEach(function() { browser.get(URL); });

View File

@ -0,0 +1,6 @@
{
"compilerOptions": {
"lib": ["es2015", "dom"],
"types": ["node", "jasminewd2", "selenium-webdriver"]
}
}

View File

@ -1,4 +1,7 @@
package(default_visibility = ["//packages:__subpackages__"])
package(default_visibility = [
"//modules/playground:__subpackages__",
"//packages:__subpackages__",
])
exports_files(["package.json"])