Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat: add report creation date
  • Loading branch information
CatWithApple committed Mar 28, 2019
commit e84757e1ef8e36ea29bc020fd07293bfaf07ce32
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

почему оно обязательное то?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

просто потому, что мы контролируем это в dateToLocaleString

}

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

я бы одной строкой выводил, тут же всего 2 поля

};
})(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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

кажется, ты здесь немного упоролся - давай просто время с AM/PM оставим и все

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Проблема в основном с положением месяцев относительно дней. Нашим пользователям, полагаю, будет удобнее DD.MM.YYYY, а по дефолту MM/DD/YYYY.

new Date().toLocaleString()
"3/28/2019, 1:18:26 PM"

new Date().toLocaleString('en-US')
"3/28/2019, 1:18:35 PM"

new Date().toLocaleString('en-GB')
"28/03/2019, 13:18:38"

new Date().toLocaleString('ru')
"28.03.2019, 13:18:42"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а мне все таки нравится. Я постоянно забываю PM это утро или вечер. Плюс неудобно читать, что дата вторым значением указана. Го голосовать ;)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я постоянно забываю PM это утро или вечер

рукалицо

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

кулакподбородок

if (!date) {
return '';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а в каком случае мы можем в это условие попасть? Кажется его выгасить можно

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

если в gui режиме

}
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;
}