fix(ivy): WorkerAppModule should be an APP_ROOT (#28544)
PR Close #28544
This commit is contained in:
parent
e3032a0d17
commit
43081a01d8
|
@ -6,73 +6,70 @@
|
||||||
* found in the LICENSE file at https://angular.io/license
|
* 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 {ExpectedConditions, browser, by, element, protractor} from 'protractor';
|
||||||
|
|
||||||
import {verifyNoBrowserErrors} from '../../../../e2e_util/e2e_util';
|
import {verifyNoBrowserErrors} from '../../../../e2e_util/e2e_util';
|
||||||
|
|
||||||
fixmeIvy('NullInjectorError: No provider for InjectionToken ROOT_CONTEXT_TOKEN!')
|
describe('WebWorkers Input', function() {
|
||||||
.describe('WebWorkers Input', function() {
|
afterEach(() => {
|
||||||
afterEach(() => {
|
verifyNoBrowserErrors();
|
||||||
verifyNoBrowserErrors();
|
browser.ignoreSynchronization = false;
|
||||||
browser.ignoreSynchronization = false;
|
});
|
||||||
});
|
const selector = 'input-app';
|
||||||
const selector = 'input-app';
|
const URL = '/';
|
||||||
const URL = '/';
|
const VALUE = 'test val';
|
||||||
const VALUE = 'test val';
|
|
||||||
|
|
||||||
it('should bootstrap', () => {
|
it('should bootstrap', () => {
|
||||||
// This test can't wait for Angular as Testability is not available when using WebWorker
|
// This test can't wait for Angular as Testability is not available when using WebWorker
|
||||||
browser.ignoreSynchronization = true;
|
browser.ignoreSynchronization = true;
|
||||||
browser.get(URL);
|
browser.get(URL);
|
||||||
|
|
||||||
waitForBootstrap();
|
waitForBootstrap();
|
||||||
const elem = element(by.css(selector + ' h2'));
|
const elem = element(by.css(selector + ' h2'));
|
||||||
expect(elem.getText()).toEqual('Input App');
|
expect(elem.getText()).toEqual('Input App');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should bind to input value', () => {
|
it('should bind to input value', () => {
|
||||||
// This test can't wait for Angular as Testability is not available when using WebWorker
|
// This test can't wait for Angular as Testability is not available when using WebWorker
|
||||||
browser.ignoreSynchronization = true;
|
browser.ignoreSynchronization = true;
|
||||||
browser.get(URL);
|
browser.get(URL);
|
||||||
|
|
||||||
waitForBootstrap();
|
waitForBootstrap();
|
||||||
const input = element(by.css(selector + ' input'));
|
const input = element(by.css(selector + ' input'));
|
||||||
input.sendKeys(VALUE);
|
input.sendKeys(VALUE);
|
||||||
const displayElem = element(by.css(selector + ' .input-val'));
|
const displayElem = element(by.css(selector + ' .input-val'));
|
||||||
const expectedVal = `Input val is ${VALUE}.`;
|
const expectedVal = `Input val is ${VALUE}.`;
|
||||||
browser.wait(ExpectedConditions.textToBePresentInElement(displayElem, expectedVal), 5000);
|
browser.wait(ExpectedConditions.textToBePresentInElement(displayElem, expectedVal), 5000);
|
||||||
expect(displayElem.getText()).toEqual(expectedVal);
|
expect(displayElem.getText()).toEqual(expectedVal);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should bind to textarea value', () => {
|
it('should bind to textarea value', () => {
|
||||||
// This test can't wait for Angular as Testability is not available when using WebWorker
|
// This test can't wait for Angular as Testability is not available when using WebWorker
|
||||||
browser.ignoreSynchronization = true;
|
browser.ignoreSynchronization = true;
|
||||||
browser.get(URL);
|
browser.get(URL);
|
||||||
|
|
||||||
waitForBootstrap();
|
waitForBootstrap();
|
||||||
const input = element(by.css(selector + ' textarea'));
|
const input = element(by.css(selector + ' textarea'));
|
||||||
input.sendKeys(VALUE);
|
input.sendKeys(VALUE);
|
||||||
const displayElem = element(by.css(selector + ' .textarea-val'));
|
const displayElem = element(by.css(selector + ' .textarea-val'));
|
||||||
const expectedVal = `Textarea val is ${VALUE}.`;
|
const expectedVal = `Textarea val is ${VALUE}.`;
|
||||||
browser.wait(ExpectedConditions.textToBePresentInElement(displayElem, expectedVal), 5000);
|
browser.wait(ExpectedConditions.textToBePresentInElement(displayElem, expectedVal), 5000);
|
||||||
expect(displayElem.getText()).toEqual(expectedVal);
|
expect(displayElem.getText()).toEqual(expectedVal);
|
||||||
});
|
});
|
||||||
|
|
||||||
function waitForBootstrap() {
|
function waitForBootstrap() {
|
||||||
browser.wait(protractor.until.elementLocated(by.css(selector + ' h2')), 5000)
|
browser.wait(protractor.until.elementLocated(by.css(selector + ' h2')), 5000)
|
||||||
.then(
|
.then(
|
||||||
() => {
|
() => {
|
||||||
const elem = element(by.css(selector + ' h2'));
|
const elem = element(by.css(selector + ' h2'));
|
||||||
browser.wait(
|
browser.wait(
|
||||||
protractor.ExpectedConditions.textToBePresentInElement(elem, 'Input App'),
|
protractor.ExpectedConditions.textToBePresentInElement(elem, 'Input App'), 5000);
|
||||||
5000);
|
},
|
||||||
},
|
() => {
|
||||||
() => {
|
// jasmine will timeout if this gets called too many times
|
||||||
// jasmine will timeout if this gets called too many times
|
console.error('>> unexpected timeout -> browser.refresh()');
|
||||||
console.error('>> unexpected timeout -> browser.refresh()');
|
browser.refresh();
|
||||||
browser.refresh();
|
waitForBootstrap();
|
||||||
waitForBootstrap();
|
});
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ import {ExpectedConditions, browser, by, element, protractor} from 'protractor';
|
||||||
|
|
||||||
import {verifyNoBrowserErrors} from '../../../../e2e_util/e2e_util';
|
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() {
|
.describe('WebWorkers Kitchen Sink', function() {
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
verifyNoBrowserErrors();
|
verifyNoBrowserErrors();
|
||||||
|
|
|
@ -6,44 +6,42 @@
|
||||||
* found in the LICENSE file at https://angular.io/license
|
* 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 {ExpectedConditions, browser, by, element, protractor} from 'protractor';
|
||||||
|
|
||||||
import {verifyNoBrowserErrors} from '../../../../e2e_util/e2e_util';
|
import {verifyNoBrowserErrors} from '../../../../e2e_util/e2e_util';
|
||||||
|
|
||||||
const URL = '/';
|
const URL = '/';
|
||||||
|
|
||||||
fixmeIvy('NullInjectorError: No provider for InjectionToken ROOT_CONTEXT_TOKEN!')
|
describe('MessageBroker', function() {
|
||||||
.describe('MessageBroker', function() {
|
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
verifyNoBrowserErrors();
|
verifyNoBrowserErrors();
|
||||||
browser.ignoreSynchronization = false;
|
browser.ignoreSynchronization = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should bootstrap', () => {
|
it('should bootstrap', () => {
|
||||||
// This test can't wait for Angular as Testability is not available when using WebWorker
|
// This test can't wait for Angular as Testability is not available when using WebWorker
|
||||||
browser.ignoreSynchronization = true;
|
browser.ignoreSynchronization = true;
|
||||||
browser.get(URL);
|
browser.get(URL);
|
||||||
waitForBootstrap();
|
waitForBootstrap();
|
||||||
expect(element(by.css('app h1')).getText()).toEqual('WebWorker MessageBroker Test');
|
expect(element(by.css('app h1')).getText()).toEqual('WebWorker MessageBroker Test');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should echo messages', () => {
|
it('should echo messages', () => {
|
||||||
const VALUE = 'Hi There';
|
const VALUE = 'Hi There';
|
||||||
// This test can't wait for Angular as Testability is not available when using WebWorker
|
// This test can't wait for Angular as Testability is not available when using WebWorker
|
||||||
browser.ignoreSynchronization = true;
|
browser.ignoreSynchronization = true;
|
||||||
browser.get(URL);
|
browser.get(URL);
|
||||||
waitForBootstrap();
|
waitForBootstrap();
|
||||||
|
|
||||||
const input = element.all(by.css('#echo_input')).first();
|
const input = element.all(by.css('#echo_input')).first();
|
||||||
input.sendKeys(VALUE);
|
input.sendKeys(VALUE);
|
||||||
element(by.css('#send_echo')).click();
|
element(by.css('#send_echo')).click();
|
||||||
const area = element(by.css('#echo_result'));
|
const area = element(by.css('#echo_result'));
|
||||||
browser.wait(ExpectedConditions.textToBePresentInElement(area, VALUE), 5000);
|
browser.wait(ExpectedConditions.textToBePresentInElement(area, VALUE), 5000);
|
||||||
expect(area.getText()).toEqual(VALUE);
|
expect(area.getText()).toEqual(VALUE);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function waitForBootstrap(): void {
|
function waitForBootstrap(): void {
|
||||||
browser.wait(protractor.until.elementLocated(by.css('app h1')), 15000);
|
browser.wait(protractor.until.elementLocated(by.css('app h1')), 15000);
|
||||||
|
|
|
@ -6,82 +6,80 @@
|
||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {fixmeIvy} from '@angular/private/testing';
|
|
||||||
import {browser, by, element, protractor} from 'protractor';
|
import {browser, by, element, protractor} from 'protractor';
|
||||||
|
|
||||||
import {verifyNoBrowserErrors} from '../../../../e2e_util/e2e_util';
|
import {verifyNoBrowserErrors} from '../../../../e2e_util/e2e_util';
|
||||||
|
|
||||||
fixmeIvy('NullInjectorError: No provider for InjectionToken ROOT_CONTEXT_TOKEN!')
|
describe('WebWorker Router', () => {
|
||||||
.describe('WebWorker Router', () => {
|
beforeEach(() => {
|
||||||
beforeEach(() => {
|
// This test can't wait for Angular as Testability is not available when using WebWorker
|
||||||
// This test can't wait for Angular as Testability is not available when using WebWorker
|
browser.ignoreSynchronization = true;
|
||||||
browser.ignoreSynchronization = true;
|
browser.get('/');
|
||||||
browser.get('/');
|
});
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
verifyNoBrowserErrors();
|
verifyNoBrowserErrors();
|
||||||
browser.ignoreSynchronization = false;
|
browser.ignoreSynchronization = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
const contentSelector = 'app main h1';
|
const contentSelector = 'app main h1';
|
||||||
const navSelector = 'app nav ul';
|
const navSelector = 'app nav ul';
|
||||||
const baseUrl = '/';
|
const baseUrl = '/';
|
||||||
|
|
||||||
it('should route on click', () => {
|
it('should route on click', () => {
|
||||||
browser.get(baseUrl);
|
browser.get(baseUrl);
|
||||||
|
|
||||||
waitForElement(contentSelector);
|
waitForElement(contentSelector);
|
||||||
let content = element(by.css(contentSelector));
|
let content = element(by.css(contentSelector));
|
||||||
expect(content.getText()).toEqual('Start');
|
expect(content.getText()).toEqual('Start');
|
||||||
|
|
||||||
const aboutBtn = element(by.css(navSelector + ' .about'));
|
const aboutBtn = element(by.css(navSelector + ' .about'));
|
||||||
aboutBtn.click();
|
aboutBtn.click();
|
||||||
waitForUrl(/\/about/);
|
waitForUrl(/\/about/);
|
||||||
waitForElement(contentSelector);
|
waitForElement(contentSelector);
|
||||||
waitForElementText(contentSelector, 'About');
|
waitForElementText(contentSelector, 'About');
|
||||||
content = element(by.css(contentSelector));
|
content = element(by.css(contentSelector));
|
||||||
expect(content.getText()).toEqual('About');
|
expect(content.getText()).toEqual('About');
|
||||||
expect(browser.getCurrentUrl()).toMatch(/\/about/);
|
expect(browser.getCurrentUrl()).toMatch(/\/about/);
|
||||||
|
|
||||||
const contactBtn = element(by.css(navSelector + ' .contact'));
|
const contactBtn = element(by.css(navSelector + ' .contact'));
|
||||||
contactBtn.click();
|
contactBtn.click();
|
||||||
waitForUrl(/\/contact/);
|
waitForUrl(/\/contact/);
|
||||||
waitForElement(contentSelector);
|
waitForElement(contentSelector);
|
||||||
waitForElementText(contentSelector, 'Contact');
|
waitForElementText(contentSelector, 'Contact');
|
||||||
content = element(by.css(contentSelector));
|
content = element(by.css(contentSelector));
|
||||||
expect(content.getText()).toEqual('Contact');
|
expect(content.getText()).toEqual('Contact');
|
||||||
expect(browser.getCurrentUrl()).toMatch(/\/contact/);
|
expect(browser.getCurrentUrl()).toMatch(/\/contact/);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should load the correct route from the URL', () => {
|
it('should load the correct route from the URL', () => {
|
||||||
browser.get(baseUrl + '#/about');
|
browser.get(baseUrl + '#/about');
|
||||||
|
|
||||||
waitForElement(contentSelector);
|
waitForElement(contentSelector);
|
||||||
waitForElementText(contentSelector, 'About');
|
waitForElementText(contentSelector, 'About');
|
||||||
const content = element(by.css(contentSelector));
|
const content = element(by.css(contentSelector));
|
||||||
expect(content.getText()).toEqual('About');
|
expect(content.getText()).toEqual('About');
|
||||||
});
|
});
|
||||||
|
|
||||||
function waitForElement(selector: string): void {
|
function waitForElement(selector: string): void {
|
||||||
browser.wait(protractor.until.elementLocated(by.css(selector)), 15000);
|
browser.wait(protractor.until.elementLocated(by.css(selector)), 15000);
|
||||||
}
|
}
|
||||||
|
|
||||||
function waitForElementText(contentSelector: string, expected: string): void {
|
function waitForElementText(contentSelector: string, expected: string): void {
|
||||||
browser.wait(() => {
|
browser.wait(() => {
|
||||||
const deferred = protractor.promise.defer();
|
const deferred = protractor.promise.defer();
|
||||||
const elem = element(by.css(contentSelector));
|
const elem = element(by.css(contentSelector));
|
||||||
elem.getText().then((text: string) => { return deferred.fulfill(text === expected); });
|
elem.getText().then((text: string) => { return deferred.fulfill(text === expected); });
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
}, 5000);
|
}, 5000);
|
||||||
}
|
}
|
||||||
|
|
||||||
function waitForUrl(regex: RegExp): void {
|
function waitForUrl(regex: RegExp): void {
|
||||||
browser.wait(() => {
|
browser.wait(() => {
|
||||||
const deferred = protractor.promise.defer();
|
const deferred = protractor.promise.defer();
|
||||||
browser.getCurrentUrl().then(
|
browser.getCurrentUrl().then(
|
||||||
(url: string) => { return deferred.fulfill(url.match(regex) !== null); });
|
(url: string) => { return deferred.fulfill(url.match(regex) !== null); });
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
}, 5000);
|
}, 5000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,30 +6,28 @@
|
||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {fixmeIvy} from '@angular/private/testing';
|
|
||||||
import {browser, by, element, protractor} from 'protractor';
|
import {browser, by, element, protractor} from 'protractor';
|
||||||
|
|
||||||
import {verifyNoBrowserErrors} from '../../../../e2e_util/e2e_util';
|
import {verifyNoBrowserErrors} from '../../../../e2e_util/e2e_util';
|
||||||
|
|
||||||
fixmeIvy('NullInjectorError: No provider for InjectionToken ROOT_CONTEXT_TOKEN!')
|
describe('WebWorkers Todo', function() {
|
||||||
.describe('WebWorkers Todo', function() {
|
afterEach(() => {
|
||||||
afterEach(() => {
|
verifyNoBrowserErrors();
|
||||||
verifyNoBrowserErrors();
|
browser.ignoreSynchronization = false;
|
||||||
browser.ignoreSynchronization = false;
|
});
|
||||||
});
|
|
||||||
|
|
||||||
const URL = '/';
|
const URL = '/';
|
||||||
|
|
||||||
it('should bootstrap', () => {
|
it('should bootstrap', () => {
|
||||||
// This test can't wait for Angular as Testability is not available when using WebWorker
|
// This test can't wait for Angular as Testability is not available when using WebWorker
|
||||||
browser.ignoreSynchronization = true;
|
browser.ignoreSynchronization = true;
|
||||||
browser.get(URL);
|
browser.get(URL);
|
||||||
|
|
||||||
waitForBootstrap();
|
waitForBootstrap();
|
||||||
expect(element(by.css('#todoapp header')).getText()).toEqual('todos');
|
expect(element(by.css('#todoapp header')).getText()).toEqual('todos');
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function waitForBootstrap(): void {
|
function waitForBootstrap(): void {
|
||||||
browser.wait(protractor.until.elementLocated(by.css('todo-app #todoapp')), 15000);
|
browser.wait(protractor.until.elementLocated(by.css('todo-app #todoapp')), 15000);
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {CommonModule, ViewportScroller, ɵNullViewportScroller as NullViewportScroller, ɵPLATFORM_WORKER_APP_ID as PLATFORM_WORKER_APP_ID} from '@angular/common';
|
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 {DOCUMENT, ɵBROWSER_SANITIZATION_PROVIDERS as BROWSER_SANITIZATION_PROVIDERS} from '@angular/platform-browser';
|
||||||
|
|
||||||
import {ON_WEB_WORKER} from './web_workers/shared/api';
|
import {ON_WEB_WORKER} from './web_workers/shared/api';
|
||||||
|
@ -60,6 +60,7 @@ export function setupWebWorker(): void {
|
||||||
@NgModule({
|
@NgModule({
|
||||||
providers: [
|
providers: [
|
||||||
BROWSER_SANITIZATION_PROVIDERS,
|
BROWSER_SANITIZATION_PROVIDERS,
|
||||||
|
{provide: APP_ROOT, useValue: true},
|
||||||
Serializer,
|
Serializer,
|
||||||
{provide: DOCUMENT, useValue: null},
|
{provide: DOCUMENT, useValue: null},
|
||||||
ClientMessageBrokerFactory,
|
ClientMessageBrokerFactory,
|
||||||
|
|
Loading…
Reference in New Issue