fix(ivy): WorkerAppModule should be an APP_ROOT (#28544)

PR Close #28544
This commit is contained in:
Marc Laval 2019-02-05 17:14:18 +01:00 committed by Matias Niemelä
parent e3032a0d17
commit 43081a01d8
6 changed files with 161 additions and 169 deletions

View File

@ -6,73 +6,70 @@
* found in the LICENSE file at https://angular.io/license
*/
import {fixmeIvy} from '@angular/private/testing';
import {ExpectedConditions, browser, by, element, protractor} from 'protractor';
import {verifyNoBrowserErrors} from '../../../../e2e_util/e2e_util';
fixmeIvy('NullInjectorError: No provider for InjectionToken ROOT_CONTEXT_TOKEN!')
.describe('WebWorkers Input', function() {
afterEach(() => {
verifyNoBrowserErrors();
browser.ignoreSynchronization = false;
});
const selector = 'input-app';
const URL = '/';
const VALUE = 'test val';
describe('WebWorkers Input', function() {
afterEach(() => {
verifyNoBrowserErrors();
browser.ignoreSynchronization = false;
});
const selector = 'input-app';
const URL = '/';
const VALUE = 'test val';
it('should bootstrap', () => {
// This test can't wait for Angular as Testability is not available when using WebWorker
browser.ignoreSynchronization = true;
browser.get(URL);
it('should bootstrap', () => {
// This test can't wait for Angular as Testability is not available when using WebWorker
browser.ignoreSynchronization = true;
browser.get(URL);
waitForBootstrap();
const elem = element(by.css(selector + ' h2'));
expect(elem.getText()).toEqual('Input App');
});
waitForBootstrap();
const elem = element(by.css(selector + ' h2'));
expect(elem.getText()).toEqual('Input App');
});
it('should bind to input value', () => {
// This test can't wait for Angular as Testability is not available when using WebWorker
browser.ignoreSynchronization = true;
browser.get(URL);
it('should bind to input value', () => {
// This test can't wait for Angular as Testability is not available when using WebWorker
browser.ignoreSynchronization = true;
browser.get(URL);
waitForBootstrap();
const input = element(by.css(selector + ' input'));
input.sendKeys(VALUE);
const displayElem = element(by.css(selector + ' .input-val'));
const expectedVal = `Input val is ${VALUE}.`;
browser.wait(ExpectedConditions.textToBePresentInElement(displayElem, expectedVal), 5000);
expect(displayElem.getText()).toEqual(expectedVal);
});
waitForBootstrap();
const input = element(by.css(selector + ' input'));
input.sendKeys(VALUE);
const displayElem = element(by.css(selector + ' .input-val'));
const expectedVal = `Input val is ${VALUE}.`;
browser.wait(ExpectedConditions.textToBePresentInElement(displayElem, expectedVal), 5000);
expect(displayElem.getText()).toEqual(expectedVal);
});
it('should bind to textarea value', () => {
// This test can't wait for Angular as Testability is not available when using WebWorker
browser.ignoreSynchronization = true;
browser.get(URL);
it('should bind to textarea value', () => {
// This test can't wait for Angular as Testability is not available when using WebWorker
browser.ignoreSynchronization = true;
browser.get(URL);
waitForBootstrap();
const input = element(by.css(selector + ' textarea'));
input.sendKeys(VALUE);
const displayElem = element(by.css(selector + ' .textarea-val'));
const expectedVal = `Textarea val is ${VALUE}.`;
browser.wait(ExpectedConditions.textToBePresentInElement(displayElem, expectedVal), 5000);
expect(displayElem.getText()).toEqual(expectedVal);
});
waitForBootstrap();
const input = element(by.css(selector + ' textarea'));
input.sendKeys(VALUE);
const displayElem = element(by.css(selector + ' .textarea-val'));
const expectedVal = `Textarea val is ${VALUE}.`;
browser.wait(ExpectedConditions.textToBePresentInElement(displayElem, expectedVal), 5000);
expect(displayElem.getText()).toEqual(expectedVal);
});
function waitForBootstrap() {
browser.wait(protractor.until.elementLocated(by.css(selector + ' h2')), 5000)
.then(
() => {
const elem = element(by.css(selector + ' h2'));
browser.wait(
protractor.ExpectedConditions.textToBePresentInElement(elem, 'Input App'),
5000);
},
() => {
// jasmine will timeout if this gets called too many times
console.error('>> unexpected timeout -> browser.refresh()');
browser.refresh();
waitForBootstrap();
});
}
});
function waitForBootstrap() {
browser.wait(protractor.until.elementLocated(by.css(selector + ' h2')), 5000)
.then(
() => {
const elem = element(by.css(selector + ' h2'));
browser.wait(
protractor.ExpectedConditions.textToBePresentInElement(elem, 'Input App'), 5000);
},
() => {
// jasmine will timeout if this gets called too many times
console.error('>> unexpected timeout -> browser.refresh()');
browser.refresh();
waitForBootstrap();
});
}
});

View File

@ -11,7 +11,7 @@ import {ExpectedConditions, browser, by, element, protractor} from 'protractor';
import {verifyNoBrowserErrors} from '../../../../e2e_util/e2e_util';
fixmeIvy('NullInjectorError: No provider for InjectionToken ROOT_CONTEXT_TOKEN!')
fixmeIvy('FW-1032: Ivy doesn\'t support injecting Renderer, the deprecated renderer V1')
.describe('WebWorkers Kitchen Sink', function() {
afterEach(() => {
verifyNoBrowserErrors();

View File

@ -6,44 +6,42 @@
* found in the LICENSE file at https://angular.io/license
*/
import {fixmeIvy} from '@angular/private/testing';
import {ExpectedConditions, browser, by, element, protractor} from 'protractor';
import {verifyNoBrowserErrors} from '../../../../e2e_util/e2e_util';
const URL = '/';
fixmeIvy('NullInjectorError: No provider for InjectionToken ROOT_CONTEXT_TOKEN!')
.describe('MessageBroker', function() {
describe('MessageBroker', function() {
afterEach(() => {
verifyNoBrowserErrors();
browser.ignoreSynchronization = false;
});
afterEach(() => {
verifyNoBrowserErrors();
browser.ignoreSynchronization = false;
});
it('should bootstrap', () => {
// This test can't wait for Angular as Testability is not available when using WebWorker
browser.ignoreSynchronization = true;
browser.get(URL);
waitForBootstrap();
expect(element(by.css('app h1')).getText()).toEqual('WebWorker MessageBroker Test');
});
it('should bootstrap', () => {
// This test can't wait for Angular as Testability is not available when using WebWorker
browser.ignoreSynchronization = true;
browser.get(URL);
waitForBootstrap();
expect(element(by.css('app h1')).getText()).toEqual('WebWorker MessageBroker Test');
});
it('should echo messages', () => {
const VALUE = 'Hi There';
// This test can't wait for Angular as Testability is not available when using WebWorker
browser.ignoreSynchronization = true;
browser.get(URL);
waitForBootstrap();
it('should echo messages', () => {
const VALUE = 'Hi There';
// This test can't wait for Angular as Testability is not available when using WebWorker
browser.ignoreSynchronization = true;
browser.get(URL);
waitForBootstrap();
const input = element.all(by.css('#echo_input')).first();
input.sendKeys(VALUE);
element(by.css('#send_echo')).click();
const area = element(by.css('#echo_result'));
browser.wait(ExpectedConditions.textToBePresentInElement(area, VALUE), 5000);
expect(area.getText()).toEqual(VALUE);
});
});
const input = element.all(by.css('#echo_input')).first();
input.sendKeys(VALUE);
element(by.css('#send_echo')).click();
const area = element(by.css('#echo_result'));
browser.wait(ExpectedConditions.textToBePresentInElement(area, VALUE), 5000);
expect(area.getText()).toEqual(VALUE);
});
});
function waitForBootstrap(): void {
browser.wait(protractor.until.elementLocated(by.css('app h1')), 15000);

View File

@ -6,82 +6,80 @@
* found in the LICENSE file at https://angular.io/license
*/
import {fixmeIvy} from '@angular/private/testing';
import {browser, by, element, protractor} from 'protractor';
import {verifyNoBrowserErrors} from '../../../../e2e_util/e2e_util';
fixmeIvy('NullInjectorError: No provider for InjectionToken ROOT_CONTEXT_TOKEN!')
.describe('WebWorker Router', () => {
beforeEach(() => {
// This test can't wait for Angular as Testability is not available when using WebWorker
browser.ignoreSynchronization = true;
browser.get('/');
});
describe('WebWorker Router', () => {
beforeEach(() => {
// This test can't wait for Angular as Testability is not available when using WebWorker
browser.ignoreSynchronization = true;
browser.get('/');
});
afterEach(() => {
verifyNoBrowserErrors();
browser.ignoreSynchronization = false;
});
afterEach(() => {
verifyNoBrowserErrors();
browser.ignoreSynchronization = false;
});
const contentSelector = 'app main h1';
const navSelector = 'app nav ul';
const baseUrl = '/';
const contentSelector = 'app main h1';
const navSelector = 'app nav ul';
const baseUrl = '/';
it('should route on click', () => {
browser.get(baseUrl);
it('should route on click', () => {
browser.get(baseUrl);
waitForElement(contentSelector);
let content = element(by.css(contentSelector));
expect(content.getText()).toEqual('Start');
waitForElement(contentSelector);
let content = element(by.css(contentSelector));
expect(content.getText()).toEqual('Start');
const aboutBtn = element(by.css(navSelector + ' .about'));
aboutBtn.click();
waitForUrl(/\/about/);
waitForElement(contentSelector);
waitForElementText(contentSelector, 'About');
content = element(by.css(contentSelector));
expect(content.getText()).toEqual('About');
expect(browser.getCurrentUrl()).toMatch(/\/about/);
const aboutBtn = element(by.css(navSelector + ' .about'));
aboutBtn.click();
waitForUrl(/\/about/);
waitForElement(contentSelector);
waitForElementText(contentSelector, 'About');
content = element(by.css(contentSelector));
expect(content.getText()).toEqual('About');
expect(browser.getCurrentUrl()).toMatch(/\/about/);
const contactBtn = element(by.css(navSelector + ' .contact'));
contactBtn.click();
waitForUrl(/\/contact/);
waitForElement(contentSelector);
waitForElementText(contentSelector, 'Contact');
content = element(by.css(contentSelector));
expect(content.getText()).toEqual('Contact');
expect(browser.getCurrentUrl()).toMatch(/\/contact/);
});
const contactBtn = element(by.css(navSelector + ' .contact'));
contactBtn.click();
waitForUrl(/\/contact/);
waitForElement(contentSelector);
waitForElementText(contentSelector, 'Contact');
content = element(by.css(contentSelector));
expect(content.getText()).toEqual('Contact');
expect(browser.getCurrentUrl()).toMatch(/\/contact/);
});
it('should load the correct route from the URL', () => {
browser.get(baseUrl + '#/about');
it('should load the correct route from the URL', () => {
browser.get(baseUrl + '#/about');
waitForElement(contentSelector);
waitForElementText(contentSelector, 'About');
const content = element(by.css(contentSelector));
expect(content.getText()).toEqual('About');
});
waitForElement(contentSelector);
waitForElementText(contentSelector, 'About');
const content = element(by.css(contentSelector));
expect(content.getText()).toEqual('About');
});
function waitForElement(selector: string): void {
browser.wait(protractor.until.elementLocated(by.css(selector)), 15000);
}
function waitForElement(selector: string): void {
browser.wait(protractor.until.elementLocated(by.css(selector)), 15000);
}
function waitForElementText(contentSelector: string, expected: string): void {
browser.wait(() => {
const deferred = protractor.promise.defer();
const elem = element(by.css(contentSelector));
elem.getText().then((text: string) => { return deferred.fulfill(text === expected); });
return deferred.promise;
}, 5000);
}
function waitForElementText(contentSelector: string, expected: string): void {
browser.wait(() => {
const deferred = protractor.promise.defer();
const elem = element(by.css(contentSelector));
elem.getText().then((text: string) => { return deferred.fulfill(text === expected); });
return deferred.promise;
}, 5000);
}
function waitForUrl(regex: RegExp): void {
browser.wait(() => {
const deferred = protractor.promise.defer();
browser.getCurrentUrl().then(
(url: string) => { return deferred.fulfill(url.match(regex) !== null); });
return deferred.promise;
}, 5000);
}
});
function waitForUrl(regex: RegExp): void {
browser.wait(() => {
const deferred = protractor.promise.defer();
browser.getCurrentUrl().then(
(url: string) => { return deferred.fulfill(url.match(regex) !== null); });
return deferred.promise;
}, 5000);
}
});

View File

@ -6,30 +6,28 @@
* found in the LICENSE file at https://angular.io/license
*/
import {fixmeIvy} from '@angular/private/testing';
import {browser, by, element, protractor} from 'protractor';
import {verifyNoBrowserErrors} from '../../../../e2e_util/e2e_util';
fixmeIvy('NullInjectorError: No provider for InjectionToken ROOT_CONTEXT_TOKEN!')
.describe('WebWorkers Todo', function() {
afterEach(() => {
verifyNoBrowserErrors();
browser.ignoreSynchronization = false;
});
describe('WebWorkers Todo', function() {
afterEach(() => {
verifyNoBrowserErrors();
browser.ignoreSynchronization = false;
});
const URL = '/';
const URL = '/';
it('should bootstrap', () => {
// This test can't wait for Angular as Testability is not available when using WebWorker
browser.ignoreSynchronization = true;
browser.get(URL);
it('should bootstrap', () => {
// This test can't wait for Angular as Testability is not available when using WebWorker
browser.ignoreSynchronization = true;
browser.get(URL);
waitForBootstrap();
expect(element(by.css('#todoapp header')).getText()).toEqual('todos');
});
waitForBootstrap();
expect(element(by.css('#todoapp header')).getText()).toEqual('todos');
});
});
});
function waitForBootstrap(): void {
browser.wait(protractor.until.elementLocated(by.css('todo-app #todoapp')), 15000);

View File

@ -7,7 +7,7 @@
*/
import {CommonModule, ViewportScroller, ɵNullViewportScroller as NullViewportScroller, ɵPLATFORM_WORKER_APP_ID as PLATFORM_WORKER_APP_ID} from '@angular/common';
import {APP_INITIALIZER, ApplicationModule, ErrorHandler, NgModule, NgZone, PLATFORM_ID, PlatformRef, RendererFactory2, RootRenderer, StaticProvider, createPlatformFactory, platformCore} from '@angular/core';
import {APP_INITIALIZER, ApplicationModule, ErrorHandler, NgModule, NgZone, PLATFORM_ID, PlatformRef, RendererFactory2, RootRenderer, StaticProvider, createPlatformFactory, platformCore, ɵAPP_ROOT as APP_ROOT} from '@angular/core';
import {DOCUMENT, ɵBROWSER_SANITIZATION_PROVIDERS as BROWSER_SANITIZATION_PROVIDERS} from '@angular/platform-browser';
import {ON_WEB_WORKER} from './web_workers/shared/api';
@ -60,6 +60,7 @@ export function setupWebWorker(): void {
@NgModule({
providers: [
BROWSER_SANITIZATION_PROVIDERS,
{provide: APP_ROOT, useValue: true},
Serializer,
{provide: DOCUMENT, useValue: null},
ClientMessageBrokerFactory,