test(ivy): update root causes for @angular/core TestBed failures (#27650)
PR Close #27650
This commit is contained in:
parent
0397e08153
commit
10c7b89f14
@ -1472,26 +1472,28 @@ const TEST_COMPILER_PROVIDERS: Provider[] = [
|
|||||||
expect(log).toEqual(['inner-start', 'main-tpl', 'outer-tpl']);
|
expect(log).toEqual(['inner-start', 'main-tpl', 'outer-tpl']);
|
||||||
});
|
});
|
||||||
|
|
||||||
fixmeIvy('unknown').it(
|
fixmeIvy(
|
||||||
'should dirty check projected views if the declaration place is dirty checked', () => {
|
'FW-842: View engine dirty-checks projected views when the declaration place is checked')
|
||||||
ctx.detectChanges(false);
|
.it('should dirty check projected views if the declaration place is dirty checked',
|
||||||
log = [];
|
() => {
|
||||||
innerComp.cdRef.detach();
|
ctx.detectChanges(false);
|
||||||
mainComp.cdRef.detectChanges();
|
log = [];
|
||||||
|
innerComp.cdRef.detach();
|
||||||
|
mainComp.cdRef.detectChanges();
|
||||||
|
|
||||||
expect(log).toEqual(['main-start', 'outer-start', 'main-tpl', 'outer-tpl']);
|
expect(log).toEqual(['main-start', 'outer-start', 'main-tpl', 'outer-tpl']);
|
||||||
|
|
||||||
log = [];
|
log = [];
|
||||||
outerComp.cdRef.detectChanges();
|
outerComp.cdRef.detectChanges();
|
||||||
|
|
||||||
expect(log).toEqual(['outer-start', 'outer-tpl']);
|
expect(log).toEqual(['outer-start', 'outer-tpl']);
|
||||||
|
|
||||||
log = [];
|
log = [];
|
||||||
outerComp.cdRef.detach();
|
outerComp.cdRef.detach();
|
||||||
mainComp.cdRef.detectChanges();
|
mainComp.cdRef.detectChanges();
|
||||||
|
|
||||||
expect(log).toEqual(['main-start', 'main-tpl']);
|
expect(log).toEqual(['main-start', 'main-tpl']);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -371,8 +371,8 @@ describe('projection', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (getDOM().supportsNativeShadowDOM()) {
|
if (getDOM().supportsNativeShadowDOM()) {
|
||||||
fixmeIvy('unknown').it(
|
fixmeIvy('FW-841: Content projection with ShadovDom v0 doesn\'t work')
|
||||||
'should support native content projection and isolate styles per component', () => {
|
.it('should support native content projection and isolate styles per component', () => {
|
||||||
TestBed.configureTestingModule({declarations: [SimpleNative1, SimpleNative2]});
|
TestBed.configureTestingModule({declarations: [SimpleNative1, SimpleNative2]});
|
||||||
TestBed.overrideComponent(MainComp, {
|
TestBed.overrideComponent(MainComp, {
|
||||||
set: {
|
set: {
|
||||||
|
@ -428,83 +428,84 @@ function declareTestsUsingBootstrap() {
|
|||||||
if (getDOM().supportsDOMEvents()) {
|
if (getDOM().supportsDOMEvents()) {
|
||||||
// This test needs a real DOM....
|
// This test needs a real DOM....
|
||||||
|
|
||||||
fixmeIvy('unknown').it('should keep change detecting if there was an error', (done) => {
|
fixmeIvy('FW-840: Exceptions thrown in event handlers are not reported to ErrorHandler')
|
||||||
@Component({
|
.it('should keep change detecting if there was an error', (done) => {
|
||||||
selector: COMP_SELECTOR,
|
@Component({
|
||||||
template:
|
selector: COMP_SELECTOR,
|
||||||
'<button (click)="next()"></button><button (click)="nextAndThrow()"></button><button (dirClick)="nextAndThrow()"></button><span>Value:{{value}}</span><span>{{throwIfNeeded()}}</span>'
|
template:
|
||||||
})
|
'<button (click)="next()"></button><button (click)="nextAndThrow()"></button><button (dirClick)="nextAndThrow()"></button><span>Value:{{value}}</span><span>{{throwIfNeeded()}}</span>'
|
||||||
class ErrorComp {
|
})
|
||||||
value = 0;
|
class ErrorComp {
|
||||||
thrownValue = 0;
|
value = 0;
|
||||||
next() { this.value++; }
|
thrownValue = 0;
|
||||||
nextAndThrow() {
|
next() { this.value++; }
|
||||||
this.value++;
|
nextAndThrow() {
|
||||||
this.throwIfNeeded();
|
this.value++;
|
||||||
}
|
this.throwIfNeeded();
|
||||||
throwIfNeeded() {
|
}
|
||||||
NgZone.assertInAngularZone();
|
throwIfNeeded() {
|
||||||
if (this.thrownValue !== this.value) {
|
NgZone.assertInAngularZone();
|
||||||
this.thrownValue = this.value;
|
if (this.thrownValue !== this.value) {
|
||||||
throw new Error(`Error: ${this.value}`);
|
this.thrownValue = this.value;
|
||||||
|
throw new Error(`Error: ${this.value}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Directive({selector: '[dirClick]'})
|
@Directive({selector: '[dirClick]'})
|
||||||
class EventDir {
|
class EventDir {
|
||||||
@Output()
|
@Output()
|
||||||
dirClick = new EventEmitter();
|
dirClick = new EventEmitter();
|
||||||
|
|
||||||
@HostListener('click', ['$event'])
|
@HostListener('click', ['$event'])
|
||||||
onClick(event: any) { this.dirClick.next(event); }
|
onClick(event: any) { this.dirClick.next(event); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [BrowserModule],
|
imports: [BrowserModule],
|
||||||
declarations: [ErrorComp, EventDir],
|
declarations: [ErrorComp, EventDir],
|
||||||
bootstrap: [ErrorComp],
|
bootstrap: [ErrorComp],
|
||||||
providers: [{provide: ErrorHandler, useValue: errorHandler}],
|
providers: [{provide: ErrorHandler, useValue: errorHandler}],
|
||||||
})
|
})
|
||||||
class TestModule {
|
class TestModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
platformBrowserDynamic().bootstrapModule(TestModule).then((ref) => {
|
platformBrowserDynamic().bootstrapModule(TestModule).then((ref) => {
|
||||||
NgZone.assertNotInAngularZone();
|
NgZone.assertNotInAngularZone();
|
||||||
const appRef = ref.injector.get(ApplicationRef) as ApplicationRef;
|
const appRef = ref.injector.get(ApplicationRef) as ApplicationRef;
|
||||||
const compRef = appRef.components[0] as ComponentRef<ErrorComp>;
|
const compRef = appRef.components[0] as ComponentRef<ErrorComp>;
|
||||||
const compEl = compRef.location.nativeElement;
|
const compEl = compRef.location.nativeElement;
|
||||||
const nextBtn = compEl.children[0];
|
const nextBtn = compEl.children[0];
|
||||||
const nextAndThrowBtn = compEl.children[1];
|
const nextAndThrowBtn = compEl.children[1];
|
||||||
const nextAndThrowDirBtn = compEl.children[2];
|
const nextAndThrowDirBtn = compEl.children[2];
|
||||||
|
|
||||||
nextBtn.click();
|
nextBtn.click();
|
||||||
assertValueAndErrors(compEl, 1, 0);
|
assertValueAndErrors(compEl, 1, 0);
|
||||||
nextBtn.click();
|
nextBtn.click();
|
||||||
assertValueAndErrors(compEl, 2, 2);
|
assertValueAndErrors(compEl, 2, 2);
|
||||||
|
|
||||||
nextAndThrowBtn.click();
|
nextAndThrowBtn.click();
|
||||||
assertValueAndErrors(compEl, 3, 4);
|
assertValueAndErrors(compEl, 3, 4);
|
||||||
nextAndThrowBtn.click();
|
nextAndThrowBtn.click();
|
||||||
assertValueAndErrors(compEl, 4, 6);
|
assertValueAndErrors(compEl, 4, 6);
|
||||||
|
|
||||||
nextAndThrowDirBtn.click();
|
nextAndThrowDirBtn.click();
|
||||||
assertValueAndErrors(compEl, 5, 8);
|
assertValueAndErrors(compEl, 5, 8);
|
||||||
nextAndThrowDirBtn.click();
|
nextAndThrowDirBtn.click();
|
||||||
assertValueAndErrors(compEl, 6, 10);
|
assertValueAndErrors(compEl, 6, 10);
|
||||||
|
|
||||||
// Assert that there were no more errors
|
// Assert that there were no more errors
|
||||||
expect(logger.errors.length).toBe(12);
|
expect(logger.errors.length).toBe(12);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
function assertValueAndErrors(compEl: any, value: number, errorIndex: number) {
|
function assertValueAndErrors(compEl: any, value: number, errorIndex: number) {
|
||||||
expect(compEl).toHaveText(`Value:${value}`);
|
expect(compEl).toHaveText(`Value:${value}`);
|
||||||
expect(logger.errors[errorIndex][0]).toBe('ERROR');
|
expect(logger.errors[errorIndex][0]).toBe('ERROR');
|
||||||
expect(logger.errors[errorIndex][1].message).toBe(`Error: ${value}`);
|
expect(logger.errors[errorIndex][1].message).toBe(`Error: ${value}`);
|
||||||
expect(logger.errors[errorIndex + 1][0]).toBe('ERROR CONTEXT');
|
expect(logger.errors[errorIndex + 1][0]).toBe('ERROR CONTEXT');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user