Skip to content

Commit 89aeed8

Browse files
committed
Fix for #601 proper display of spec groups in html report
1 parent 8721ab0 commit 89aeed8

File tree

2 files changed

+73
-13
lines changed

2 files changed

+73
-13
lines changed

galen-core/src/main/resources/html-report/galen-report.js

Lines changed: 53 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,15 @@ Vue.component('layout-spec', {
368368
this.bus.$emit('spec-clicked', this.spec, this.layout);
369369
}
370370
}
371-
})
371+
});
372+
373+
Vue.component('layout-spec-group', {
374+
props: ['layout', 'specgroup', 'bus'],
375+
template: '#tpl-spec-group',
376+
methods: {
377+
toggleReportNode: toggleReportNode
378+
}
379+
});
372380

373381
Vue.component('layout-report', {
374382
props: ['layout'],
@@ -656,18 +664,31 @@ function enrichObjectAndReturnHasFailure(object) {
656664
object.expanded = false;
657665
object.hasFailure = false;
658666

659-
_.forEach(object.specs, function (spec) {
660-
if (spec.errors && spec.errors.length > 0) {
661-
object.hasFailure = true;
662-
}
663-
if (spec.subLayout && spec.subLayout.sections) {
664-
_.forEach(spec.subLayout.sections, function (subSection) {
665-
if (enrichSectionAndReturnHasFailure(subSection)) {
666-
object.hasFailure = true;
667-
}
668-
});
669-
}
670-
});
667+
var enrichSpec = function(parent) {
668+
return function (spec) {
669+
if (spec.errors && spec.errors.length > 0) {
670+
parent.hasFailure = true;
671+
}
672+
if (spec.subLayout && spec.subLayout.sections) {
673+
_.forEach(spec.subLayout.sections, function (subSection) {
674+
if (enrichSectionAndReturnHasFailure(subSection)) {
675+
parent.hasFailure = true;
676+
}
677+
});
678+
}
679+
};
680+
};
681+
682+
_.forEach(object.specs, enrichSpec(object));
683+
if (object.specGroups) {
684+
_.forEach(object.specGroups, function (specGroup) {
685+
specGroup.expanded = false;
686+
_.forEach(specGroup.specs, enrichSpec(specGroup));
687+
if (specGroup.hasFailure) {
688+
object.hasFailure = true;
689+
}
690+
});
691+
}
671692
return object.hasFailure;
672693
}
673694

@@ -733,6 +754,14 @@ function expandOnlyErrorsInSection (section) {
733754
}
734755
});
735756
}
757+
_.forEach(object.specGroups, function (specGroup) {
758+
specGroup.expanded = specGroup.hasFailure;
759+
_.forEach(specGroup.specs, function (spec) {
760+
if (spec.subLayout && spec.subLayout.sections) {
761+
_.forEach(spec.subLayout.sections, expandOnlyErrorsInSection);
762+
}
763+
});
764+
});
736765
});
737766
}
738767

@@ -758,6 +787,17 @@ function visitEachSection(section, callback) {
758787
});
759788
_.forEach(section.objects, function (object) {
760789
callback(object, 'object');
790+
791+
_.forEach(object.specs, function (spec) {
792+
if (spec.subLayout) {
793+
_.forEach(spec.subLayout.sections, function (subSection) {
794+
visitEachSection(subSection, callback);
795+
});
796+
}
797+
});
798+
_.forEach(object.specGroups, function (specGroup) {
799+
callback(specGroup);
800+
});
761801
});
762802
}
763803

galen-core/src/main/resources/html-report/report-test.tpl.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,24 @@
189189
>{{object.name}}:</div>
190190
<div class="child-nodes" v-bind:class="{'child-nodes-expanded': object.expanded}">
191191
<layout-spec v-for="spec in object.specs" v-bind:spec="spec" v-bind:bus="bus" v-bind:layout="layout"></layout-spec>
192+
193+
<layout-spec-group v-if="object.specGroups"
194+
v-for="specGroup in object.specGroups"
195+
v-bind:specgroup="specGroup"
196+
v-bind:bus="bus"
197+
v-bind:layout="layout"
198+
></layout-spec-group>
199+
</div>
200+
</div>
201+
</template>
202+
203+
<template id="tpl-spec-group">
204+
<div class="layout-section" v-bind:class="{'has-failure': specgroup.hasFailure}">
205+
<div class="title icon-sprite-before"
206+
v-on:click="toggleReportNode(specgroup)"
207+
>{{specgroup.name}}:</div>
208+
<div class="child-nodes" v-bind:class="{'child-nodes-expanded': specgroup.expanded}">
209+
<layout-spec v-for="spec in specgroup.specs" v-bind:spec="spec" v-bind:bus="bus" v-bind:layout="layout"></layout-spec>
192210
</div>
193211
</div>
194212
</template>
@@ -207,6 +225,8 @@
207225
</div>
208226
</div>
209227
</template>
228+
229+
210230
<template id="tpl-screenshot-popup">
211231
<div>
212232
<div class="popup-shadow" v-on:click="$emit('close')"> </div>

0 commit comments

Comments
 (0)