html-reporter 9.5.1 → 9.6.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.
Files changed (38) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/lib/static/components/controls/browser-list/index.js +239 -0
  3. package/lib/static/components/controls/browser-list/index.styl +52 -0
  4. package/lib/static/components/controls/browser-list/label.js +60 -0
  5. package/lib/static/components/controls/browser-list/label.styl +18 -0
  6. package/lib/static/components/controls/browser-list/utils.js +43 -0
  7. package/lib/static/components/controls/controls.less +0 -4
  8. package/lib/static/components/controls/strict-match-filter-input.js +26 -35
  9. package/lib/static/components/controls/test-name-filter-input.js +29 -41
  10. package/lib/static/components/gui.js +2 -2
  11. package/lib/static/components/header/header.css +1 -0
  12. package/lib/static/components/header/summary/dbSummary.js +15 -13
  13. package/lib/static/components/header/summary/summary.css +6 -3
  14. package/lib/static/components/popup/index.js +85 -0
  15. package/lib/static/components/popup/index.styl +37 -0
  16. package/lib/static/components/report.js +2 -4
  17. package/lib/static/components/sticky-header/gui.js +12 -0
  18. package/lib/static/components/sticky-header/index.js +36 -0
  19. package/lib/static/components/sticky-header/index.styl +37 -0
  20. package/lib/static/components/sticky-header/report.js +14 -0
  21. package/lib/static/containers/array/array.styl +32 -0
  22. package/lib/static/containers/array/index.js +61 -0
  23. package/lib/static/gui.html +1 -13
  24. package/lib/static/gui.min.css +1 -723
  25. package/lib/static/gui.min.js +61 -47
  26. package/lib/static/hooks/useElementSize.js +30 -0
  27. package/lib/static/hooks/useEventListener.js +25 -0
  28. package/lib/static/hooks/useWindowSize.js +25 -0
  29. package/lib/static/index.html +1 -13
  30. package/lib/static/report.min.css +1 -723
  31. package/lib/static/report.min.js +61 -47
  32. package/lib/static/styles.css +20 -103
  33. package/package.json +11 -9
  34. package/webpack.common.js +29 -18
  35. package/webpack.dev.js +4 -0
  36. package/webpack.prod.js +4 -9
  37. package/lib/static/2.min.js +0 -1925
  38. package/lib/static/components/controls/browser-list.js +0 -153
