html-reporter 7.1.0 → 7.4.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 (60) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/README.md +44 -10
  3. package/lib/common-utils.js +14 -14
  4. package/lib/config/index.js +11 -7
  5. package/lib/constants/defaults.js +1 -1
  6. package/lib/constants/expand-modes.js +8 -0
  7. package/lib/constants/extension-points.js +1 -0
  8. package/lib/constants/plugin-events.js +10 -0
  9. package/lib/gui/constants/client-events.js +2 -4
  10. package/lib/gui/server.js +1 -4
  11. package/lib/gui/tool-runner/index.js +4 -2
  12. package/lib/gui/tool-runner/utils.js +4 -20
  13. package/lib/plugin-api.js +14 -1
  14. package/lib/report-builder/static.js +1 -0
  15. package/lib/server-utils.js +0 -1
  16. package/lib/sqlite-adapter.js +4 -1
  17. package/lib/static/components/controls/common-controls.js +5 -9
  18. package/lib/static/components/error-groups/item.js +12 -17
  19. package/lib/static/components/error-groups/list.js +45 -18
  20. package/lib/static/components/gui.js +10 -1
  21. package/lib/static/components/report.js +6 -1
  22. package/lib/static/components/section/body/index.js +14 -40
  23. package/lib/static/components/section/body/result.js +5 -1
  24. package/lib/static/components/section/section-browser.js +13 -53
  25. package/lib/static/components/section/section-common.js +23 -88
  26. package/lib/static/components/section/section-wrapper.js +2 -15
  27. package/lib/static/components/section/title/browser.js +2 -1
  28. package/lib/static/components/state/index.js +14 -82
  29. package/lib/static/components/state/screenshot.js +6 -22
  30. package/lib/static/components/state/state-error.js +1 -1
  31. package/lib/static/components/suites.js +100 -28
  32. package/lib/static/gui.html +1 -1
  33. package/lib/static/gui.min.css +1 -1
  34. package/lib/static/gui.min.js +23 -15
  35. package/lib/static/modules/action-names.js +3 -2
  36. package/lib/static/modules/actions.js +20 -31
  37. package/lib/static/modules/default-state.js +2 -1
  38. package/lib/static/modules/group-errors.js +3 -3
  39. package/lib/static/modules/middlewares/local-storage.js +0 -2
  40. package/lib/static/modules/middlewares/metrika.js +1 -6
  41. package/lib/static/modules/reducers/db.js +4 -2
  42. package/lib/static/modules/reducers/tree/helpers.js +28 -0
  43. package/lib/static/modules/reducers/tree/index.js +241 -0
  44. package/lib/static/modules/reducers/tree/nodes/browsers.js +99 -0
  45. package/lib/static/modules/reducers/tree/nodes/images.js +50 -0
  46. package/lib/static/modules/reducers/tree/nodes/results.js +13 -0
  47. package/lib/static/modules/reducers/tree/nodes/suites.js +217 -0
  48. package/lib/static/modules/reducers/view.js +7 -11
  49. package/lib/static/modules/selectors/tree.js +98 -145
  50. package/lib/static/modules/sqlite.js +20 -15
  51. package/lib/static/modules/utils.js +58 -10
  52. package/lib/static/report.min.css +1 -1
  53. package/lib/static/report.min.js +23 -15
  54. package/lib/static/styles.css +4 -8
  55. package/package.json +6 -6
  56. package/webpack.common.js +5 -0
  57. package/lib/constants/client-events.js +0 -6
  58. package/lib/static/components/state/placeholder.js +0 -10
  59. package/lib/static/modules/reducers/tree.js +0 -169
  60. package/sqlite.db +0 -0
