Skip to content
This repository has been archived by the owner on Sep 16, 2022. It is now read-only.

Commit

Permalink
chore(Test): Add more golden file testing around @deferred.
Browse files Browse the repository at this point in the history
Trying to get more context around the following bugs:
* #1539
* #1540

PiperOrigin-RevId: 208096491
  • Loading branch information
matanlurey authored and leonsenft committed Aug 9, 2018
1 parent 7a53d7a commit 3d9ce58
Show file tree
Hide file tree
Showing 5 changed files with 595 additions and 75 deletions.
34 changes: 29 additions & 5 deletions _goldens/test/_files/deferred/container_component.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,34 @@ import 'deferred_component.dart';

@Component(
selector: 'test-container',
template: r''''
<deferred-component @deferred>Foo</deferred-component>
<sample-component @deferred></sample-component>
template: r'''
<deferred-child-1 @deferred></deferred-child-1>
<template [ngIf]="showDeferredChild">
<deferred-child-2 @deferred></deferred-child-2>
</template>
<div *ngIf="showDeferredChild">
<deferred-child-3 @deferred #queryMe></deferred-child-3>
</div>
<deferred-child-without-ng-content @deferred>
Hello World
</deferred-child-without-ng-content>
<deferred-child-with-ng-content @deferred>
Hello World
</deferred-child-with-ng-content>
''',
directives: [DeferredChildComponent, SampleComponent],
directives: [
DeferredChild1Component,
DeferredChild2Component,
DeferredChild3Component,
DeferredChildComponentWithoutNgContent,
DeferredChildComponentWithNgContent,
NgIf,
SampleComponent,
],
)
class TestContainerComponent {}
class TestContainerComponent {
bool showDeferredChild = true;

@ViewChild('queryMe')
DeferredChild3Component queryDeferredChild;
}
262 changes: 230 additions & 32 deletions _goldens/test/_files/deferred/container_component.template.golden
Original file line number Diff line number Diff line change
Expand Up @@ -13,54 +13,94 @@ import 'package:angular/angular.template.dart' as _ref0;
import 'package:angular/src/core/linker/app_view.dart';
import 'container_component.dart' as import1;
import 'package:angular/src/core/linker/view_container.dart';
import 'package:angular/src/common/directives/ng_if.dart';
import 'package:angular/src/core/render/api.dart';
import 'package:angular/src/core/linker/view_type.dart' as import4;
import 'package:angular/src/core/linker/view_type.dart' as import5;
import 'package:angular/src/core/change_detection/change_detection.dart';
import 'dart:html' as import6;
import 'package:angular/src/core/linker/app_view_utils.dart' as import7;
import 'package:angular/src/runtime.dart' as import8;
import 'dart:html' as import7;
import 'package:angular/src/core/linker/app_view_utils.dart' as import8;
import 'package:angular/src/runtime.dart' as import9;
import 'package:angular/angular.dart';
import 'package:angular/src/core/linker/template_ref.dart';
import 'deferred_component.template.dart' deferred as deflib1;
import 'deferred_component.dart' deferred as deflib0;
import 'package:_goldens/component.template.dart' deferred as deflib3;
import 'package:_goldens/component.dart' deferred as deflib2;

final List<dynamic> styles$TestContainerComponent = const [];

class ViewTestContainerComponent0 extends AppView<import1.TestContainerComponent> {
ViewContainer _appEl_0;
ViewContainer _appEl_1;
NgIf _NgIf_1_9;
ViewContainer _appEl_2;
bool _query_queryMe_1_0_isDirty = true;
NgIf _NgIf_2_9;
ViewContainer _appEl_3;
ViewContainer _appEl_4;
static RenderComponentType _renderType;
ViewTestContainerComponent0(AppView<dynamic> parentView, int parentIndex) : super(import4.ViewType.component, {}, parentView, parentIndex, ChangeDetectionStrategy.CheckAlways) {
rootEl = import6.document.createElement('test-container');
_renderType ??= import7.appViewUtils.createRenderType((import8.isDevMode ? 'asset:_goldens/test/_files/deferred/container_component.dart' : null), ViewEncapsulation.None, styles$TestContainerComponent);
ViewTestContainerComponent0(AppView<dynamic> parentView, int parentIndex) : super(import5.ViewType.component, {}, parentView, parentIndex, ChangeDetectionStrategy.CheckAlways) {
rootEl = import7.document.createElement('test-container');
_renderType ??= import8.appViewUtils.createRenderType((import9.isDevMode ? 'asset:_goldens/test/_files/deferred/container_component.dart' : null), ViewEncapsulation.None, styles$TestContainerComponent);
setupComponentType(_renderType);
}
@override
ComponentRef<import1.TestContainerComponent> build() {
final _rootEl = rootEl;
final import6.HtmlElement parentRenderNode = initViewRoot(_rootEl);
import6.Text _text_0 = import6.Text('\'');
parentRenderNode.append(_text_0);
final import7.HtmlElement parentRenderNode = initViewRoot(_rootEl);
final _anchor_0 = createViewContainerAnchor();
parentRenderNode.append(_anchor_0);
_appEl_0 = ViewContainer(0, null, this, _anchor_0);
TemplateRef _TemplateRef_0_7 = TemplateRef(_appEl_0, viewFactory_TestContainerComponent1);
loadDeferred(deflib0.loadLibrary, deflib1.loadLibrary, _appEl_0, _TemplateRef_0_7);
final _anchor_1 = createViewContainerAnchor();
parentRenderNode.append(_anchor_1);
_appEl_1 = ViewContainer(1, null, this, _anchor_1);
TemplateRef _TemplateRef_1_7 = TemplateRef(_appEl_1, viewFactory_TestContainerComponent1);
loadDeferred(deflib0.loadLibrary, deflib1.loadLibrary, _appEl_1, _TemplateRef_1_7);
TemplateRef _TemplateRef_1_8 = TemplateRef(_appEl_1, viewFactory_TestContainerComponent2);
_NgIf_1_9 = NgIf(_appEl_1, _TemplateRef_1_8);
final _anchor_2 = createViewContainerAnchor();
parentRenderNode.append(_anchor_2);
_appEl_2 = ViewContainer(2, null, this, _anchor_2);
TemplateRef _TemplateRef_2_7 = TemplateRef(_appEl_2, viewFactory_TestContainerComponent2);
loadDeferred(deflib2.loadLibrary, deflib3.loadLibrary, _appEl_2, _TemplateRef_2_7);
TemplateRef _TemplateRef_2_8 = TemplateRef(_appEl_2, viewFactory_TestContainerComponent4);
_NgIf_2_9 = NgIf(_appEl_2, _TemplateRef_2_8);
final _anchor_3 = createViewContainerAnchor();
parentRenderNode.append(_anchor_3);
_appEl_3 = ViewContainer(3, null, this, _anchor_3);
TemplateRef _TemplateRef_3_7 = TemplateRef(_appEl_3, viewFactory_TestContainerComponent6);
loadDeferred(deflib0.loadLibrary, deflib1.loadLibrary, _appEl_3, _TemplateRef_3_7);
final _anchor_4 = createViewContainerAnchor();
parentRenderNode.append(_anchor_4);
_appEl_4 = ViewContainer(4, null, this, _anchor_4);
TemplateRef _TemplateRef_4_7 = TemplateRef(_appEl_4, viewFactory_TestContainerComponent7);
loadDeferred(deflib0.loadLibrary, deflib1.loadLibrary, _appEl_4, _TemplateRef_4_7);
init(const [], null);
return null;
}

@override
void detectChangesInternal() {
final import1.TestContainerComponent _ctx = ctx;
_NgIf_1_9.ngIf = _ctx.showDeferredChild;
_NgIf_2_9.ngIf = _ctx.showDeferredChild;
_appEl_1.detectChangesInNestedViews();
_appEl_2.detectChangesInNestedViews();
if (!import8.AppViewUtils.throwOnChanges) {
if (_query_queryMe_1_0_isDirty) {
ctx.queryDeferredChild = import8.firstOrNull(_appEl_2.mapNestedViews((_ViewTestContainerComponent4 nestedView) {
return nestedView._appEl_1.mapNestedViews((_ViewTestContainerComponent5 nestedView) {
return [nestedView._DeferredChild3Component_0_5];
});
}));
_query_queryMe_1_0_isDirty = false;
}
}
_appEl_0.detectChangesInNestedViews();
_appEl_3.detectChangesInNestedViews();
_appEl_4.detectChangesInNestedViews();
}

@override
void destroyInternal() {
_appEl_1?.destroyNestedViews();
_appEl_2?.destroyNestedViews();
}
}

Expand All @@ -69,19 +109,18 @@ AppView<import1.TestContainerComponent> viewFactory_TestContainerComponent0(AppV
}

class _ViewTestContainerComponent1 extends AppView<import1.TestContainerComponent> {
import6.Element _el_0;
import7.Element _el_0;
AppView _compView_0;
dynamic _DeferredChildComponent_0_5;
_ViewTestContainerComponent1(AppView<dynamic> parentView, int parentIndex) : super(import4.ViewType.embedded, {}, parentView, parentIndex, ChangeDetectionStrategy.CheckAlways) {
dynamic _DeferredChild1Component_0_5;
_ViewTestContainerComponent1(AppView<dynamic> parentView, int parentIndex) : super(import5.ViewType.embedded, {}, parentView, parentIndex, ChangeDetectionStrategy.CheckAlways) {
componentType = ViewTestContainerComponent0._renderType;
}
@override
ComponentRef<import1.TestContainerComponent> build() {
_compView_0 = deflib1.viewFactory_DeferredChildComponent0(this, 0);
_compView_0 = deflib1.viewFactory_DeferredChild1Component0(this, 0);
_el_0 = _compView_0.rootEl;
_DeferredChildComponent_0_5 = deflib0.DeferredChildComponent();
import6.Text _text_1 = import6.Text('Foo');
_compView_0.create(_DeferredChildComponent_0_5, []);
_DeferredChild1Component_0_5 = deflib0.DeferredChild1Component();
_compView_0.create(_DeferredChild1Component_0_5, []);
init0(_el_0);
return null;
}
Expand All @@ -102,18 +141,43 @@ AppView<import1.TestContainerComponent> viewFactory_TestContainerComponent1(AppV
}

class _ViewTestContainerComponent2 extends AppView<import1.TestContainerComponent> {
import6.Element _el_0;
ViewContainer _appEl_0;
_ViewTestContainerComponent2(AppView<dynamic> parentView, int parentIndex) : super(import5.ViewType.embedded, {}, parentView, parentIndex, ChangeDetectionStrategy.CheckAlways) {
componentType = ViewTestContainerComponent0._renderType;
}
@override
ComponentRef<import1.TestContainerComponent> build() {
final _anchor_0 = createViewContainerAnchor();
_appEl_0 = ViewContainer(0, null, this, _anchor_0);
TemplateRef _TemplateRef_0_7 = TemplateRef(_appEl_0, viewFactory_TestContainerComponent3);
loadDeferred(deflib0.loadLibrary, deflib1.loadLibrary, _appEl_0, _TemplateRef_0_7);
init0(_anchor_0);
return null;
}

@override
void detectChangesInternal() {
_appEl_0.detectChangesInNestedViews();
}
}

AppView<import1.TestContainerComponent> viewFactory_TestContainerComponent2(AppView<dynamic> parentView, int parentIndex) {
return _ViewTestContainerComponent2(parentView, parentIndex);
}

class _ViewTestContainerComponent3 extends AppView<import1.TestContainerComponent> {
import7.Element _el_0;
AppView _compView_0;
dynamic _SampleComponent_0_5;
_ViewTestContainerComponent2(AppView<dynamic> parentView, int parentIndex) : super(import4.ViewType.embedded, {}, parentView, parentIndex, ChangeDetectionStrategy.CheckAlways) {
dynamic _DeferredChild2Component_0_5;
_ViewTestContainerComponent3(AppView<dynamic> parentView, int parentIndex) : super(import5.ViewType.embedded, {}, parentView, parentIndex, ChangeDetectionStrategy.CheckAlways) {
componentType = ViewTestContainerComponent0._renderType;
}
@override
ComponentRef<import1.TestContainerComponent> build() {
_compView_0 = deflib3.viewFactory_SampleComponent0(this, 0);
_compView_0 = deflib1.viewFactory_DeferredChild2Component0(this, 0);
_el_0 = _compView_0.rootEl;
_SampleComponent_0_5 = deflib2.SampleComponent();
_compView_0.create(_SampleComponent_0_5, []);
_DeferredChild2Component_0_5 = deflib0.DeferredChild2Component();
_compView_0.create(_DeferredChild2Component_0_5, []);
init0(_el_0);
return null;
}
Expand All @@ -129,16 +193,150 @@ class _ViewTestContainerComponent2 extends AppView<import1.TestContainerComponen
}
}

AppView<import1.TestContainerComponent> viewFactory_TestContainerComponent2(AppView<dynamic> parentView, int parentIndex) {
return _ViewTestContainerComponent2(parentView, parentIndex);
AppView<import1.TestContainerComponent> viewFactory_TestContainerComponent3(AppView<dynamic> parentView, int parentIndex) {
return _ViewTestContainerComponent3(parentView, parentIndex);
}

class _ViewTestContainerComponent4 extends AppView<import1.TestContainerComponent> {
import7.DivElement _el_0;
ViewContainer _appEl_1;
_ViewTestContainerComponent4(AppView<dynamic> parentView, int parentIndex) : super(import5.ViewType.embedded, {}, parentView, parentIndex, ChangeDetectionStrategy.CheckAlways) {
componentType = ViewTestContainerComponent0._renderType;
}
@override
ComponentRef<import1.TestContainerComponent> build() {
var doc = import7.document;
_el_0 = doc.createElement('div');
final _anchor_1 = createViewContainerAnchor();
_el_0.append(_anchor_1);
_appEl_1 = ViewContainer(1, 0, this, _anchor_1);
TemplateRef _TemplateRef_1_7 = TemplateRef(_appEl_1, viewFactory_TestContainerComponent5);
loadDeferred(deflib0.loadLibrary, deflib1.loadLibrary, _appEl_1, _TemplateRef_1_7);
init0(_el_0);
return null;
}

@override
void detectChangesInternal() {
_appEl_1.detectChangesInNestedViews();
}
}

AppView<import1.TestContainerComponent> viewFactory_TestContainerComponent4(AppView<dynamic> parentView, int parentIndex) {
return _ViewTestContainerComponent4(parentView, parentIndex);
}

class _ViewTestContainerComponent5 extends AppView<import1.TestContainerComponent> {
import7.Element _el_0;
AppView _compView_0;
dynamic _DeferredChild3Component_0_5;
_ViewTestContainerComponent5(AppView<dynamic> parentView, int parentIndex) : super(import5.ViewType.embedded, {}, parentView, parentIndex, ChangeDetectionStrategy.CheckAlways) {
componentType = ViewTestContainerComponent0._renderType;
}
@override
ComponentRef<import1.TestContainerComponent> build() {
_compView_0 = deflib1.viewFactory_DeferredChild3Component0(this, 0);
_el_0 = _compView_0.rootEl;
_DeferredChild3Component_0_5 = deflib0.DeferredChild3Component();
_compView_0.create(_DeferredChild3Component_0_5, []);
init0(_el_0);
return null;
}

@override
void detectChangesInternal() {
_compView_0.detectChanges();
}

@override
void dirtyParentQueriesInternal() {
import9.unsafeCast<ViewTestContainerComponent0>(parentView.parentView)._query_queryMe_1_0_isDirty = true;
}

@override
void destroyInternal() {
_compView_0?.destroy();
}
}

AppView<import1.TestContainerComponent> viewFactory_TestContainerComponent5(AppView<dynamic> parentView, int parentIndex) {
return _ViewTestContainerComponent5(parentView, parentIndex);
}

class _ViewTestContainerComponent6 extends AppView<import1.TestContainerComponent> {
import7.Element _el_0;
AppView _compView_0;
dynamic _DeferredChildComponentWithoutNgContent_0_5;
_ViewTestContainerComponent6(AppView<dynamic> parentView, int parentIndex) : super(import5.ViewType.embedded, {}, parentView, parentIndex, ChangeDetectionStrategy.CheckAlways) {
componentType = ViewTestContainerComponent0._renderType;
}
@override
ComponentRef<import1.TestContainerComponent> build() {
_compView_0 = deflib1.viewFactory_DeferredChildComponentWithoutNgContent0(this, 0);
_el_0 = _compView_0.rootEl;
_DeferredChildComponentWithoutNgContent_0_5 = deflib0.DeferredChildComponentWithoutNgContent();
import7.Text _text_1 = import7.Text('Hello World');
_compView_0.create(_DeferredChildComponentWithoutNgContent_0_5, []);
init0(_el_0);
return null;
}

@override
void detectChangesInternal() {
_compView_0.detectChanges();
}

@override
void destroyInternal() {
_compView_0?.destroy();
}
}

AppView<import1.TestContainerComponent> viewFactory_TestContainerComponent6(AppView<dynamic> parentView, int parentIndex) {
return _ViewTestContainerComponent6(parentView, parentIndex);
}

class _ViewTestContainerComponent7 extends AppView<import1.TestContainerComponent> {
import7.Element _el_0;
AppView _compView_0;
dynamic _DeferredChildComponentWithNgContent_0_5;
_ViewTestContainerComponent7(AppView<dynamic> parentView, int parentIndex) : super(import5.ViewType.embedded, {}, parentView, parentIndex, ChangeDetectionStrategy.CheckAlways) {
componentType = ViewTestContainerComponent0._renderType;
}
@override
ComponentRef<import1.TestContainerComponent> build() {
_compView_0 = deflib1.viewFactory_DeferredChildComponentWithNgContent0(this, 0);
_el_0 = _compView_0.rootEl;
_DeferredChildComponentWithNgContent_0_5 = deflib0.DeferredChildComponentWithNgContent();
import7.Text _text_1 = import7.Text('Hello World');
_compView_0.create(_DeferredChildComponentWithNgContent_0_5, [
[_text_1]
]);
init0(_el_0);
return null;
}

@override
void detectChangesInternal() {
_compView_0.detectChanges();
}

@override
void destroyInternal() {
_compView_0?.destroy();
}
}

AppView<import1.TestContainerComponent> viewFactory_TestContainerComponent7(AppView<dynamic> parentView, int parentIndex) {
return _ViewTestContainerComponent7(parentView, parentIndex);
}

final List<dynamic> styles$TestContainerComponentHost = const [];

class _ViewTestContainerComponentHost0 extends AppView<import1.TestContainerComponent> {
ViewTestContainerComponent0 _compView_0;
import1.TestContainerComponent _TestContainerComponent_0_5;
_ViewTestContainerComponentHost0(AppView<dynamic> parentView, int parentIndex) : super(import4.ViewType.host, {}, parentView, parentIndex, ChangeDetectionStrategy.CheckAlways);
_ViewTestContainerComponentHost0(AppView<dynamic> parentView, int parentIndex) : super(import5.ViewType.host, {}, parentView, parentIndex, ChangeDetectionStrategy.CheckAlways);
@override
ComponentRef<import1.TestContainerComponent> build() {
_compView_0 = ViewTestContainerComponent0(this, 0);
Expand Down
Loading

0 comments on commit 3d9ce58

Please sign in to comment.