package/CHANGELOG.md CHANGED
@@ -2,6 +2,17 @@
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="9.6.0"></a>
6
+ # [9.6.0](https://github.com/gemini-testing/html-reporter/compare/v9.5.1...v9.6.0) (2022-12-12)
7
+
8
+
9
+ ### Features
10
+
11
+ * sticky header ([f2aea96](https://github.com/gemini-testing/html-reporter/commit/f2aea96))
12
+ * **browser-list:** add "Only" and "Except" buttons ([29be12d](https://github.com/gemini-testing/html-reporter/commit/29be12d))
13
+
14
+
15
+
5
16
  <a name="9.5.1"></a>
6
17
  ## [9.5.1](https://github.com/gemini-testing/html-reporter/compare/v9.5.0...v9.5.1) (2022-11-23)
7
18
 
@@ -0,0 +1,239 @@
1
+ 'use strict';
2
+
3
+ import React, {useState, useMemo, useEffect, useCallback} from 'react';
4
+ import {flatten, isEmpty, get, chain, compact} from 'lodash';
5
+ import PropTypes from 'prop-types';
6
+ import CheckboxTree from 'react-checkbox-tree';
7
+
8
+ import Label from './label';
9
+ import {mkBrowserIcon, buildComplexId} from './utils';
10
+ import Popup from '../../popup';
11
+ import ArrayContainer from '../../../containers/array';
12
+
13
+ import 'react-checkbox-tree/lib/react-checkbox-tree.css';
14
+ import './index.styl';
15
+
16
+ const BrowserList = (props) => {
17
+ const {available, onChange, selected: selectedProp} = props;
18
+
19
+ const [expanded, setExpanded] = useState([]);
20
+ const [selected, setSelected] = useState(buidSelectedItems());
21
+ const [elements, setElements] = useState([]);
22
+ const treeDataMap = useMemo(buildTreeDataMap, [available]);
23
+ const nodes = useMemo(prepareTreeData, [available]);
24
+ const selectAll = useCallback(_selectAll, [setExpanded, treeDataMap]);
25
+
26
+ useEffect(() => {
27
+ updateLabels();
28
+ onChange && onChange(formatSelectedData(selected));
29
+ }, [selected]);
30
+
31
+ function buildTreeDataMap() {
32
+ return available.reduce((acc, {id: browserId, versions}) => {
33
+ const hasChildren = !isEmpty(versions) && versions.length > 1;
34
+
35
+ acc[buildComplexId(browserId)] = {browserId, isLeaf: !hasChildren};
36
+
37
+ if (hasChildren) {
38
+ versions.forEach(version => {
39
+ acc[buildComplexId(browserId, version)] = {browserId, version, isLeaf: true};
40
+ });
41
+ }
42
+
43
+ return acc;
44
+ }, {});
45
+ }
46
+
47
+ function buidSelectedItems() {
48
+ if (!selectedProp || !selectedProp.length) {
49
+ return [];
50
+ }
51
+
52
+ const selectedItems = selectedProp.map(({id, versions}) => {
53
+ if (!versions) {
54
+ return [];
55
+ }
56
+
57
+ const availableNode = available.find((item) => item.id === id);
58
+ const shouldDrawOnlyRootNode = get(availableNode, 'versions.length', 1) === 1;
59
+
60
+ if (shouldDrawOnlyRootNode) {
61
+ return buildComplexId(id);
62
+ }
63
+
64
+ return versions.length
65
+ ? versions.map((version) => buildComplexId(id, version))
66
+ : availableNode.versions.map(version => buildComplexId(id, version));
67
+ });
68
+
69
+ return flatten(selectedItems);
70
+ }
71
+
72
+ function prepareTreeData() {
73
+ const mkNode = ({browserId, version, icon}) => ({
74
+ icon,
75
+ data: {browserId, version},
76
+ value: buildComplexId(browserId, version),
77
+ label: mkLabel({browserId, version, elements})
78
+ });
79
+
80
+ return available.map(({id: browserId, versions}) => {
81
+ const node = mkNode({browserId, icon: mkBrowserIcon(browserId)});
82
+
83
+ if (!isEmpty(versions) && versions.length > 1) {
84
+ node.children = versions.map(version => mkNode({browserId, version}));
85
+ }
86
+
87
+ return node;
88
+ });
89
+ }
90
+
91
+ function _selectAll() {
92
+ const leaves = Object.keys(treeDataMap).filter(key => treeDataMap[key].isLeaf);
93
+ const cb = selected => selected.length !== leaves.length
94
+ ? leaves
95
+ : selected;
96
+
97
+ setSelected(cb);
98
+ }
99
+
100
+ function mkLabel({browserId, version, elements}) {
101
+ return (
102
+ <Label
103
+ treeDataMap={treeDataMap}
104
+ browserId={browserId}
105
+ version={version}
106
+ elements={elements}
107
+ setSelected={setSelected}
108
+ />
109
+ );
110
+ }
111
+
112
+ function buildElements() {
113
+ const availableVersionsCount = available.reduce((acc, browser) => {
114
+ acc[browser.id] = browser.versions ? browser.versions.length : undefined;
115
+ return acc;
116
+ }, {});
117
+
118
+ const selectedBrowsers = selected.reduce((acc, value) => {
119
+ if (!treeDataMap[value]) {
120
+ return acc;
121
+ }
122
+
123
+ const {browserId, version} = treeDataMap[value];
124
+
125
+ acc[browserId] = acc[browserId] || [];
126
+
127
+ if (version) {
128
+ acc[browserId].push(version);
129
+ }
130
+
131
+ return acc;
132
+ }, {});
133
+
134
+ const elementsNew = [];
135
+
136
+ for (const browserId in selectedBrowsers) {
137
+ const versions = selectedBrowsers[browserId];
138
+ if (!versions.length || (availableVersionsCount[browserId] === versions.length)) {
139
+ elementsNew.push(browserId);
140
+ } else {
141
+ elementsNew.push(...versions.map(version => buildComplexId(browserId, version)));
142
+ }
143
+ }
144
+
145
+ return elementsNew;
146
+ }
147
+
148
+ function updateLabels() {
149
+ const newElements = buildElements();
150
+
151
+ if (get(elements, 'length', 0) !== 1 && get(newElements, 'length', 0) !== 1) {
152
+ setElements(newElements);
153
+ return;
154
+ }
155
+
156
+ const updatingValues = [
157
+ get(newElements, 'length', undefined) === 1 && newElements[0],
158
+ get(elements, 'length', undefined) === 1 && elements[0]
159
+ ];
160
+
161
+ const nodesFlat = nodes.reduce((arr, node) => {
162
+ const children = node.children || [];
163
+
164
+ arr.push(node);
165
+ children.forEach(child => arr.push(child));
166
+
167
+ return arr;
168
+ }, []);
169
+
170
+ const updatingNodes = nodesFlat.filter(node => {
171
+ const {browserId, version} = node.data;
172
+
173
+ return updatingValues.includes(buildComplexId(browserId, version));
174
+ });
175
+
176
+ updatingNodes.forEach(node => {
177
+ const {browserId, version} = node.data;
178
+ node.label = mkLabel({browserId, version, elements: newElements});
179
+ });
180
+
181
+ setElements(newElements);
182
+ }
183
+
184
+ function formatSelectedData(selectedItems) {
185
+ return chain(selectedItems)
186
+ .reduce((acc, value) => {
187
+ const {browserId, version} = treeDataMap[value] || {};
188
+
189
+ if (browserId) {
190
+ acc[browserId] = acc[browserId] || [];
191
+ acc[browserId].push(version);
192
+ }
193
+
194
+ return acc;
195
+ }, {})
196
+ .map((versions, id) => ({id, versions: compact(versions)}))
197
+ .value();
198
+ }
199
+
200
+ if (isEmpty(available)) {
201
+ return (<div></div>);
202
+ }
203
+
204
+ return (
205
+ <div className="browserlist">
206
+ <Popup
207
+ target={<ArrayContainer elements={elements} placeholder="Browsers" />}
208
+ action="click"
209
+ >
210
+ <div>
211
+ <button className='rct-controls' onClick={selectAll}>
212
+ Select all
213
+ </button>
214
+ <CheckboxTree
215
+ nodes={nodes}
216
+ checked={selected}
217
+ expanded={expanded}
218
+ onCheck={setSelected}
219
+ onExpand={setExpanded}
220
+ />
221
+ </div>
222
+ </Popup>
223
+ </div>
224
+ );
225
+ };
226
+
227
+ BrowserList.propTypes = {
228
+ available: PropTypes.arrayOf(PropTypes.shape({
229
+ id: PropTypes.string,
230
+ versions: PropTypes.arrayOf(PropTypes.string)
231
+ })).isRequired,
232
+ selected: PropTypes.arrayOf(PropTypes.shape({
233
+ id: PropTypes.string,
234
+ versions: PropTypes.arrayOf(PropTypes.string)
235
+ })),
236
+ onChange: PropTypes.func.isRequired
237
+ };
238
+
239
+ export default BrowserList;
@@ -0,0 +1,52 @@
1
+ .browserlist
2
+ label-bg-color = #3333cc1a
3
+ button-hover-bg-color = #99999950
4
+
5
+ .array
6
+ width 220px
7
+
8
+ .rct-controls
9
+ width 100%
10
+ height 25px
11
+ margin-bottom 10px
12
+ border none
13
+ border-radius 5px
14
+ cursor pointer
15
+ background-color label-bg-color
16
+ transition background-color 150ms linear
17
+
18
+ &:hover
19
+ background-color button-hover-bg-color;
20
+
21
+ .rct-node-parent
22
+ .rct-node-leaf
23
+ .rct-node-icon
24
+ display none
25
+
26
+ .rct-node-icon
27
+ color black
28
+ text-align center
29
+
30
+ .rct-text
31
+ label
32
+ display inline-flex
33
+ width 100%
34
+ user-select none
35
+
36
+ &:not(:hover)
37
+ .rct-label__controls
38
+ visibility hidden
39
+
40
+ &:hover
41
+ background-color: label-bg-color
42
+
43
+ .rct-label__controls
44
+ visibility visible
45
+
46
+ .rct-title
47
+ display inherit
48
+ width 100%
49
+
50
+ .rct-label
51
+ display inherit
52
+ width 100%
@@ -0,0 +1,60 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+
4
+ import {buildComplexId} from './utils';
5
+
6
+ import './label.styl';
7
+
8
+ const Label = ({treeDataMap, browserId, version, elements, setSelected}) => {
9
+ const id = buildComplexId(browserId, version);
10
+ const isChildren = key => !version && treeDataMap[key].browserId === browserId;
11
+ const getLeaves = () => Object.keys(treeDataMap).filter(key => treeDataMap[key].isLeaf);
12
+
13
+ const onOnlyClick = (event) => {
14
+ event.stopPropagation();
15
+
16
+ const leaves = getLeaves();
17
+ const ids = leaves.includes(id)
18
+ ? [id]
19
+ : leaves.filter(key => isChildren(key));
20
+
21
+ setSelected(ids);
22
+ };
23
+
24
+ const onExceptClick = (event) => {
25
+ event.stopPropagation();
26
+
27
+ const leaves = getLeaves();
28
+ const ids = leaves.includes(id)
29
+ ? leaves.filter(key => key !== id)
30
+ : leaves.filter(key => !isChildren(key));
31
+
32
+ setSelected(ids);
33
+ };
34
+
35
+ return (
36
+ <span className='rct-label'>
37
+ <span className='rct-label__title'>{version || browserId}</span>
38
+ {elements && elements.length === 1 && elements[0] === id
39
+ ? <button className='rct-label__controls' onClick={onExceptClick}>Except</button>
40
+ : <button className='rct-label__controls' onClick={onOnlyClick}>Only</button>
41
+ }
42
+ </span>
43
+ );
44
+ };
45
+
46
+ Label.propTypes = {
47
+ treeDataMap: PropTypes.shape({
48
+ [PropTypes.string]: PropTypes.shape({
49
+ browserId: PropTypes.string.isRequired,
50
+ version: PropTypes.string,
51
+ isLeaf: PropTypes.bool.isRequired
52
+ })
53
+ }),
54
+ browserId: PropTypes.string.isRequired,
55
+ version: PropTypes.string,
56
+ elements: PropTypes.arrayOf(PropTypes.string),
57
+ setSelected: PropTypes.func.isRequired
58
+ };
59
+
60
+ export default Label;
@@ -0,0 +1,18 @@
1
+ .rct-label
2
+ .rct-label__title
3
+ margin-right 25px
4
+
5
+ .rct-label__controls
6
+ cursor pointer
7
+ width 70px
8
+ margin-left auto
9
+ border none
10
+ border-radius 5px
11
+ background-color inherit
12
+ opacity 0.5
13
+ transition background-color 150ms linear,
14
+ opacity 150ms linear
15
+
16
+ &:hover
17
+ background-color #99999950
18
+ opacity 1
@@ -0,0 +1,43 @@
1
+ import React from 'react';
2
+ import {isString} from 'lodash';
3
+
4
+ const valueToIcon = {
5
+ google: 'chrome',
6
+ chrome: 'chrome',
7
+ firefox: 'firefox',
8
+ safari: 'safari',
9
+ edge: 'edge',
10
+ yandex: 'yandex',
11
+ yabro: 'yandex',
12
+ ie: 'internet-explorer',
13
+ explorer: 'internet-explorer',
14
+ opera: 'opera',
15
+ phone: 'mobile',
16
+ mobile: 'mobile',
17
+ tablet: 'tablet',
18
+ ipad: 'tablet'
19
+ };
20
+
21
+ export function mkBrowserIcon(browser) {
22
+ const mkIcon = (iconName) => <i className={`fa fa-${iconName}`} aria-hidden="true" />;
23
+
24
+ if (!isString(browser)) {
25
+ return mkIcon('browser');
26
+ }
27
+
28
+ const lowerValue = browser.toLowerCase();
29
+
30
+ for (const pattern in valueToIcon) {
31
+ if (lowerValue.includes(pattern)) {
32
+ return mkIcon(valueToIcon[pattern]);
33
+ }
34
+ }
35
+
36
+ return mkIcon('browser');
37
+ }
38
+
39
+ export function buildComplexId(browserId, version) {
40
+ return version
41
+ ? `${browserId} (${version})`
42
+ : browserId;
43
+ }
@@ -56,10 +56,6 @@
56
56
  width: auto;
57
57
  min-width: 220px;
58
58
  max-width: 400px;
59
-
60
- .rc-tree-select-selection-item {
61
- height: 21px;
62
- }
63
59
  }
64
60
  }
65
61
 
@@ -1,46 +1,37 @@
1
1
  'use strict';
2
2
 
3
- import React, {Component} from 'react';
3
+ import React, {useState} from 'react';
4
4
  import PropTypes from 'prop-types';
5
5
  import {bindActionCreators} from 'redux';
6
6
  import {connect} from 'react-redux';
7
7
  import {Checkbox} from 'semantic-ui-react';
8
8
  import * as actions from '../../modules/actions';
9
9
 
10
- class StrictMatchFilterInput extends Component {
11
- static propTypes = {
12
- strictMatchFilter: PropTypes.bool.isRequired,
13
- actions: PropTypes.object.isRequired
14
- }
15
-
16
- constructor(props) {
17
- super(props);
18
-
19
- this.state = {
20
- strictMatchFilter: this.props.strictMatchFilter
21
- };
22
- }
23
-
24
- _onChange = () => {
25
- const nextState = !this.state.strictMatchFilter;
26
-
27
- this.setState({strictMatchFilter: nextState});
28
- this.props.actions.setStrictMatchFilter(nextState);
29
- }
30
-
31
- render() {
32
- return (
33
- <div className="strict-match-filter">
34
- <Checkbox
35
- toggle
36
- label="Strict match"
37
- onChange={this._onChange}
38
- checked={this.state.strictMatchFilter}
39
- />
40
- </div>
41
- );
42
- }
43
- }
10
+ const StrictMatchFilterInput = ({strictMatchFilter, actions}) => {
11
+ const [checked, setChecked] = useState(strictMatchFilter);
12
+
13
+ const onChange = () => {
14
+ const newState = !checked;
15
+ setChecked(newState);
16
+ actions.setStrictMatchFilter(newState);
17
+ };
18
+
19
+ return (
20
+ <div className="strict-match-filter">
21
+ <Checkbox
22
+ toggle
23
+ label="Strict match"
24
+ onChange={onChange}
25
+ checked={checked}
26
+ />
27
+ </div>
28
+ );
29
+ };
30
+
31
+ StrictMatchFilterInput.propTypes = {
32
+ strictMatchFilter: PropTypes.bool.isRequired,
33
+ actions: PropTypes.object.isRequired
34
+ };
44
35
 
45
36
  export default connect(
46
37
  (state) => ({strictMatchFilter: state.view.strictMatchFilter}),
@@ -1,52 +1,40 @@
1
1
  'use strict';
2
2
 
3
- import React, {Component} from 'react';
3
+ import React, {useState, useCallback} from 'react';
4
4
  import PropTypes from 'prop-types';
5
5
  import {bindActionCreators} from 'redux';
6
6
  import {connect} from 'react-redux';
7
7
  import {debounce} from 'lodash';
8
8
  import * as actions from '../../modules/actions';
9
9
 
10
- class TestNameFilterInput extends Component {
11
- static propTypes = {
12
- testNameFilter: PropTypes.string.isRequired,
13
- actions: PropTypes.object.isRequired
14
- }
15
-
16
- constructor(props) {
17
- super(props);
18
-
19
- this.state = {
20
- testNameFilter: this.props.testNameFilter
21
- };
22
-
23
- this._onChange = (event) => {
24
- this.setState({testNameFilter: event.target.value});
25
- this._debouncedUpdate();
26
- };
27
-
28
- this._debouncedUpdate = debounce(
29
- () => {
30
- this.props.actions.updateTestNameFilter(this.state.testNameFilter);
31
- },
32
- 500,
33
- {
34
- 'maxWait': 1000
35
- }
36
- );
37
- }
38
-
39
- render() {
40
- return (
41
- <input
42
- className="filter__input-name"
43
- value={this.state.testNameFilter}
44
- placeholder="filter by test name"
45
- onChange={this._onChange}
46
- />
47
- );
48
- }
49
- }
10
+ const TestNameFilterInput = ({actions, testNameFilter: testNameFilterProp}) => {
11
+ const [testNameFilter, setTestNameFilter] = useState(testNameFilterProp);
12
+
13
+ const _debouncedUpdate = useCallback(debounce(
14
+ (testName) => actions.updateTestNameFilter(testName),
15
+ 500,
16
+ {maxWait: 3000}
17
+ ), []);
18
+
19
+ const onChange = (event) => {
20
+ setTestNameFilter(event.target.value);
21
+ _debouncedUpdate(event.target.value);
22
+ };
23
+
24
+ return (
25
+ <input
26
+ className="filter__input-name"
27
+ value={testNameFilter}
28
+ placeholder="filter by test name"
29
+ onChange={onChange}
30
+ />
31
+ );
32
+ };
33
+
34
+ TestNameFilterInput.propTypes = {
35
+ testNameFilter: PropTypes.string.isRequired,
36
+ actions: PropTypes.object.isRequired
37
+ };
50
38
 
51
39
  export default connect(
52
40
  (state) => ({testNameFilter: state.view.testNameFilter}),
@@ -6,7 +6,7 @@ import {bindActionCreators} from 'redux';
6
6
 
7
7
  import {ROOT} from '../../constants/extension-points';
8
8
  import * as actions from '../modules/actions';
9
- import ControlButtons from './controls/gui-controls';
9
+ import StickyHeader from './sticky-header/gui';
10
10
  import Loading from './loading';
11
11
  import ModalContainer from '../containers/modal';
12
12
  import MainTree from './main-tree';
@@ -81,7 +81,7 @@ class Gui extends Component {
81
81
  <CustomScripts scripts={customScripts}/>
82
82
  {notificationElem}
83
83
  <FaviconChanger />
84
- <ControlButtons />
84
+ <StickyHeader />
85
85
  <main className="container">
86
86
  <MainTree />
87
87
  </main>
@@ -1,4 +1,5 @@
1
1
  .header {
2
+ padding-top: 15px;
2
3
  padding-bottom: 15px;
3
4
  border-bottom: 1px solid #ccc;
4
5
  }
@@ -1,8 +1,10 @@
1
1
  import React, {Component} from 'react';
2
- import {Dropdown, Popup, Button} from 'semantic-ui-react';
2
+ import {Dropdown, Button, Ref} from 'semantic-ui-react';
3
3
  import PropTypes from 'prop-types';
4
4
  import classNames from 'classnames';
5
5
 
6
+ import Popup from '../../popup';
7
+
6
8
  export default class DbSummaryKey extends Component {
7
9
  /*
8
10
  Component to display the amount of fetched databases (and response statuses of all databases).
@@ -19,10 +21,6 @@ export default class DbSummaryKey extends Component {
19
21
  collapsed: true
20
22
  };
21
23
 
22
- _toggleDatabases = () => {
23
- this.setState({collapsed: !this.state.collapsed});
24
- };
25
-
26
24
  render() {
27
25
  const {fetchDbDetails} = this.props;
28
26
 
@@ -46,18 +44,22 @@ export default class DbSummaryKey extends Component {
46
44
  {'db-info_failed': isFailed}
47
45
  );
48
46
 
49
- return (
50
- <Popup
51
- trigger={<Button
47
+ const DbBtn = React.forwardRef((props, ref) => (
48
+ <Ref innerRef={ref}>
49
+ <Button
52
50
  content={title}
53
51
  icon="angle down"
54
52
  className={btnClassNames}
55
53
  basic
56
- />}
57
- position="bottom center"
58
- flowing
59
- wide
60
- hoverable
54
+ />
55
+ </Ref>
56
+ ));
57
+
58
+ return (
59
+ <Popup
60
+ className="db-info__popup"
61
+ action="hover"
62
+ target={<DbBtn />}
61
63
  >
62
64
  {additionalInfo}
63
65
  </Popup>