From 1a85de302d64f03de7f619aa467dac2e3403b527 Mon Sep 17 00:00:00 2001 From: Pawel Kozlowski Date: Tue, 15 Jan 2019 15:21:41 +0100 Subject: [PATCH] test(ivy): add root cause analysis for the remaining projection test (#28152) Initial thinking was that the bug is in the content projection logic but it turned out to be a wrong assumption - hence adding a test to illustrate that basic content projection of view containers works correctly. What fails in the marked test is the logic quering debug nodes - content peojection is fine but we never create the 'B' text node since we call show() method on the "wrong" directive instance. PR Close #28152 --- .../linker/projection_integration_spec.ts | 88 ++++++++++++------- 1 file changed, 57 insertions(+), 31 deletions(-) diff --git a/packages/core/test/linker/projection_integration_spec.ts b/packages/core/test/linker/projection_integration_spec.ts index 10f23806ab..91a48c28b4 100644 --- a/packages/core/test/linker/projection_integration_spec.ts +++ b/packages/core/test/linker/projection_integration_spec.ts @@ -543,48 +543,74 @@ describe('projection', () => { expect(main.nativeElement).toHaveText('B(A)'); }); - fixmeIvy('unknown').it('should project filled view containers into a view container', () => { + it('should project view containers', () => { TestBed.configureTestingModule( - {declarations: [ConditionalContentComponent, ManualViewportDirective]}); + {declarations: [SingleContentTagComponent, ManualViewportDirective]}); TestBed.overrideComponent(MainComp, { set: { - template: '' + - '
A
' + - 'B' + - '
C
' + - '
D
' + - '
' + template: '' + + '
A
' + + 'B' + + '
C
' + + '
' } }); + const main = TestBed.createComponent(MainComp); - - const conditionalComp = main.debugElement.query(By.directive(ConditionalContentComponent)); - - const viewViewportDir = - conditionalComp.queryAllNodes(By.directive(ManualViewportDirective))[0].injector.get( + const manualDirective = + main.debugElement.queryAllNodes(By.directive(ManualViewportDirective))[0].injector.get( ManualViewportDirective); - expect(main.nativeElement).toHaveText('(, D)'); - expect(main.nativeElement).toHaveText('(, D)'); + expect(main.nativeElement).toHaveText('AC'); - viewViewportDir.show(); + manualDirective.show(); main.detectChanges(); - expect(main.nativeElement).toHaveText('(AC, D)'); - - const contentViewportDir = - conditionalComp.queryAllNodes(By.directive(ManualViewportDirective))[1].injector.get( - ManualViewportDirective); - - contentViewportDir.show(); - main.detectChanges(); - expect(main.nativeElement).toHaveText('(ABC, D)'); - - // hide view viewport, and test that it also hides - // the content viewport's views - viewViewportDir.hide(); - main.detectChanges(); - expect(main.nativeElement).toHaveText('(, D)'); + expect(main.nativeElement).toHaveText('ABC'); }); + + fixmeIvy('FW-869: debugElement.queryAllNodes returns nodes in the wrong order') + .it('should project filled view containers into a view container', () => { + TestBed.configureTestingModule( + {declarations: [ConditionalContentComponent, ManualViewportDirective]}); + TestBed.overrideComponent(MainComp, { + set: { + template: '' + + '
A
' + + 'B' + + '
C
' + + '
D
' + + '
' + } + }); + const main = TestBed.createComponent(MainComp); + + const conditionalComp = main.debugElement.query(By.directive(ConditionalContentComponent)); + + const viewViewportDir = + conditionalComp.queryAllNodes(By.directive(ManualViewportDirective))[0].injector.get( + ManualViewportDirective); + + expect(main.nativeElement).toHaveText('(, D)'); + expect(main.nativeElement).toHaveText('(, D)'); + + viewViewportDir.show(); + main.detectChanges(); + expect(main.nativeElement).toHaveText('(AC, D)'); + + const contentViewportDir = + conditionalComp.queryAllNodes(By.directive(ManualViewportDirective))[1].injector.get( + ManualViewportDirective); + + contentViewportDir.show(); + main.detectChanges(); + expect(main.nativeElement).toHaveText('(ABC, D)'); + + // hide view viewport, and test that it also hides + // the content viewport's views + viewViewportDir.hide(); + main.detectChanges(); + expect(main.nativeElement).toHaveText('(, D)'); + }); }); @Component({selector: 'main', template: ''})