html-reporter 8.0.2 → 8.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ <a name="8.1.0"></a>
6
+ # [8.1.0](https://github.com/gemini-testing/html-reporter/compare/v8.0.2...v8.1.0) (2022-01-13)
7
+
8
+
9
+ ### Features
10
+
11
+ * implemented progress-bar of scroll ([49d5631](https://github.com/gemini-testing/html-reporter/commit/49d5631))
12
+
13
+
14
+
5
15
  <a name="8.0.2"></a>
6
16
  ## [8.0.2](https://github.com/gemini-testing/html-reporter/compare/v8.0.1...v8.0.2) (2021-12-28)
7
17
 
@@ -0,0 +1,38 @@
1
+ 'use strict';
2
+
3
+ import {extend} from 'lodash';
4
+ import React from 'react';
5
+ import {connect} from 'react-redux';
6
+
7
+ import {getVisibleRootSuiteIds} from '../../modules/selectors/tree';
8
+
9
+ const BottomProgressBar = (props) => {
10
+ const {progressBar: {currentRootSuiteId}, visibleRootSuiteIds} = props;
11
+ const suiteIdsIndexMap = React.useMemo(
12
+ () => visibleRootSuiteIds.reduce((map, suiteId, idx) => extend(map, {[suiteId]: idx}), {}),
13
+ [visibleRootSuiteIds]
14
+ );
15
+ const currentRootSuiteIdx = suiteIdsIndexMap[currentRootSuiteId];
16
+ const percent = 100 / (visibleRootSuiteIds.length - 1) * currentRootSuiteIdx;
17
+
18
+ return (
19
+ <div className="bottom-progress-bar">
20
+ <div className='bottom-progress-bar__progress-container'>
21
+ <div className='bottom-progress-bar__progress-bar' style={{width: `${percent}%`}}></div>
22
+ <div className='bottom-progress-bar__counter'>
23
+ {currentRootSuiteId}
24
+ <span>
25
+ {' '}(<strong>{currentRootSuiteIdx + 1}</strong> suite of <strong>{visibleRootSuiteIds.length}</strong>)
26
+ </span>
27
+ </div>
28
+ </div>
29
+ </div>
30
+ );
31
+ };
32
+
33
+ export default connect(
34
+ (state) => ({
35
+ progressBar: state.progressBar,
36
+ visibleRootSuiteIds: getVisibleRootSuiteIds(state)
37
+ }),
38
+ )(BottomProgressBar);
@@ -16,6 +16,7 @@ import CustomScripts from './custom-scripts';
16
16
  import clientEvents from '../../gui/constants/client-events';
17
17
  import FaviconChanger from './favicon-changer';
18
18
  import ExtensionPoint from './extension-point';
19
+ import BottomProgressBar from './bottom-progress-bar';
19
20
 
20
21
  class Gui extends Component {
21
22
  static propTypes = {
@@ -87,6 +88,7 @@ class Gui extends Component {
87
88
  </main>
88
89
  <Loading active={loading.active} content={loading.content} />
89
90
  <ModalContainer />
91
+ <BottomProgressBar />
90
92
  </ExtensionPoint>
91
93
  </Fragment>
92
94
  );
@@ -15,6 +15,7 @@ import MainTree from './main-tree';
15
15
  import CustomScripts from './custom-scripts';
16
16
  import FaviconChanger from './favicon-changer';
17
17
  import ExtensionPoint from './extension-point';
18
+ import BottomProgressBar from './bottom-progress-bar';
18
19
 
19
20
  class Report extends Component {
20
21
  static propTypes = {
@@ -56,6 +57,7 @@ class Report extends Component {
56
57
  <SkippedList />
57
58
  <MainTree />
58
59
  </main>
60
+ <BottomProgressBar />
59
61
  </ExtensionPoint>
60
62
  </Fragment>
61
63
  );
@@ -1,10 +1,12 @@
1
1
  import React, {Component} from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import {connect} from 'react-redux';
4
- import {isEmpty, flatMap} from 'lodash';
4
+ import {isEmpty, flatMap, find, once, throttle} from 'lodash';
5
5
  import {List, AutoSizer, CellMeasurer, CellMeasurerCache, WindowScroller} from 'react-virtualized';
6
6
  import ResizeObserver from 'rc-resize-observer';
7
+ import {bindActionCreators} from 'redux';
7
8
 
9
+ import * as actions from '../modules/actions';
8
10
  import SectionCommon from './section/section-common';
9
11
  import viewModes from '../../constants/view-modes';
10
12
  import {getVisibleRootSuiteIds} from '../modules/selectors/tree';
@@ -18,7 +20,7 @@ class Suites extends Component {
18
20
 
19
21
  _suitesMeasurementCache = new CellMeasurerCache({
20
22
  fixedWidth: true,
21
- defaultHeight: 250
23
+ defaultHeight: 40
22
24
  });
23
25
 
24
26
  _renderRow = ({index, key, style, parent}) => {
@@ -39,7 +41,7 @@ class Suites extends Component {
39
41
  rowIndex={index}
40
42
  >
41
43
  {({measure}) => (
42
- <div key={key} style={style}>
44
+ <div key={key} style={style} className="virtualized__row">
43
45
  <ResizeObserver onResize={measure}>
44
46
  <SectionCommon {...sectionProps} />
45
47
  </ResizeObserver>
@@ -49,6 +51,36 @@ class Suites extends Component {
49
51
  );
50
52
  }
51
53
 
54
+ _recalculateBottomProgressBar = throttle(() => {
55
+ const {actions} = this.props;
56
+ const nodes = Array.from(document.querySelectorAll('.virtualized__row'));
57
+
58
+ let visibleNode = find(nodes.slice().reverse(), (node) => {
59
+ const rect = node.getBoundingClientRect();
60
+ const bottomViewportWindow = document.documentElement.clientHeight - this._suitesMeasurementCache.defaultHeight;
61
+
62
+ return rect.top > 0 && rect.top <= bottomViewportWindow;
63
+ });
64
+
65
+ if (!visibleNode) {
66
+ visibleNode = find(nodes, (node) => {
67
+ const rect = node.getBoundingClientRect();
68
+
69
+ return rect.bottom > 0;
70
+ });
71
+ }
72
+
73
+ if (!visibleNode) {
74
+ return;
75
+ }
76
+
77
+ const suiteId = visibleNode.querySelector('.section__title').textContent;
78
+
79
+ actions.updateBottomProgressBar({currentRootSuiteId: suiteId});
80
+ }, 100)
81
+
82
+ _calculateInitialBottomProgressBar = once(() => setTimeout(this._recalculateBottomProgressBar, 0));
83
+
52
84
  _getSelectedFiltersInfo() {
53
85
  const {viewMode, filteredBrowsers, testNameFilter, strictMatchFilter} = this.props;
54
86
  const msgs = [];
@@ -86,7 +118,7 @@ class Suites extends Component {
86
118
 
87
119
  return (
88
120
  <div className="sections">
89
- <WindowScroller>
121
+ <WindowScroller onScroll={this._recalculateBottomProgressBar}>
90
122
  {({height, isScrolling, onChildScroll, scrollTop}) => (
91
123
  <AutoSizer disableHeight>
92
124
  {({width}) => (
@@ -97,6 +129,7 @@ class Suites extends Component {
97
129
  isScrolling={isScrolling}
98
130
  onScroll={onChildScroll}
99
131
  scrollTop={scrollTop}
132
+ onRowsRendered={this._calculateInitialBottomProgressBar}
100
133
  deferredMeasurementCache={this._suitesMeasurementCache}
101
134
  rowHeight={this._suitesMeasurementCache.rowHeight}
102
135
  rowCount={visibleRootSuiteIds.length}
@@ -119,5 +152,6 @@ export default connect(
119
152
  filteredBrowsers: state.view.filteredBrowsers,
120
153
  testNameFilter: state.view.testNameFilter,
121
154
  strictMatchFilter: state.view.strictMatchFilter
122
- })
155
+ }),
156
+ (dispatch) => ({actions: bindActionCreators(actions, dispatch)})
123
157
  )(Suites);