Skip to content

Commit

Permalink
feat: add report creation date
Browse files Browse the repository at this point in the history
  • Loading branch information
CatWithApple committed Mar 28, 2019
1 parent 80b7e92 commit e84757e
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 8 deletions.
3 changes: 2 additions & 1 deletion lib/report-builder-factory/report-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ module.exports = class ReportBuilder {
skips: _.uniq(this._skips, JSON.stringify),
suites: this._tree.children,
config: {defaultView, baseHost, scaleImages, lazyLoadOffset},
extraItems: this._extraItems
extraItems: this._extraItems,
date: new Date().toString()
}, this._stats);
}

Expand Down
10 changes: 7 additions & 3 deletions lib/static/components/summary/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ class Summary extends Component {
failed: PropTypes.number.isRequired,
skipped: PropTypes.number.isRequired,
retries: PropTypes.number.isRequired
})
}),
date: PropTypes.string.isRequired
}

render() {
const {date} = this.props;
const {total, passed, failed, skipped, retries} = this.props.stats;

return (
Expand All @@ -27,18 +29,20 @@ class Summary extends Component {
<SummaryKey label="Failed" value={failed} isFailed={true}/>
<SummaryKey label="Skipped" value={skipped}/>
<SummaryKey label="Retries" value={retries}/>
<div className='summary__date'>created at {date}</div>
</dl>
);
}
}

export default connect(
(state) => {
const {stats} = state;
const {stats, date} = state;
const {filteredBrowsers} = state.view;
const statsToShow = getStats(stats, filteredBrowsers);

return {
stats: statsToShow
stats: statsToShow,
date
};
})(Summary);
5 changes: 3 additions & 2 deletions lib/static/modules/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import url from 'url';
import actionNames from './action-names';
import defaultState from './default-state';
import {assign, merge, filter, map, clone, cloneDeep, reduce, find, last} from 'lodash';
import {isSuiteFailed, setStatusToAll, findNode, setStatusForBranch} from './utils';
import {isSuiteFailed, setStatusToAll, findNode, setStatusForBranch, dateToLocaleString} from './utils';

const compiledData = window.data || defaultState;
const localStorage = window.localStorage;

function getInitialState(compiledData) {
const {skips, suites, config, total, updated, passed,
failed, skipped, warned, retries, perBrowser, extraItems, gui = false} = compiledData;
failed, skipped, warned, retries, perBrowser, extraItems, gui = false, date} = compiledData;
const formattedSuites = formatSuitesData(suites);
const parsedURL = new URL(window.location.href);
const filteredBrowsers = parsedURL.searchParams.getAll('browser');
Expand All @@ -21,6 +21,7 @@ function getInitialState(compiledData) {
skips,
config,
extraItems,
date: dateToLocaleString(date),
stats: {
all: {total, updated, passed, failed, skipped, retries, warned},
perBrowser
Expand Down
13 changes: 11 additions & 2 deletions lib/static/modules/utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const {forOwn, pick, isArray, find, get, values} = require('lodash');
const {forOwn, pick, isArray, find, get, values, isEmpty} = require('lodash');
const {isFailStatus, isErroredStatus, isSkippedStatus, determineStatus} = require('../../common-utils');
const {getCommonErrors} = require('../../constants/errors');

Expand Down Expand Up @@ -154,6 +154,14 @@ function getStats(stats, filteredBrowsers) {
return resStats;
}

function dateToLocaleString(date) {
if (!date) {
return '';
}
const lang = isEmpty(navigator.languages) ? navigator.language : navigator.languages[0];
return new Date(date).toLocaleString(lang);
}

module.exports = {
hasNoRefImageErrors,
hasFails,
Expand All @@ -166,5 +174,6 @@ module.exports = {
setStatusForBranch,
shouldSuiteBeShownByName,
shouldSuiteBeShownByBrowser,
getStats
getStats,
dateToLocaleString
};
5 changes: 5 additions & 0 deletions lib/static/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -589,3 +589,8 @@ a:active {
opacity: 0.3;
background-color: #FF00FF;
}

.summary__date {
float: right;
color: gray;
}

0 comments on commit e84757e

Please sign in to comment.