test(ivy): add root cause analysis for failing core tests (view injector integration) (#27912)
PR Close #27912
This commit is contained in:
@ -589,7 +589,7 @@ const TEST_COMPILER_PROVIDERS: Provider[] = [
|
|||||||
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
modifiedInIvy('FW-821: Pure pipes are instantiated differently in view engine and ivy')
|
modifiedInIvy('Pure pipes are instantiated differently in view engine and ivy')
|
||||||
.it('should call pure pipes that are used multiple times only when the arguments change and share state between pipe instances',
|
.it('should call pure pipes that are used multiple times only when the arguments change and share state between pipe instances',
|
||||||
fakeAsync(() => {
|
fakeAsync(() => {
|
||||||
const ctx = createCompFixture(
|
const ctx = createCompFixture(
|
||||||
|
@ -10,7 +10,7 @@ import {Attribute, ChangeDetectionStrategy, ChangeDetectorRef, Component, Compon
|
|||||||
import {ComponentFixture, TestBed, fakeAsync} from '@angular/core/testing';
|
import {ComponentFixture, TestBed, fakeAsync} from '@angular/core/testing';
|
||||||
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||||
import {expect} from '@angular/platform-browser/testing/src/matchers';
|
import {expect} from '@angular/platform-browser/testing/src/matchers';
|
||||||
import {fixmeIvy, obsoleteInIvy, onlyInIvy} from '@angular/private/testing';
|
import {fixmeIvy, modifiedInIvy, obsoleteInIvy, onlyInIvy} from '@angular/private/testing';
|
||||||
|
|
||||||
@Directive({selector: '[simpleDirective]'})
|
@Directive({selector: '[simpleDirective]'})
|
||||||
class SimpleDirective {
|
class SimpleDirective {
|
||||||
@ -292,7 +292,9 @@ class TestComp {
|
|||||||
expect(el.children[0].injector.get('injectable2')).toEqual('injectable1-injectable2');
|
expect(el.children[0].injector.get('injectable2')).toEqual('injectable1-injectable2');
|
||||||
});
|
});
|
||||||
|
|
||||||
fixmeIvy('unknown').it('should instantiate viewProviders that have dependencies', () => {
|
fixmeIvy(
|
||||||
|
'FW-889: Element injector cannot access the viewProviders of the component to which it belongs')
|
||||||
|
.it('should instantiate viewProviders that have dependencies', () => {
|
||||||
TestBed.configureTestingModule({declarations: [SimpleComponent]});
|
TestBed.configureTestingModule({declarations: [SimpleComponent]});
|
||||||
const viewProviders = [
|
const viewProviders = [
|
||||||
{provide: 'injectable1', useValue: 'injectable1'}, {
|
{provide: 'injectable1', useValue: 'injectable1'}, {
|
||||||
@ -429,7 +431,7 @@ class TestComp {
|
|||||||
expect(ctx.debugElement.injector.get('eager2')).toBe('v2: v1');
|
expect(ctx.debugElement.injector.get('eager2')).toBe('v2: v1');
|
||||||
});
|
});
|
||||||
|
|
||||||
fixmeIvy('unknown').it('should inject providers that were declared after it', () => {
|
it('should inject providers that were declared after it', () => {
|
||||||
@Component({
|
@Component({
|
||||||
template: '',
|
template: '',
|
||||||
providers: [
|
providers: [
|
||||||
@ -465,7 +467,8 @@ class TestComp {
|
|||||||
expect(comp.componentInstance.a).toBe('aValue');
|
expect(comp.componentInstance.a).toBe('aValue');
|
||||||
});
|
});
|
||||||
|
|
||||||
fixmeIvy('unknown').it('should support ngOnDestroy for lazy providers', () => {
|
fixmeIvy('FW-848: ngOnDestroy hooks are not called on providers')
|
||||||
|
.it('should support ngOnDestroy for lazy providers', () => {
|
||||||
let created = false;
|
let created = false;
|
||||||
let destroyed = false;
|
let destroyed = false;
|
||||||
|
|
||||||
@ -497,7 +500,9 @@ class TestComp {
|
|||||||
expect(destroyed).toBe(true);
|
expect(destroyed).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
fixmeIvy('unknown').it('should instantiate view providers lazily', () => {
|
fixmeIvy(
|
||||||
|
'FW-889: Element injector cannot access the viewProviders of the component to which it belongs')
|
||||||
|
.it('should instantiate view providers lazily', () => {
|
||||||
let created = false;
|
let created = false;
|
||||||
TestBed.configureTestingModule({declarations: [SimpleComponent]});
|
TestBed.configureTestingModule({declarations: [SimpleComponent]});
|
||||||
TestBed.overrideComponent(
|
TestBed.overrideComponent(
|
||||||
@ -552,8 +557,8 @@ class TestComp {
|
|||||||
.toEqual('parentService');
|
.toEqual('parentService');
|
||||||
});
|
});
|
||||||
|
|
||||||
fixmeIvy('unknown').it(
|
fixmeIvy('FW-890: Overridden providers are not found during dependency resolution')
|
||||||
'should instantiate directives that depend on providers of a component', () => {
|
.it('should instantiate directives that depend on providers of a component', () => {
|
||||||
TestBed.configureTestingModule({declarations: [SimpleComponent, NeedsService]});
|
TestBed.configureTestingModule({declarations: [SimpleComponent, NeedsService]});
|
||||||
TestBed.overrideComponent(
|
TestBed.overrideComponent(
|
||||||
SimpleComponent,
|
SimpleComponent,
|
||||||
@ -565,8 +570,8 @@ class TestComp {
|
|||||||
.toEqual('hostService');
|
.toEqual('hostService');
|
||||||
});
|
});
|
||||||
|
|
||||||
fixmeIvy('unknown').it(
|
fixmeIvy('FW-890: Overridden providers are not found during dependency resolution')
|
||||||
'should instantiate directives that depend on view providers of a component', () => {
|
.it('should instantiate directives that depend on view providers of a component', () => {
|
||||||
TestBed.configureTestingModule({declarations: [SimpleComponent, NeedsService]});
|
TestBed.configureTestingModule({declarations: [SimpleComponent, NeedsService]});
|
||||||
TestBed.overrideComponent(
|
TestBed.overrideComponent(
|
||||||
SimpleComponent,
|
SimpleComponent,
|
||||||
@ -578,8 +583,8 @@ class TestComp {
|
|||||||
.toEqual('hostService');
|
.toEqual('hostService');
|
||||||
});
|
});
|
||||||
|
|
||||||
fixmeIvy('unknown').it(
|
fixmeIvy('FW-890: Overridden providers are not found during dependency resolution')
|
||||||
'should instantiate directives in a root embedded view that depend on view providers of a component',
|
.it('should instantiate directives in a root embedded view that depend on view providers of a component',
|
||||||
() => {
|
() => {
|
||||||
TestBed.configureTestingModule({declarations: [SimpleComponent, NeedsService]});
|
TestBed.configureTestingModule({declarations: [SimpleComponent, NeedsService]});
|
||||||
TestBed.overrideComponent(
|
TestBed.overrideComponent(
|
||||||
@ -734,8 +739,8 @@ class TestComp {
|
|||||||
expect(d.dependency).toBeAnInstanceOf(SimpleComponent);
|
expect(d.dependency).toBeAnInstanceOf(SimpleComponent);
|
||||||
});
|
});
|
||||||
|
|
||||||
fixmeIvy('unknown').it(
|
obsoleteInIvy('@Host() / @Self() no longer looks in module injector')
|
||||||
'should instantiate host views for components that have a @Host dependency ', () => {
|
.it('should instantiate host views for components that have a @Host dependency ', () => {
|
||||||
TestBed.configureTestingModule({declarations: [NeedsHostAppService]});
|
TestBed.configureTestingModule({declarations: [NeedsHostAppService]});
|
||||||
const el = createComponent('', [], NeedsHostAppService);
|
const el = createComponent('', [], NeedsHostAppService);
|
||||||
expect(el.componentInstance.service).toEqual('appService');
|
expect(el.componentInstance.service).toEqual('appService');
|
||||||
@ -764,15 +769,16 @@ class TestComp {
|
|||||||
.toThrowError('NodeInjector: NOT_FOUND [SimpleDirective]');
|
.toThrowError('NodeInjector: NOT_FOUND [SimpleDirective]');
|
||||||
});
|
});
|
||||||
|
|
||||||
fixmeIvy('unknown').it(
|
fixmeIvy('FW-638: Exception thrown when getting VCRef.parentInjector on the root view')
|
||||||
'should allow to use the NgModule injector from a root ViewContainerRef.parentInjector',
|
.it('should allow to use the NgModule injector from a root ViewContainerRef.parentInjector',
|
||||||
() => {
|
() => {
|
||||||
@Component({template: ''})
|
@Component({template: ''})
|
||||||
class MyComp {
|
class MyComp {
|
||||||
constructor(public vc: ViewContainerRef) {}
|
constructor(public vc: ViewContainerRef) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
const compFixture = TestBed
|
const compFixture =
|
||||||
|
TestBed
|
||||||
.configureTestingModule({
|
.configureTestingModule({
|
||||||
declarations: [MyComp],
|
declarations: [MyComp],
|
||||||
providers: [{provide: 'someToken', useValue: 'someValue'}]
|
providers: [{provide: 'someToken', useValue: 'someValue'}]
|
||||||
@ -812,8 +818,7 @@ class TestComp {
|
|||||||
.toBe(el.children[0].nativeElement);
|
.toBe(el.children[0].nativeElement);
|
||||||
});
|
});
|
||||||
|
|
||||||
fixmeIvy('unknown').it(
|
it('should inject ChangeDetectorRef of the component\'s view into the component', () => {
|
||||||
'should inject ChangeDetectorRef of the component\'s view into the component', () => {
|
|
||||||
TestBed.configureTestingModule({declarations: [PushComponentNeedsChangeDetectorRef]});
|
TestBed.configureTestingModule({declarations: [PushComponentNeedsChangeDetectorRef]});
|
||||||
const cf = createComponentFixture('<div componentNeedsChangeDetectorRef></div>');
|
const cf = createComponentFixture('<div componentNeedsChangeDetectorRef></div>');
|
||||||
cf.detectChanges();
|
cf.detectChanges();
|
||||||
@ -827,8 +832,9 @@ class TestComp {
|
|||||||
expect(compEl.nativeElement).toHaveText('1');
|
expect(compEl.nativeElement).toHaveText('1');
|
||||||
});
|
});
|
||||||
|
|
||||||
fixmeIvy('unknown').it(
|
fixmeIvy(
|
||||||
'should inject ChangeDetectorRef of the containing component into directives', () => {
|
'FW-893: expect(changeDetectorRef).toEqual(otherChangeDetectorRef) creates an infinite loop')
|
||||||
|
.it('should inject ChangeDetectorRef of the containing component into directives', () => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
declarations:
|
declarations:
|
||||||
[PushComponentNeedsChangeDetectorRef, DirectiveNeedsChangeDetectorRef]
|
[PushComponentNeedsChangeDetectorRef, DirectiveNeedsChangeDetectorRef]
|
||||||
@ -858,12 +864,9 @@ class TestComp {
|
|||||||
expect(compEl.nativeElement).toHaveText('1');
|
expect(compEl.nativeElement).toHaveText('1');
|
||||||
});
|
});
|
||||||
|
|
||||||
fixmeIvy('unknown').it(
|
it('should inject ChangeDetectorRef of a same element component into a directive', () => {
|
||||||
'should inject ChangeDetectorRef of a same element component into a directive', () => {
|
TestBed.configureTestingModule(
|
||||||
TestBed.configureTestingModule({
|
{declarations: [PushComponentNeedsChangeDetectorRef, DirectiveNeedsChangeDetectorRef]});
|
||||||
declarations:
|
|
||||||
[PushComponentNeedsChangeDetectorRef, DirectiveNeedsChangeDetectorRef]
|
|
||||||
});
|
|
||||||
const cf = createComponentFixture(
|
const cf = createComponentFixture(
|
||||||
'<div componentNeedsChangeDetectorRef directiveNeedsChangeDetectorRef></div>');
|
'<div componentNeedsChangeDetectorRef directiveNeedsChangeDetectorRef></div>');
|
||||||
cf.detectChanges();
|
cf.detectChanges();
|
||||||
@ -878,13 +881,10 @@ class TestComp {
|
|||||||
expect(compEl.nativeElement).toHaveText('1');
|
expect(compEl.nativeElement).toHaveText('1');
|
||||||
});
|
});
|
||||||
|
|
||||||
fixmeIvy('unknown').it(
|
it(`should not inject ChangeDetectorRef of a parent element's component into a directive`, () => {
|
||||||
`should not inject ChangeDetectorRef of a parent element's component into a directive`,
|
|
||||||
() => {
|
|
||||||
TestBed
|
TestBed
|
||||||
.configureTestingModule({
|
.configureTestingModule({
|
||||||
declarations:
|
declarations: [PushComponentNeedsChangeDetectorRef, DirectiveNeedsChangeDetectorRef]
|
||||||
[PushComponentNeedsChangeDetectorRef, DirectiveNeedsChangeDetectorRef]
|
|
||||||
})
|
})
|
||||||
.overrideComponent(
|
.overrideComponent(
|
||||||
PushComponentNeedsChangeDetectorRef,
|
PushComponentNeedsChangeDetectorRef,
|
||||||
@ -912,7 +912,8 @@ class TestComp {
|
|||||||
.toBe(el.children[0].nativeElement);
|
.toBe(el.children[0].nativeElement);
|
||||||
});
|
});
|
||||||
|
|
||||||
fixmeIvy('unknown').it('should inject ViewContainerRef', () => {
|
fixmeIvy('FW-638: Exception thrown when getting VCRef.parentInjector on the root view')
|
||||||
|
.it('should inject ViewContainerRef', () => {
|
||||||
@Component({template: ''})
|
@Component({template: ''})
|
||||||
class TestComp {
|
class TestComp {
|
||||||
constructor(public vcr: ViewContainerRef) {}
|
constructor(public vcr: ViewContainerRef) {}
|
||||||
@ -937,7 +938,7 @@ class TestComp {
|
|||||||
expect(component.instance.vcr.parentInjector.get('someToken')).toBe('someNewValue');
|
expect(component.instance.vcr.parentInjector.get('someToken')).toBe('someNewValue');
|
||||||
});
|
});
|
||||||
|
|
||||||
fixmeIvy('unknown').it('should inject TemplateRef', () => {
|
it('should inject TemplateRef', () => {
|
||||||
TestBed.configureTestingModule({declarations: [NeedsViewContainerRef, NeedsTemplateRef]});
|
TestBed.configureTestingModule({declarations: [NeedsViewContainerRef, NeedsTemplateRef]});
|
||||||
const el =
|
const el =
|
||||||
createComponent('<ng-template needsViewContainerRef needsTemplateRef></ng-template>');
|
createComponent('<ng-template needsViewContainerRef needsTemplateRef></ng-template>');
|
||||||
@ -960,20 +961,24 @@ class TestComp {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('pipes', () => {
|
describe('pipes', () => {
|
||||||
fixmeIvy('unknown').it('should instantiate pipes that have dependencies', () => {
|
fixmeIvy('FW-890: Overridden providers are not found during dependency resolution')
|
||||||
|
.it('should instantiate pipes that have dependencies', () => {
|
||||||
TestBed.configureTestingModule({declarations: [SimpleDirective, PipeNeedsService]});
|
TestBed.configureTestingModule({declarations: [SimpleDirective, PipeNeedsService]});
|
||||||
|
|
||||||
const el = createComponent(
|
const el = createComponent(
|
||||||
'<div [simpleDirective]="true | pipeNeedsService"></div>',
|
'<div [simpleDirective]="true | pipeNeedsService"></div>',
|
||||||
[{provide: 'service', useValue: 'pipeService'}]);
|
[{provide: 'service', useValue: 'pipeService'}]);
|
||||||
expect(el.children[0].injector.get(SimpleDirective).value.service).toEqual('pipeService');
|
expect(el.children[0].injector.get(SimpleDirective).value.service)
|
||||||
|
.toEqual('pipeService');
|
||||||
});
|
});
|
||||||
|
|
||||||
fixmeIvy('unknown').it('should overwrite pipes with later entry in the pipes array', () => {
|
fixmeIvy('FW-894: Pipes don\'t overwrite pipes with later entry in the pipes array')
|
||||||
|
.it('should overwrite pipes with later entry in the pipes array', () => {
|
||||||
TestBed.configureTestingModule(
|
TestBed.configureTestingModule(
|
||||||
{declarations: [SimpleDirective, DuplicatePipe1, DuplicatePipe2]});
|
{declarations: [SimpleDirective, DuplicatePipe1, DuplicatePipe2]});
|
||||||
const el = createComponent('<div [simpleDirective]="true | duplicatePipe"></div>');
|
const el = createComponent('<div [simpleDirective]="true | duplicatePipe"></div>');
|
||||||
expect(el.children[0].injector.get(SimpleDirective).value).toBeAnInstanceOf(DuplicatePipe2);
|
expect(el.children[0].injector.get(SimpleDirective).value)
|
||||||
|
.toBeAnInstanceOf(DuplicatePipe2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should inject ChangeDetectorRef into pipes', () => {
|
it('should inject ChangeDetectorRef into pipes', () => {
|
||||||
@ -988,7 +993,8 @@ class TestComp {
|
|||||||
expect(el.children[0].injector.get(SimpleDirective).value.changeDetectorRef).toEqual(cdRef);
|
expect(el.children[0].injector.get(SimpleDirective).value.changeDetectorRef).toEqual(cdRef);
|
||||||
});
|
});
|
||||||
|
|
||||||
fixmeIvy('unknown').it('should cache pure pipes', () => {
|
modifiedInIvy('Pure pipes are instantiated differently in view engine and ivy')
|
||||||
|
.it('should cache pure pipes', () => {
|
||||||
TestBed.configureTestingModule({declarations: [SimpleDirective, PurePipe]});
|
TestBed.configureTestingModule({declarations: [SimpleDirective, PurePipe]});
|
||||||
const el = createComponent(
|
const el = createComponent(
|
||||||
'<div [simpleDirective]="true | purePipe"></div><div [simpleDirective]="true | purePipe"></div>' +
|
'<div [simpleDirective]="true | purePipe"></div><div [simpleDirective]="true | purePipe"></div>' +
|
||||||
|
Reference in New Issue
Block a user