Skip to content

Commit

Permalink
Merge pull request #12 from jansaris/master
Browse files Browse the repository at this point in the history
Added the ability to toggle showing details of success/failed/skipped…
  • Loading branch information
a11smiles authored Oct 16, 2018
2 parents f550900 + 69e74a2 commit d5ac5c9
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 7 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,21 @@ module.exports = function(config) {
**Default:** `true`
**Description:** Determines whether the results are split into a separate file for each browser.

#### showSuccess
**Type:** Boolean
**Default:** `true`
**Description:** Determines whether the detailed results of the successfull tests are default shown or hidden in the browser (you are able to toggle live in the browser)

#### showFailed
**Type:** Boolean
**Default:** `true`
**Description:** Determines whether the detailed results of the failed tests are default shown or hidden in the browser (you are able to toggle live in the browser)

#### showSkipped
**Type:** Boolean
**Default:** `true`
**Description:** Determines whether the detailed results of the skipped tests are default shown or hidden in the browser (you are able to toggle live in the browser)

#### useHostedBootstrap
**Type:** Boolean
**Default:** `false`
Expand Down
16 changes: 13 additions & 3 deletions lib/reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ var HtmlDetailedReporter = function (baseReporterDecorator, config, logger, help
var outputDir = helper.normalizeWinPath(path.resolve(config.basePath, reporterConfig.dir || '_reports/'));
var autoReload = (reporterConfig.autoReload == null || reporterConfig.autoReload == undefined) ? true : reporterConfig.autoReload == false ? false : true;
var refreshTimeout = reporterConfig.refreshTimeout <= 0 ? 0 : !!reporterConfig.refreshTimeout ? reporterConfig.refreshTimeout : 1000;
var showSuccess = (reporterConfig.showSuccess == null || reporterConfig.showSuccess == undefined) ? true : reporterConfig.showSuccess == false ? false : true;
var showFailed = (reporterConfig.showFailed == null || reporterConfig.showFailed == undefined) ? true : reporterConfig.showFailed == false ? false : true;
var showSkipped = (reporterConfig.showSkipped == null || reporterConfig.showSkipped == undefined) ? true : reporterConfig.showSkipped == false ? false : true;

var splitResults;
if (reporterConfig.splitResults == undefined || reporterConfig.splitResults == null)
Expand Down Expand Up @@ -212,6 +215,13 @@ var HtmlDetailedReporter = function (baseReporterDecorator, config, logger, help
counts = getCounts();
}

var json = {
success: showSuccess,
danger: showFailed,
active: showSkipped
};
template = template.replace(/\{\{DefaultVisibilityStates\}\}/g, JSON.stringify(json));

// Replace remaining placeholders
template = template.replace('{{Auto_Reload}}', autoReload);
template = template.replace('{{Refresh_Timeout}}', refreshTimeout);
Expand Down Expand Up @@ -326,7 +336,7 @@ var HtmlDetailedReporter = function (baseReporterDecorator, config, logger, help

if (result.skipped) {
skipCnt[browser]++;
row.att('class', 'active');
row.att('class', 'active' + (showSkipped ? '' : ' hide'));
statusCell.att('class', 'status');
statusCell.text('Skipped');

Expand All @@ -335,7 +345,7 @@ var HtmlDetailedReporter = function (baseReporterDecorator, config, logger, help
}
else if (result.success) {
passCnt[browser]++;
row.att('class', 'success');
row.att('class', 'success' + (showSuccess ? '' : ' hide'));
statusCell.att('class', 'status');
statusCell.text('Passed');

Expand All @@ -344,7 +354,7 @@ var HtmlDetailedReporter = function (baseReporterDecorator, config, logger, help
}
else {
failCnt[browser]++;
row.att('class', 'danger');
row.att('class', 'danger' + (showFailed ? '' : ' hide'));
expandCell.att('rowspan', '2');
statusCell.att('class', 'status');
statusCell.att('rowspan', '2');
Expand Down
68 changes: 64 additions & 4 deletions template.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<script src="{{jquery_Path}}/jquery.min.js"></script>
<script>
var reload = shouldReload();
var visibleStates = {{DefaultVisibilityStates}};

function shouldReload() {
if (location.search != null && location.search != undefined && location.search.length > 0)
Expand All @@ -59,9 +60,65 @@
}
};

var loadValuesFromStorage = function(){
try{
var value = JSON.parse(localStorage['VisibleStates']);
visibleStates = value || visibleStates;
}catch(e){
//For some reason we don't support local getValueFromLocalStorage
//Old version of IE?
}
}

var saveValueInStorage = function(){
try{
localStorage['VisibleStates'] = JSON.stringify(visibleStates);
}catch(e){
//For some reason we don't support local getValueFromLocalStorage
//Old version of IE?
}
}

var toggleHiddenState = function(){
var id = $(this).attr('id');
if(!id || !visibleStates.hasOwnProperty(id)) return;
visibleStates[id] = !visibleStates[id];
displayItems(id);
saveValueInStorage();
}

var displayItems = function(id){
var visible = visibleStates[id];
var eye = $('span', '#'+ id);
var items = $(('.' + id), '.whiteout');

var openEye = 'glyphicon-eye-open';
var closedEye = 'glyphicon-eye-close';

if(visible) {
items.removeClass('hide');
eye.removeClass(closedEye);

eye.addClass(openEye);
}
else {
eye.removeClass(openEye);

items.addClass('hide');
eye.addClass(closedEye);
}
}

$(document).ready(function() {
setState(!reload);
setState(!reload);
loadValuesFromStorage();

for(name in visibleStates){
displayItems(name);
}

$('.countBox').click(toggleHiddenState);

$('#refreshBtn').click(function() {
setState(reload);
if (reload) {
Expand Down Expand Up @@ -110,21 +167,24 @@ <h2>{{Total_Test_Count}}</h2>
</div>
</div>
<div class="col-sm-2 col-sm-offset-1">
<div class="countBox success">
<div class="countBox success" id="success">
<h2>{{Total_Pass_Count}}</h2>
Passed Tests
<span class="glyphicon glyphicon-eye-open"></span>
</div>
</div>
<div class="col-sm-2 col-sm-offset-1">
<div class="countBox danger">
<div class="countBox danger" id="danger">
<h2>{{Total_Fail_Count}}</h2>
Failed Tests
<span class="glyphicon glyphicon-eye-open"></span>
</div>
</div>
<div class="col-sm-2 col-sm-offset-1">
<div class="countBox active">
<div class="countBox active" id="active">
<h2>{{Total_Skip_Count}}</h2>
Skipped Tests
<span class="glyphicon glyphicon-eye-open"></span>
</div>
</div>
</div>
Expand Down

0 comments on commit d5ac5c9

Please sign in to comment.