@@ -34,7 +34,12 @@ class Report extends Component {
34
34
  const {allRootSuiteIds, fetchDbDetails} = this.props;
35
35
 
36
36
  if (!allRootSuiteIds.length && !fetchDbDetails.length) {
37
- return (<Loading active={true} />);
37
+ return (
38
+ <Fragment>
39
+ <Notifications theme={wybo}/>
40
+ <Loading active={true} />
41
+ </Fragment>
42
+ );
38
43
  }
39
44
 
40
45
  return (
@@ -18,36 +18,17 @@ class Body extends Component {
18
18
  // from store
19
19
  gui: PropTypes.bool.isRequired,
20
20
  running: PropTypes.bool.isRequired,
21
- viewRetryIndex: PropTypes.number,
22
- browserRetryIndex: PropTypes.number
21
+ retryIndex: PropTypes.number
23
22
  }
24
23
 
25
- constructor(props) {
26
- super(props);
27
-
28
- const retry = typeof this.props.viewRetryIndex === 'number'
29
- ? Math.min(this.props.viewRetryIndex, this.props.resultIds.length - 1)
30
- : this.props.resultIds.length - 1;
31
-
32
- this.state = {retry};
33
- }
34
-
35
- componentDidMount() {
36
- this._changeTestRetry({retryIndex: this.state.retry});
37
- }
24
+ onRetrySwitcherChange = (index) => {
25
+ const {browserId, retryIndex} = this.props;
38
26
 
39
- // eslint-disable-next-line camelcase
40
- UNSAFE_componentWillReceiveProps(nextProps) {
41
- if (nextProps.resultIds.length > this.props.resultIds.length) {
42
- const lastRetryIndex = nextProps.resultIds.length - 1;
43
- this.setState({retry: lastRetryIndex});
44
- this._changeTestRetry({retryIndex: lastRetryIndex});
27
+ if (index === retryIndex) {
28
+ return;
45
29
  }
46
- }
47
30
 
48
- onRetrySwitcherChange = (index) => {
49
- this.setState({retry: index});
50
- this._changeTestRetry({retryIndex: index, isUserClick: true});
31
+ this.props.actions.changeTestRetry({browserId, retryIndex: index});
51
32
  }
52
33
 
53
34
  onTestRetry = () => {
@@ -56,18 +37,8 @@ class Body extends Component {
56
37
  this.props.actions.retryTest({testName, browserName});
57
38
  }
58
39
 
59
- _changeTestRetry({retryIndex, isUserClick = false}) {
60
- const {browserId, browserRetryIndex} = this.props;
61
-
62
- if (retryIndex === browserRetryIndex) {
63
- return;
64
- }
65
-
66
- this.props.actions.changeTestRetry({browserId, retryIndex, isUserClick});
67
- }
68
-
69
40
  _addRetrySwitcher = () => {
70
- const {resultIds} = this.props;
41
+ const {resultIds, retryIndex} = this.props;
71
42
 
72
43
  if (resultIds.length <= 1) {
73
44
  return;
@@ -77,7 +48,7 @@ class Body extends Component {
77
48
  <div className="controls__item">
78
49
  <RetrySwitcher
79
50
  resultIds={resultIds}
80
- retryIndex={this.state.retry}
51
+ retryIndex={retryIndex}
81
52
  onChange={this.onRetrySwitcherChange}
82
53
  />
83
54
  </div>
@@ -102,7 +73,7 @@ class Body extends Component {
102
73
  }
103
74
 
104
75
  _getActiveResultId = () => {
105
- return this.props.resultIds[this.state.retry];
76
+ return this.props.resultIds[this.props.retryIndex];
106
77
  }
107
78
 
108
79
  render() {
@@ -126,10 +97,13 @@ class Body extends Component {
126
97
  }
127
98
 
128
99
  export default connect(
129
- ({gui, running, view: {retryIndex}, tree}, {browserId}) => {
100
+ ({gui, running, view: {retryIndex: viewRetryIndex}, tree}, {browserId}) => {
130
101
  const {retryIndex: browserRetryIndex} = tree.browsers.stateById[browserId] || {};
102
+ const retryIndex = typeof viewRetryIndex === 'number'
103
+ ? Math.min(viewRetryIndex, browserRetryIndex)
104
+ : browserRetryIndex;
131
105
 
132
- return {gui, running, viewRetryIndex: retryIndex, browserRetryIndex};
106
+ return {gui, running, retryIndex};
133
107
  },
134
108
  (dispatch) => ({actions: bindActionCreators(actions, dispatch)})
135
109
  )(Body);
@@ -4,6 +4,8 @@ import PropTypes from 'prop-types';
4
4
  import MetaInfo from './meta-info';
5
5
  import Description from './description';
6
6
  import Tabs from './tabs';
7
+ import ExtensionPoint from '../../extension-point';
8
+ import {RESULT_META} from '../../../../constants/extension-points';
7
9
 
8
10
  class Result extends Component {
9
11
  static propTypes = {
@@ -22,7 +24,9 @@ class Result extends Component {
22
24
 
23
25
  return (
24
26
  <Fragment>
25
- <MetaInfo result={result} testName={testName} />
27
+ <ExtensionPoint name={RESULT_META} result={result} testName={testName}>
28
+ <MetaInfo result={result} testName={testName} />
29
+ </ExtensionPoint>
26
30
  {result.description && <Description content={result.description} />}
27
31
  <Tabs result={result} />
28
32
  </Fragment>
@@ -10,15 +10,11 @@ import BrowserTitle from './title/browser';
10
10
  import BrowserSkippedTitle from './title/browser-skipped';
11
11
  import Body from './body';
12
12
  import {isSkippedStatus} from '../../../common-utils';
13
- import {isNodeFailed} from '../../modules/utils';
14
- import {mkShouldBrowserBeShown, mkHasBrowserFailedRetries} from '../../modules/selectors/tree';
15
13
 
16
14
  class SectionBrowser extends Component {
17
15
  static propTypes = {
18
16
  browserId: PropTypes.string.isRequired,
19
- errorGroupBrowserIds: PropTypes.array,
20
17
  // from store
21
- expand: PropTypes.string.isRequired,
22
18
  browser: PropTypes.shape({
23
19
  name: PropTypes.string.isRequired,
24
20
  resultIds: PropTypes.arrayOf(PropTypes.string).isRequired,
@@ -32,34 +28,15 @@ class SectionBrowser extends Component {
32
28
  skipReason: PropTypes.string
33
29
  }).isRequired,
34
30
  shouldBeShown: PropTypes.bool.isRequired,
35
- hasFailedRetries: PropTypes.bool.isRequired,
31
+ shouldBeOpened: PropTypes.bool.isRequired,
36
32
  // from SectionCommonWrapper
37
- shouldBeOpened: PropTypes.func.isRequired,
38
33
  sectionStatusResolver: PropTypes.func.isRequired
39
34
  }
40
35
 
41
- state = {
42
- opened: this.props.shouldBeOpened(this._getStates())
43
- }
36
+ onToggleSection = () => {
37
+ const {browserId, shouldBeOpened} = this.props;
44
38
 
45
- // eslint-disable-next-line camelcase
46
- UNSAFE_componentWillReceiveProps(nextProps) {
47
- const updatedStates = this._getStates(nextProps);
48
- this.setState({opened: this.props.shouldBeOpened(updatedStates)});
49
- }
50
-
51
- _onToggleSection = () => {
52
- this.setState({opened: !this.state.opened});
53
-
54
- this.props.actions.toggleBrowserSection(this.props.browserId);
55
- }
56
-
57
- _getStates(props = this.props) {
58
- const {expand, lastResult, hasFailedRetries} = props;
59
- const failed = isNodeFailed(lastResult);
60
- const retried = hasFailedRetries;
61
-
62
- return {failed, retried, expand};
39
+ this.props.actions.toggleBrowserSection({browserId, shouldBeOpened: !shouldBeOpened});
63
40
  }
64
41
 
65
42
  _generateSkippedTitle(skipReason) {
@@ -77,8 +54,7 @@ class SectionBrowser extends Component {
77
54
  return null;
78
55
  }
79
56
 
80
- const {browser, lastResult} = this.props;
81
- const {opened} = this.state;
57
+ const {browser, shouldBeOpened, lastResult} = this.props;
82
58
 
83
59
  const isSkippedLastResult = isSkippedStatus(lastResult.status);
84
60
  const hasRetries = browser.resultIds.length > 1;
@@ -91,7 +67,7 @@ class SectionBrowser extends Component {
91
67
  const isExecutedResult = hasRetries || lastResult.error || lastResult.imageIds.length > 0;
92
68
  const isSkipped = isSkippedLastResult && !isExecutedResult;
93
69
 
94
- const body = isSkipped || !opened
70
+ const body = isSkipped || !shouldBeOpened
95
71
  ? null
96
72
  : (
97
73
  <Body
@@ -110,14 +86,14 @@ class SectionBrowser extends Component {
110
86
  title={title}
111
87
  browserId={browser.id}
112
88
  lastResultId={lastResult.id}
113
- handler={this._onToggleSection}
89
+ handler={this.onToggleSection}
114
90
  />
115
91
  {body}
116
92
  </Fragment>
117
93
  );
118
94
 
119
95
  return (
120
- <div className={this.props.sectionStatusResolver({status: lastResult.status, opened})}>
96
+ <div className={this.props.sectionStatusResolver({status: lastResult.status, shouldBeOpened})}>
121
97
  {section}
122
98
  </div>
123
99
  );
@@ -125,28 +101,12 @@ class SectionBrowser extends Component {
125
101
  }
126
102
 
127
103
  export default connect(
128
- () => {
129
- const hasBrowserFailedRetries = mkHasBrowserFailedRetries();
130
- const shouldBrowserBeShown = mkShouldBrowserBeShown();
131
-
132
- return (state, {browserId, errorGroupBrowserIds}) => {
133
- const browser = state.tree.browsers.byId[browserId];
134
- const lastResult = state.tree.results.byId[last(browser.resultIds)];
135
- const shouldBeShown = shouldBrowserBeShown(state, {browserId, result: lastResult, errorGroupBrowserIds});
136
- let hasFailedRetries = false;
137
-
138
- if (shouldBeShown) {
139
- hasFailedRetries = hasBrowserFailedRetries(state, {browserId});
140
- }
104
+ ({tree}, {browserId}) => {
105
+ const browser = tree.browsers.byId[browserId];
106
+ const {shouldBeOpened, shouldBeShown} = tree.browsers.stateById[browserId];
107
+ const lastResult = tree.results.byId[last(browser.resultIds)];
141
108
 
142
- return {
143
- expand: state.view.expand,
144
- browser,
145
- lastResult,
146
- shouldBeShown,
147
- hasFailedRetries
148
- };
149
- };
109
+ return {browser, lastResult, shouldBeShown, shouldBeOpened};
150
110
  },
151
111
  (dispatch) => ({actions: bindActionCreators(actions, dispatch)})
152
112
  )(SectionWrapper(SectionBrowser));
@@ -2,69 +2,30 @@ import React, {Component} from 'react';
2
2
  import {connect} from 'react-redux';
3
3
  import {bindActionCreators} from 'redux';
4
4
  import PropTypes from 'prop-types';
5
- import LazilyRender from '@gemini-testing/react-lazily-render';
6
5
  import * as actions from '../../modules/actions';
7
6
  import SectionWrapper from './section-wrapper';
8
7
  import SectionBrowser from './section-browser';
9
- import {isFailStatus, isErroredStatus} from '../../../common-utils';
10
8
  import Title from './title/simple';
11
- import {mkShouldSuiteBeShown, mkHasSuiteFailedRetries} from '../../modules/selectors/tree';
12
9
 
13
10
  class SectionCommon extends Component {
14
11
  static propTypes = {
15
12
  suiteId: PropTypes.string.isRequired,
16
- eventToUpdate: PropTypes.string,
17
- eventToReset: PropTypes.string,
18
- errorGroupBrowserIds: PropTypes.array,
19
13
  sectionRoot: PropTypes.bool.isRequired,
20
14
  // from store
21
- expand: PropTypes.string.isRequired,
22
15
  suiteName: PropTypes.string.isRequired,
23
16
  suiteStatus: PropTypes.string.isRequired,
24
17
  suiteChildIds: PropTypes.array,
25
18
  suiteBrowserIds: PropTypes.array,
26
19
  shouldBeShown: PropTypes.bool.isRequired,
27
- hasFailedRetries: PropTypes.bool.isRequired,
20
+ shouldBeOpened: PropTypes.bool.isRequired,
28
21
  // from SectionCommonWrapper
29
- shouldBeOpened: PropTypes.func.isRequired,
30
22
  sectionStatusResolver: PropTypes.func.isRequired
31
23
  }
32
24
 
33
- constructor(props) {
34
- super(props);
25
+ onToggleSection = () => {
26
+ const {suiteId, shouldBeOpened} = this.props;
35
27
 
36
- this._lazyRender = React.createRef();
37
- }
38
-
39
- state = {
40
- opened: this.props.shouldBeOpened(this._getStates())
41
- }
42
-
43
- // eslint-disable-next-line camelcase
44
- UNSAFE_componentWillReceiveProps(nextProps) {
45
- const updatedStates = this._getStates(nextProps);
46
- this.setState({opened: this.props.shouldBeOpened(updatedStates)});
47
- }
48
-
49
- _getStates(props = this.props) {
50
- const {suiteStatus, expand, hasFailedRetries} = props;
51
-
52
- return {
53
- failed: isFailStatus(suiteStatus) || isErroredStatus(suiteStatus),
54
- retried: hasFailedRetries,
55
- expand
56
- };
57
- }
58
-
59
- _onToggleSection = () => {
60
- this.setState({opened: !this.state.opened});
61
- const {eventToUpdate, suiteId} = this.props;
62
-
63
- if (eventToUpdate) {
64
- window.dispatchEvent(new Event(eventToUpdate));
65
- }
66
-
67
- this.props.actions.toggleSuiteSection(suiteId);
28
+ this.props.actions.toggleSuiteSection({suiteId, shouldBeOpened: !shouldBeOpened});
68
29
  }
69
30
 
70
31
  _drawSection() {
@@ -74,16 +35,15 @@ class SectionCommon extends Component {
74
35
  suiteStatus,
75
36
  suiteChildIds,
76
37
  suiteBrowserIds,
77
- errorGroupBrowserIds,
78
38
  sectionRoot,
79
- sectionStatusResolver
39
+ sectionStatusResolver,
40
+ shouldBeOpened
80
41
  } = this.props;
81
- const {opened} = this.state;
82
42
 
83
- if (!opened) {
43
+ if (!shouldBeOpened) {
84
44
  return (
85
- <div className={sectionStatusResolver({status: suiteStatus, opened, sectionRoot})}>
86
- <Title name={suiteName} suiteId={suiteId} handler={this._onToggleSection} />
45
+ <div className={sectionStatusResolver({status: suiteStatus, shouldBeOpened, sectionRoot})}>
46
+ <Title name={suiteName} suiteId={suiteId} handler={this.onToggleSection} />
87
47
  </div>
88
48
  );
89
49
  }
@@ -92,20 +52,17 @@ class SectionCommon extends Component {
92
52
  return <SectionCommonWrapper
93
53
  key={suiteId}
94
54
  suiteId={suiteId}
95
- eventToUpdate={this.props.eventToUpdate}
96
- eventToReset={this.props.eventToReset}
97
55
  sectionRoot={false}
98
- errorGroupBrowserIds={errorGroupBrowserIds}
99
56
  />;
100
57
  });
101
58
 
102
59
  const browsersTmpl = suiteBrowserIds && suiteBrowserIds.map((browserId) => {
103
- return <SectionBrowser key={browserId} browserId={browserId} errorGroupBrowserIds={errorGroupBrowserIds} />;
60
+ return <SectionBrowser key={browserId} browserId={browserId} />;
104
61
  });
105
62
 
106
63
  return (
107
- <div className={sectionStatusResolver({status: suiteStatus, opened, sectionRoot})}>
108
- <Title name={suiteName} suiteId={suiteId} handler={this._onToggleSection} />
64
+ <div className={sectionStatusResolver({status: suiteStatus, shouldBeOpened, sectionRoot})}>
65
+ <Title name={suiteName} suiteId={suiteId} handler={this.onToggleSection} />
109
66
  <div className="section__body">
110
67
  {childSuitesTmpl}
111
68
  {browsersTmpl}
@@ -114,49 +71,27 @@ class SectionCommon extends Component {
114
71
  );
115
72
  }
116
73
 
117
- _drawLazySection() {
118
- const {suiteId, eventToUpdate, eventToReset, lazyLoadOffset} = this.props;
119
-
120
- return <LazilyRender key={suiteId} eventToUpdate={eventToUpdate} eventToReset={eventToReset} offset={lazyLoadOffset}>
121
- {render => render ? this._drawSection() : null}
122
- </LazilyRender>;
123
- }
124
-
125
74
  render() {
126
75
  if (!this.props.shouldBeShown) {
127
76
  return null;
128
77
  }
129
78
 
130
- return this.props.lazyLoadOffset > 0
131
- ? this._drawLazySection()
132
- : this._drawSection();
79
+ return this._drawSection();
133
80
  }
134
81
  }
135
82
 
136
83
  const SectionCommonWrapper = connect(
137
- () => {
138
- const shouldSuiteBeShown = mkShouldSuiteBeShown();
139
- const hasSuiteFailedRetries = mkHasSuiteFailedRetries();
140
-
141
- return (state, {suiteId, errorGroupBrowserIds, sectionRoot}) => {
142
- const suite = state.tree.suites.byId[suiteId];
143
- const shouldBeShown = sectionRoot ? true : shouldSuiteBeShown(state, {suiteId, errorGroupBrowserIds});
144
- let hasFailedRetries = false;
84
+ ({tree}, {suiteId}) => {
85
+ const suite = tree.suites.byId[suiteId];
86
+ const {shouldBeOpened, shouldBeShown} = tree.suites.stateById[suiteId];
145
87
 
146
- if (shouldBeShown) {
147
- hasFailedRetries = hasSuiteFailedRetries(state, {suiteId});
148
- }
149
-
150
- return {
151
- expand: state.view.expand,
152
- lazyLoadOffset: state.view.lazyLoadOffset,
153
- suiteName: suite.name,
154
- suiteStatus: suite.status,
155
- suiteChildIds: suite.suiteIds,
156
- suiteBrowserIds: suite.browserIds,
157
- shouldBeShown,
158
- hasFailedRetries
159
- };
88
+ return {
89
+ suiteName: suite.name,
90
+ suiteStatus: suite.status,
91
+ suiteChildIds: suite.suiteIds,
92
+ suiteBrowserIds: suite.browserIds,
93
+ shouldBeShown,
94
+ shouldBeOpened
160
95
  };
161
96
  },
162
97
  (dispatch) => ({actions: bindActionCreators(actions, dispatch)})
@@ -2,20 +2,8 @@ import React, {Component} from 'react';
2
2
  import classNames from 'classnames';
3
3
 
4
4
  export default (SectionComponent) => class WrappedComponent extends Component {
5
- shouldBeOpened({failed, retried, expand}) {
6
- if (expand === 'errors' && failed) {
7
- return true;
8
- } else if (expand === 'retries' && retried) {
9
- return true;
10
- } else if (expand === 'all') {
11
- return true;
12
- }
13
-
14
- return false;
15
- }
16
-
17
- sectionStatusResolver({status, opened, sectionRoot}) {
18
- const baseClasses = ['section', {'section_collapsed': !opened}];
5
+ sectionStatusResolver({status, shouldBeOpened, sectionRoot}) {
6
+ const baseClasses = ['section', {'section_collapsed': !shouldBeOpened}];
19
7
 
20
8
  return classNames(baseClasses, {
21
9
  [`section_status_${status}`]: status,
@@ -26,7 +14,6 @@ export default (SectionComponent) => class WrappedComponent extends Component {
26
14
  render() {
27
15
  return <SectionComponent
28
16
  {...this.props}
29
- shouldBeOpened={this.shouldBeOpened}
30
17
  sectionStatusResolver={this.sectionStatusResolver}
31
18
  />;
32
19
  }
@@ -8,6 +8,7 @@ import {get} from 'lodash';
8
8
  import * as actions from '../../../modules/actions';
9
9
  import {appendQuery} from '../../../modules/query-params';
10
10
  import viewModes from '../../../../constants/view-modes';
11
+ import {EXPAND_ALL} from '../../../../constants/expand-modes';
11
12
 
12
13
  class BrowserTitle extends Component {
13
14
  static propTypes = {
@@ -37,7 +38,7 @@ class BrowserTitle extends Component {
37
38
  strictMatchFilter: true,
38
39
  retryIndex,
39
40
  viewModes: viewModes.ALL,
40
- expand: 'all',
41
+ expand: EXPAND_ALL,
41
42
  groupByError: false
42
43
  });
43
44
  }
@@ -13,7 +13,7 @@ import ControlButton from '../controls/control-button';
13
13
  import FindSameDiffsButton from '../controls/find-same-diffs-button';
14
14
  import ArrowsOpen from '../icons/arrows-open';
15
15
  import {types as modalTypes} from '../modals';
16
- import {isAcceptable, isNodeFailed, isNodeSuccessful} from '../../modules/utils';
16
+ import {isAcceptable, isNodeSuccessful} from '../../modules/utils';
17
17
  import {isSuccessStatus, isFailStatus, isErroredStatus, isUpdatedStatus, isIdleStatus} from '../../../common-utils';
18
18
 
19
19
  class State extends Component {
@@ -25,62 +25,17 @@ class State extends Component {
25
25
  imageId: PropTypes.string,
26
26
  // from store
27
27
  gui: PropTypes.bool.isRequired,
28
- expand: PropTypes.string.isRequired,
29
28
  scaleImages: PropTypes.bool.isRequired,
30
- closeIds: PropTypes.array,
31
29
  image: PropTypes.shape({
32
30
  status: PropTypes.string,
33
31
  error: PropTypes.object,
34
32
  stateName: PropTypes.string,
35
33
  expectedImg: PropTypes.object
36
34
  }).isRequired,
37
- imageOpened: PropTypes.bool,
35
+ shouldImageBeOpened: PropTypes.bool.isRequired,
38
36
  isScreenshotAccepterDisabled: PropTypes.bool.isRequired
39
37
  }
40
38
 
41
- static defaultProps = {
42
- image: {}
43
- };
44
-
45
- constructor(props) {
46
- super(props);
47
-
48
- const opened = this.props.image.stateName ? this._shouldBeOpened() : true;
49
- this.state = {opened};
50
- }
51
-
52
- componentDidMount() {
53
- this.onToggleStateResult({opened: this.state.opened});
54
- }
55
-
56
- // eslint-disable-next-line camelcase
57
- UNSAFE_componentWillReceiveProps(nextProps) {
58
- if (nextProps.closeIds === this.props.closeIds || !this.state.opened) {
59
- return;
60
- }
61
-
62
- if (nextProps.expand !== this.props.expand) {
63
- const opened = this._shouldBeOpened(nextProps);
64
-
65
- if (this.state.opened !== opened) {
66
- this.setState({opened});
67
- this.onToggleStateResult({opened});
68
- }
69
- }
70
-
71
- const {imageId} = this.props;
72
- const opened = !nextProps.closeIds.includes(imageId);
73
-
74
- if (opened !== this.state.opened) {
75
- this.setState({opened});
76
- this.onToggleStateResult({opened});
77
- }
78
- }
79
-
80
- componentWillUnmount() {
81
- this.onToggleStateResult({opened: false});
82
- }
83
-
84
39
  toggleModal = () => {
85
40
  const {actions, image} = this.props;
86
41
 
@@ -92,36 +47,20 @@ class State extends Component {
92
47
  });
93
48
  }
94
49
 
95
- onToggleStateResult = ({opened, isUserClick = false}) => {
96
- const {imageId, image, imageOpened} = this.props;
50
+ onToggleStateResult = () => {
51
+ const {imageId, image, shouldImageBeOpened} = this.props;
97
52
 
98
- if (!image.stateName || imageOpened === opened) {
53
+ if (!image.stateName) {
99
54
  return;
100
55
  }
101
56
 
102
- this.props.actions.toggleStateResult({imageId, opened, isUserClick});
57
+ this.props.actions.toggleStateResult({imageId, shouldBeOpened: !shouldImageBeOpened});
103
58
  }
104
59
 
105
60
  onTestAccept = () => {
106
61
  this.props.actions.acceptTest(this.props.imageId);
107
62
  }
108
63
 
109
- _initOpened() {
110
- return this.props.image.stateName ? this._shouldBeOpened() : true;
111
- }
112
-
113
- _shouldBeOpened(props = this.props) {
114
- const {expand, node} = props;
115
-
116
- if ((expand === 'errors' || expand === 'retries') && isNodeFailed(node)) {
117
- return true;
118
- } else if (expand === 'all') {
119
- return true;
120
- }
121
-
122
- return false;
123
- }
124
-
125
64
  _drawControlButtons() {
126
65
  if (!this.props.gui) {
127
66
  return null;
@@ -159,13 +98,8 @@ class State extends Component {
159
98
  );
160
99
  }
161
100
 
162
- _toggleState = () => {
163
- this.setState({opened: !this.state.opened});
164
- this.onToggleStateResult({opened: !this.state.opened, isUserClick: true});
165
- }
166
-
167
101
  _getStateTitle() {
168
- const {image, imageOpened} = this.props;
102
+ const {image, shouldImageBeOpened} = this.props;
169
103
 
170
104
  if (!image.stateName) {
171
105
  return null;
@@ -173,15 +107,15 @@ class State extends Component {
173
107
 
174
108
  const className = classNames(
175
109
  'state-title',
176
- {'state-title_collapsed': !imageOpened},
110
+ {'state-title_collapsed': !shouldImageBeOpened},
177
111
  `state-title_${image.status}`
178
112
  );
179
113
 
180
- return <div className={className} onClick={this._toggleState}>{image.stateName}</div>;
114
+ return <div className={className} onClick={this.onToggleStateResult}>{image.stateName}</div>;
181
115
  }
182
116
 
183
117
  render() {
184
- if (!this.state.opened) {
118
+ if (!this.props.shouldImageBeOpened) {
185
119
  return (
186
120
  <Fragment>
187
121
  <hr className="tab__separator" />
@@ -225,9 +159,9 @@ export default connect(
225
159
  const getLastImageByStateName = mkGetLastImageByStateName();
226
160
 
227
161
  return (state, {imageId, result}) => {
228
- const {gui, tree, view: {expand, scaleImages}, closeIds} = state;
229
- const image = tree.images.byId[imageId];
230
- const {opened} = tree.images.stateById[imageId] || {};
162
+ const {gui, tree, view: {scaleImages}} = state;
163
+ const image = tree.images.byId[imageId] || {};
164
+ const shouldImageBeOpened = image.stateName ? tree.images.stateById[imageId].shouldBeOpened : true;
231
165
  const node = imageId ? image : result;
232
166
  let isScreenshotAccepterDisabled = true;
233
167
 
@@ -238,12 +172,10 @@ export default connect(
238
172
 
239
173
  return {
240
174
  gui,
241
- expand,
242
175
  scaleImages,
243
- closeIds,
244
176
  image,
245
177
  node,
246
- imageOpened: opened,
178
+ shouldImageBeOpened,
247
179
  isScreenshotAccepterDisabled
248
180
  };
249
181
  };