test(ivy): update root causes for @angular/core TestBed failures (#27479)

PR Close #27479
This commit is contained in:
Pawel Kozlowski 2018-12-05 15:52:35 +01:00 committed by Igor Minar
parent 26433509f9
commit 821fecb413
6 changed files with 755 additions and 734 deletions

View File

@ -625,8 +625,7 @@ function declareTests(config?: {useJit: boolean}) {
}); });
if (getDOM().supportsDOMEvents()) { if (getDOM().supportsDOMEvents()) {
fixmeIvy('unknown').it( it('should allow to destroy a component from within a host event handler',
'should allow to destroy a component from within a host event handler',
fakeAsync(() => { fakeAsync(() => {
TestBed.configureTestingModule({declarations: [MyComp, [[PushCmpWithHostEvent]]]}); TestBed.configureTestingModule({declarations: [MyComp, [[PushCmpWithHostEvent]]]});
const template = '<push-cmp-with-host-event></push-cmp-with-host-event>'; const template = '<push-cmp-with-host-event></push-cmp-with-host-event>';

View File

@ -136,8 +136,8 @@ function declareTests(config?: {useJit: boolean}) {
expect(dir.text).toEqual('container'); expect(dir.text).toEqual('container');
}); });
fixmeIvy('unknown').it( fixmeIvy('FW-795: Queries with descendants: true don\'t descent into <ng-container>')
'should contain all direct child directives in a <ng-container> (content dom)', () => { .it('should contain all direct child directives in a <ng-container> (content dom)', () => {
const template = const template =
'<needs-content-children #q><ng-container><div text="foo"></div></ng-container></needs-content-children>'; '<needs-content-children #q><ng-container><div text="foo"></div></ng-container></needs-content-children>';
TestBed.overrideComponent(MyComp, {set: {template}}); TestBed.overrideComponent(MyComp, {set: {template}});

View File

@ -13,7 +13,6 @@ 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} from '@angular/private/testing'; import {fixmeIvy} from '@angular/private/testing';
{
describe('projection', () => { describe('projection', () => {
beforeEach(() => TestBed.configureTestingModule({declarations: [MainComp, OtherComp, Simple]})); beforeEach(() => TestBed.configureTestingModule({declarations: [MainComp, OtherComp, Simple]}));
@ -114,8 +113,7 @@ import {fixmeIvy} from '@angular/private/testing';
expect(main.nativeElement).toHaveText('(, BAC)'); expect(main.nativeElement).toHaveText('(, BAC)');
}); });
fixmeIvy('FW-665: Unable to find the given context data for the given target') it('should redistribute direct child viewcontainers when the light dom changes', () => {
.it('should redistribute direct child viewcontainers when the light dom changes', () => {
TestBed.configureTestingModule( TestBed.configureTestingModule(
{declarations: [MultipleContentTagsComponent, ManualViewportDirective]}); {declarations: [MultipleContentTagsComponent, ManualViewportDirective]});
TestBed.overrideComponent(MainComp, { TestBed.overrideComponent(MainComp, {
@ -158,8 +156,7 @@ import {fixmeIvy} from '@angular/private/testing';
expect(main.nativeElement).toHaveText('OUTER(SIMPLE(AB))'); expect(main.nativeElement).toHaveText('OUTER(SIMPLE(AB))');
}); });
fixmeIvy('FW-665: Unable to find the given context data for the given target') it('should support nesting with content being direct child of a nested component', () => {
.it('should support nesting with content being direct child of a nested component', () => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: declarations:
[InnerComponent, InnerInnerComponent, OuterComponent, ManualViewportDirective] [InnerComponent, InnerInnerComponent, OuterComponent, ManualViewportDirective]
@ -176,8 +173,8 @@ import {fixmeIvy} from '@angular/private/testing';
const main = TestBed.createComponent(MainComp); const main = TestBed.createComponent(MainComp);
const viewportDirective = const viewportDirective =
main.debugElement.queryAllNodes(By.directive(ManualViewportDirective))[0] main.debugElement.queryAllNodes(By.directive(ManualViewportDirective))[0].injector.get(
.injector.get(ManualViewportDirective); ManualViewportDirective);
expect(main.nativeElement).toHaveText('OUTER(INNER(INNERINNER(,BC)))'); expect(main.nativeElement).toHaveText('OUTER(INNER(INNERINNER(,BC)))');
viewportDirective.show(); viewportDirective.show();
@ -185,8 +182,7 @@ import {fixmeIvy} from '@angular/private/testing';
expect(main.nativeElement).toHaveText('OUTER(INNER(INNERINNER(A,BC)))'); expect(main.nativeElement).toHaveText('OUTER(INNER(INNERINNER(A,BC)))');
}); });
fixmeIvy( fixmeIvy('FW-796: Content projection logic is incorrect for <ng-content> in nested templates')
'FW-745: Compiler isn\'t generating projectionDefs for <ng-content> tags inside <ng-templates>')
.it('should redistribute when the shadow dom changes', () => { .it('should redistribute when the shadow dom changes', () => {
TestBed.configureTestingModule( TestBed.configureTestingModule(
{declarations: [ConditionalContentComponent, ManualViewportDirective]}); {declarations: [ConditionalContentComponent, ManualViewportDirective]});
@ -202,8 +198,8 @@ import {fixmeIvy} from '@angular/private/testing';
const main = TestBed.createComponent(MainComp); const main = TestBed.createComponent(MainComp);
const viewportDirective = const viewportDirective =
main.debugElement.queryAllNodes(By.directive(ManualViewportDirective))[0] main.debugElement.queryAllNodes(By.directive(ManualViewportDirective))[0].injector.get(
.injector.get(ManualViewportDirective); ManualViewportDirective);
expect(main.nativeElement).toHaveText('(, BC)'); expect(main.nativeElement).toHaveText('(, BC)');
@ -234,8 +230,7 @@ import {fixmeIvy} from '@angular/private/testing';
// which could skrew up text node indices. // which could skrew up text node indices.
it('should support text nodes after style tags', () => { it('should support text nodes after style tags', () => {
TestBed.overrideComponent(MainComp, {set: {template: '<simple stringProp="text"></simple>'}}); TestBed.overrideComponent(MainComp, {set: {template: '<simple stringProp="text"></simple>'}});
TestBed.overrideComponent( TestBed.overrideComponent(Simple, {set: {template: '<style></style><p>P,</p>{{stringProp}}'}});
Simple, {set: {template: '<style></style><p>P,</p>{{stringProp}}'}});
const main = TestBed.createComponent(MainComp); const main = TestBed.createComponent(MainComp);
main.detectChanges(); main.detectChanges();
@ -295,11 +290,10 @@ import {fixmeIvy} from '@angular/private/testing';
expect(main.nativeElement).toHaveText('SIMPLE()START(A)END'); expect(main.nativeElement).toHaveText('SIMPLE()START(A)END');
}); });
fixmeIvy('FW-665: Unable to find the given context data for the given target') fixmeIvy('FW-796: Content projection logic is incorrect for <ng-content> in nested templates')
.it('should support moving ng-content around', () => { .it('should support moving ng-content around', () => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: declarations: [ConditionalContentComponent, ProjectDirective, ManualViewportDirective]
[ConditionalContentComponent, ProjectDirective, ManualViewportDirective]
}); });
TestBed.overrideComponent(MainComp, { TestBed.overrideComponent(MainComp, {
set: { set: {
@ -313,8 +307,8 @@ import {fixmeIvy} from '@angular/private/testing';
const main = TestBed.createComponent(MainComp); const main = TestBed.createComponent(MainComp);
const sourceDirective: ManualViewportDirective = const sourceDirective: ManualViewportDirective =
main.debugElement.queryAllNodes(By.directive(ManualViewportDirective))[0] main.debugElement.queryAllNodes(By.directive(ManualViewportDirective))[0].injector.get(
.injector.get(ManualViewportDirective); ManualViewportDirective);
const projectDirective: ProjectDirective = const projectDirective: ProjectDirective =
main.debugElement.queryAllNodes(By.directive(ProjectDirective))[0].injector.get( main.debugElement.queryAllNodes(By.directive(ProjectDirective))[0].injector.get(
ProjectDirective); ProjectDirective);
@ -435,7 +429,7 @@ import {fixmeIvy} from '@angular/private/testing';
}); });
} }
fixmeIvy('FW-665: Unable to find the given context data for the given target') fixmeIvy('FW-796: Content projection logic is incorrect for <ng-content> in nested templates')
.it('should support nested conditionals that contain ng-contents', () => { .it('should support nested conditionals that contain ng-contents', () => {
TestBed.configureTestingModule( TestBed.configureTestingModule(
{declarations: [ConditionalTextComponent, ManualViewportDirective]}); {declarations: [ConditionalTextComponent, ManualViewportDirective]});
@ -450,8 +444,7 @@ import {fixmeIvy} from '@angular/private/testing';
viewportElement.injector.get(ManualViewportDirective).show(); viewportElement.injector.get(ManualViewportDirective).show();
expect(main.nativeElement).toHaveText('MAIN(FIRST())'); expect(main.nativeElement).toHaveText('MAIN(FIRST())');
viewportElement = viewportElement = main.debugElement.queryAllNodes(By.directive(ManualViewportDirective))[1];
main.debugElement.queryAllNodes(By.directive(ManualViewportDirective))[1];
viewportElement.injector.get(ManualViewportDirective).show(); viewportElement.injector.get(ManualViewportDirective).show();
expect(main.nativeElement).toHaveText('MAIN(FIRST(SECOND(a)))'); expect(main.nativeElement).toHaveText('MAIN(FIRST(SECOND(a)))');
}); });
@ -469,8 +462,7 @@ import {fixmeIvy} from '@angular/private/testing';
}); });
it('should create nested components in the right order', () => { it('should create nested components in the right order', () => {
TestBed.configureTestingModule( TestBed.configureTestingModule({declarations: [CmpA1, CmpA2, CmpB11, CmpB12, CmpB21, CmpB22]});
{declarations: [CmpA1, CmpA2, CmpB11, CmpB12, CmpB21, CmpB22]});
TestBed.overrideComponent(MainComp, {set: {template: `<cmp-a1></cmp-a1><cmp-a2></cmp-a2>`}}); TestBed.overrideComponent(MainComp, {set: {template: `<cmp-a1></cmp-a1><cmp-a2></cmp-a2>`}});
const main = TestBed.createComponent(MainComp); const main = TestBed.createComponent(MainComp);
@ -481,8 +473,7 @@ import {fixmeIvy} from '@angular/private/testing';
'<cmp-a2>a2<cmp-b21>b21</cmp-b21><cmp-b22>b22</cmp-b22></cmp-a2>'); '<cmp-a2>a2<cmp-b21>b21</cmp-b21><cmp-b22>b22</cmp-b22></cmp-a2>');
}); });
fixmeIvy( fixmeIvy('FW-796: Content projection logic is incorrect for <ng-content> in nested templates')
'FW-745: Compiler isn\'t generating projectionDefs for <ng-content> tags inside <ng-templates>')
.it('should project filled view containers into a view container', () => { .it('should project filled view containers into a view container', () => {
TestBed.configureTestingModule( TestBed.configureTestingModule(
{declarations: [ConditionalContentComponent, ManualViewportDirective]}); {declarations: [ConditionalContentComponent, ManualViewportDirective]});
@ -498,8 +489,7 @@ import {fixmeIvy} from '@angular/private/testing';
}); });
const main = TestBed.createComponent(MainComp); const main = TestBed.createComponent(MainComp);
const conditionalComp = const conditionalComp = main.debugElement.query(By.directive(ConditionalContentComponent));
main.debugElement.query(By.directive(ConditionalContentComponent));
const viewViewportDir = const viewViewportDir =
conditionalComp.queryAllNodes(By.directive(ManualViewportDirective))[0].injector.get( conditionalComp.queryAllNodes(By.directive(ManualViewportDirective))[0].injector.get(
@ -527,7 +517,6 @@ import {fixmeIvy} from '@angular/private/testing';
expect(main.nativeElement).toHaveText('(, D)'); expect(main.nativeElement).toHaveText('(, D)');
}); });
}); });
}
@Component({selector: 'main', template: ''}) @Component({selector: 'main', template: ''})
class MainComp { class MainComp {

View File

@ -9,7 +9,7 @@
import {AfterContentChecked, AfterContentInit, AfterViewChecked, AfterViewInit, Component, ContentChild, ContentChildren, Directive, QueryList, TemplateRef, Type, ViewChild, ViewChildren, ViewContainerRef, asNativeElements} from '@angular/core'; import {AfterContentChecked, AfterContentInit, AfterViewChecked, AfterViewInit, Component, ContentChild, ContentChildren, Directive, QueryList, TemplateRef, Type, ViewChild, ViewChildren, ViewContainerRef, asNativeElements} from '@angular/core';
import {ComponentFixture, TestBed, async} from '@angular/core/testing'; import {ComponentFixture, TestBed, async} from '@angular/core/testing';
import {expect} from '@angular/platform-browser/testing/src/matchers'; import {expect} from '@angular/platform-browser/testing/src/matchers';
import {fixmeIvy, modifiedInIvy} from '@angular/private/testing'; import {fixmeIvy, ivyEnabled, modifiedInIvy} from '@angular/private/testing';
import {Subject} from 'rxjs'; import {Subject} from 'rxjs';
import {stringify} from '../../src/util'; import {stringify} from '../../src/util';
@ -637,11 +637,13 @@ describe('Query API', () => {
expect(q.query.length).toBe(0); expect(q.query.length).toBe(0);
}); });
fixmeIvy('unknown').it( modifiedInIvy('https://github.com/angular/angular/issues/15117 fixed in ivy')
'should not throw if a content template is queried and created in the view during change detection', .it('should not throw if a content template is queried and created in the view during change detection',
() => { () => {
@Component( @Component({
{selector: 'auto-projecting', template: '<div *ngIf="true; then: content"></div>'}) selector: 'auto-projecting',
template: '<div *ngIf="true; then: content"></div>'
})
class AutoProjecting { class AutoProjecting {
// TODO(issue/24571): // TODO(issue/24571):
// remove '!'. // remove '!'.
@ -666,6 +668,35 @@ describe('Query API', () => {
expect(q.query.length).toBe(0); expect(q.query.length).toBe(0);
}); });
if (ivyEnabled) {
// The fixed version of the "should not throw if a content template is queried and created in
// the view during change detection" test. This test is a different as ivy fixes
// https://github.com/angular/angular/issues/15117 present in the view engine.
it('should not throw if a content template is queried and created in the view during change detection - fixed in ivy',
() => {
@Component(
{selector: 'auto-projecting', template: '<div *ngIf="true; then: content"></div>'})
class AutoProjecting {
// TODO(issue/24571):
// remove '!'.
@ContentChild(TemplateRef)
content !: TemplateRef<any>;
// TODO(issue/24571):
// remove '!'.
@ContentChildren(TextDirective)
query !: QueryList<TextDirective>;
}
TestBed.configureTestingModule({declarations: [AutoProjecting]});
const template =
'<auto-projecting #q><ng-template><div text="1"></div></ng-template></auto-projecting>';
const view = createTestCmpAndDetectChanges(MyComp0, template);
const q = view.debugElement.children[0].references !['q'];
expect(q.query.length).toBe(1);
});
}
}); });
}); });

View File

@ -32,7 +32,8 @@ function declareTests(config?: {useJit: boolean}) {
describe('platform pipes', () => { describe('platform pipes', () => {
beforeEach(() => { TestBed.configureCompiler({...config}); }); beforeEach(() => { TestBed.configureCompiler({...config}); });
fixmeIvy('unknown').it('should overwrite them by custom pipes', () => { fixmeIvy('FW-798: Handle pipes with duplicate names')
.it('should overwrite them by custom pipes', () => {
TestBed.configureTestingModule({declarations: [CustomPipe]}); TestBed.configureTestingModule({declarations: [CustomPipe]});
const template = '{{true | somePipe}}'; const template = '{{true | somePipe}}';
TestBed.overrideComponent(MyComp1, {set: {template}}); TestBed.overrideComponent(MyComp1, {set: {template}});
@ -351,8 +352,9 @@ function declareTests(config?: {useJit: boolean}) {
}); });
}); });
fixmeIvy('unknown').it( fixmeIvy('FW-797: @ContentChildren results are assigned after @Input bindings')
'should support @ContentChild and @Input on the same property for static queries', () => { .it('should support @ContentChild and @Input on the same property for static queries',
() => {
@Directive({selector: 'test'}) @Directive({selector: 'test'})
class Test { class Test {
// TODO(issue/24571): remove '!'. // TODO(issue/24571): remove '!'.
@ -375,8 +377,8 @@ function declareTests(config?: {useJit: boolean}) {
TestBed.configureTestingModule({declarations: [App, Test]}).createComponent(App); TestBed.configureTestingModule({declarations: [App, Test]}).createComponent(App);
fixture.detectChanges(); fixture.detectChanges();
const testDirs = const testDirs = fixture.debugElement.queryAll(By.directive(Test))
fixture.debugElement.queryAll(By.directive(Test)).map(el => el.injector.get(Test)); .map(el => el.injector.get(Test));
expect(testDirs[0].tpl).toBeUndefined(); expect(testDirs[0].tpl).toBeUndefined();
expect(testDirs[1].tpl).toBeDefined(); expect(testDirs[1].tpl).toBeDefined();
expect(testDirs[2].tpl).toBeDefined(); expect(testDirs[2].tpl).toBeDefined();

View File

@ -102,29 +102,30 @@ import {fixmeIvy} from '@angular/private/testing';
function declareTests( function declareTests(
{ngUrl, templateDecorator}: {ngUrl, templateDecorator}:
{ngUrl: string, templateDecorator: (template: string) => { [key: string]: any }}) { {ngUrl: string, templateDecorator: (template: string) => { [key: string]: any }}) {
fixmeIvy('unknown').it( fixmeIvy('FW-682: Compiler error handling')
'should use the right source url in html parse errors', fakeAsync(() => { .it('should use the right source url in html parse errors', fakeAsync(() => {
@Component({...templateDecorator('<div>\n </error>')}) @Component({...templateDecorator('<div>\n </error>')})
class MyComp { class MyComp {
} }
expect(() => compileAndCreateComponent(MyComp)) expect(() => compileAndCreateComponent(MyComp))
.toThrowError( .toThrowError(new RegExp(
new RegExp(`Template parse errors[\\s\\S]*${ngUrl.replace('$', '\\$')}@1:2`)); `Template parse errors[\\s\\S]*${ngUrl.replace('$', '\\$')}@1:2`));
})); }));
fixmeIvy('unknown').it( fixmeIvy('FW-682: Compiler error handling')
'should use the right source url in template parse errors', fakeAsync(() => { .it('should use the right source url in template parse errors', fakeAsync(() => {
@Component({...templateDecorator('<div>\n <div unknown="{{ctxProp}}"></div>')}) @Component({...templateDecorator('<div>\n <div unknown="{{ctxProp}}"></div>')})
class MyComp { class MyComp {
} }
expect(() => compileAndCreateComponent(MyComp)) expect(() => compileAndCreateComponent(MyComp))
.toThrowError( .toThrowError(new RegExp(
new RegExp(`Template parse errors[\\s\\S]*${ngUrl.replace('$', '\\$')}@1:7`)); `Template parse errors[\\s\\S]*${ngUrl.replace('$', '\\$')}@1:7`));
})); }));
fixmeIvy('unknown').it('should create a sourceMap for templates', fakeAsync(() => { fixmeIvy('FW-223: Generate source maps during template compilation')
.it('should create a sourceMap for templates', fakeAsync(() => {
const template = `Hello World!`; const template = `Hello World!`;
@Component({...templateDecorator(template)}) @Component({...templateDecorator(template)})
@ -133,8 +134,7 @@ import {fixmeIvy} from '@angular/private/testing';
compileAndCreateComponent(MyComp); compileAndCreateComponent(MyComp);
const sourceMap = const sourceMap = getSourceMap('ng:///DynamicTestModule/MyComp.ngfactory.js');
getSourceMap('ng:///DynamicTestModule/MyComp.ngfactory.js');
expect(sourceMap.sources).toEqual([ expect(sourceMap.sources).toEqual([
'ng:///DynamicTestModule/MyComp.ngfactory.js', ngUrl 'ng:///DynamicTestModule/MyComp.ngfactory.js', ngUrl
]); ]);
@ -142,8 +142,8 @@ import {fixmeIvy} from '@angular/private/testing';
})); }));
fixmeIvy('unknown').it( fixmeIvy('FW-223: Generate source maps during template compilation')
'should report source location for di errors', fakeAsync(() => { .it('should report source location for di errors', fakeAsync(() => {
const template = `<div>\n <div someDir></div></div>`; const template = `<div>\n <div someDir></div></div>`;
@Component({...templateDecorator(template)}) @Component({...templateDecorator(template)})
@ -170,8 +170,8 @@ import {fixmeIvy} from '@angular/private/testing';
}); });
})); }));
fixmeIvy('unknown').it( fixmeIvy('FW-223: Generate source maps during template compilation')
'should report di errors with multiple elements and directives', fakeAsync(() => { .it('should report di errors with multiple elements and directives', fakeAsync(() => {
const template = `<div someDir></div><div someDir="throw"></div>`; const template = `<div someDir></div><div someDir="throw"></div>`;
@Component({...templateDecorator(template)}) @Component({...templateDecorator(template)})
@ -202,8 +202,8 @@ import {fixmeIvy} from '@angular/private/testing';
}); });
})); }));
fixmeIvy('unknown').it( fixmeIvy('FW-223: Generate source maps during template compilation')
'should report source location for binding errors', fakeAsync(() => { .it('should report source location for binding errors', fakeAsync(() => {
const template = `<div>\n <span [title]="createError()"></span></div>`; const template = `<div>\n <span [title]="createError()"></span></div>`;
@Component({...templateDecorator(template)}) @Component({...templateDecorator(template)})
@ -233,8 +233,8 @@ import {fixmeIvy} from '@angular/private/testing';
}); });
})); }));
fixmeIvy('unknown').it( fixmeIvy('FW-223: Generate source maps during template compilation')
'should report source location for event errors', fakeAsync(() => { .it('should report source location for event errors', fakeAsync(() => {
const template = `<div>\n <span (click)="createError()"></span></div>`; const template = `<div>\n <span (click)="createError()"></span></div>`;
@Component({...templateDecorator(template)}) @Component({...templateDecorator(template)})