html-reporter 9.1.1 → 9.2.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 (43) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +2 -2
  3. package/lib/constants/group-tests.js +7 -0
  4. package/lib/static/components/bottom-progress-bar/index.js +5 -1
  5. package/lib/static/components/controls/common-controls.js +3 -6
  6. package/lib/static/components/controls/{control-select/index.js → selects/control.js} +4 -3
  7. package/lib/static/components/controls/selects/group-tests.js +94 -0
  8. package/lib/static/components/controls/{control-select → selects}/index.styl +23 -9
  9. package/lib/static/components/{error-groups → group-tests}/item.js +8 -8
  10. package/lib/static/components/group-tests/list.js +71 -0
  11. package/lib/static/components/group-tests/prop-types.js +12 -0
  12. package/lib/static/components/main-tree.js +5 -5
  13. package/lib/static/components/retry-switcher/item.js +15 -7
  14. package/lib/static/components/section/body/index.js +9 -4
  15. package/lib/static/components/section/title/browser.js +1 -2
  16. package/lib/static/gui.min.css +26 -13
  17. package/lib/static/gui.min.js +16 -16
  18. package/lib/static/modules/action-names.js +3 -3
  19. package/lib/static/modules/actions.js +2 -2
  20. package/lib/static/modules/custom-queries.js +1 -2
  21. package/lib/static/modules/default-state.js +12 -2
  22. package/lib/static/modules/middlewares/local-storage.js +0 -1
  23. package/lib/static/modules/middlewares/metrika.js +4 -11
  24. package/lib/static/modules/reducers/grouped-tests/by/meta.js +31 -0
  25. package/lib/static/modules/reducers/grouped-tests/by/result.js +57 -0
  26. package/lib/static/modules/reducers/grouped-tests/helpers.js +91 -0
  27. package/lib/static/modules/reducers/grouped-tests/index.js +52 -0
  28. package/lib/static/modules/reducers/index.js +2 -2
  29. package/lib/static/modules/reducers/tree/index.js +38 -12
  30. package/lib/static/modules/reducers/tree/nodes/browsers.js +9 -10
  31. package/lib/static/modules/reducers/tree/nodes/results.js +16 -0
  32. package/lib/static/modules/reducers/tree/nodes/suites.js +1 -1
  33. package/lib/static/modules/reducers/view.js +2 -10
  34. package/lib/static/modules/selectors/grouped-tests.js +8 -0
  35. package/lib/static/modules/selectors/view.js +1 -0
  36. package/lib/static/modules/utils.js +19 -1
  37. package/lib/static/report.min.css +26 -13
  38. package/lib/static/report.min.js +16 -16
  39. package/lib/static/styles.css +68 -31
  40. package/package.json +1 -1
  41. package/lib/static/components/error-groups/list.js +0 -56
  42. package/lib/static/modules/group-errors.js +0 -101
  43. package/lib/static/modules/reducers/grouped-errors.js +0 -43
@@ -32,7 +32,6 @@ export default {
32
32
  VIEW_UPDATE_BASE_HOST: 'VIEW_UPDATE_BASE_HOST',
33
33
  VIEW_UPDATE_FILTER_BY_NAME: 'VIEW_UPDATE_FILTER_BY_NAME',
34
34
  VIEW_SET_STRICT_MATCH_FILTER: 'VIEW_SET_STRICT_MATCH_FILTER',
35
- VIEW_TOGGLE_GROUP_BY_ERROR: 'VIEW_TOGGLE_GROUP_BY_ERROR',
36
35
  VIEW_THREE_UP_DIFF: 'VIEW_THREE_UP_DIFF',
37
36
  VIEW_THREE_UP_SCALED_DIFF: 'VIEW_THREE_UP_SCALED_DIFF',
38
37
  VIEW_ONLY_DIFF: 'VIEW_ONLY_DIFF',
@@ -50,6 +49,7 @@ export default {
50
49
  TOGGLE_BROWSER_SECTION: 'TOGGLE_BROWSER_SECTION',
51
50
  TOGGLE_META_INFO: 'TOGGLE_META_INFO',
52
51
  TOGGLE_PAGE_SCREENSHOT: 'TOGGLE_PAGE_SCREENSHOT',
53
- TOGGLE_ERROR_GROUP: 'TOGGLE_ERROR_GROUP',
54
- UPDATE_BOTTOM_PROGRESS_BAR: 'UPDATE_BOTTOM_PROGRESS_BAR'
52
+ TOGGLE_TESTS_GROUP: 'TOGGLE_TESTS_GROUP',
53
+ UPDATE_BOTTOM_PROGRESS_BAR: 'UPDATE_BOTTOM_PROGRESS_BAR',
54
+ GROUP_TESTS_BY_KEY: 'GROUP_TESTS_BY_KEY'
55
55
  };
@@ -177,7 +177,6 @@ export const expandErrors = () => ({type: actionNames.VIEW_EXPAND_ERRORS});
177
177
  export const expandRetries = () => ({type: actionNames.VIEW_EXPAND_RETRIES});
178
178
  export const collapseAll = () => ({type: actionNames.VIEW_COLLAPSE_ALL});
179
179
  export const toggleSkipped = () => ({type: actionNames.VIEW_TOGGLE_SKIPPED});
180
- export const toggleGroupByError = () => ({type: actionNames.VIEW_TOGGLE_GROUP_BY_ERROR});
181
180
  export const processBegin = () => ({type: actionNames.PROCESS_BEGIN});
182
181
  export const processEnd = () => ({type: actionNames.PROCESS_END});
183
182
  export const updateBaseHost = (host) => ({type: actionNames.VIEW_UPDATE_BASE_HOST, host});
@@ -188,8 +187,9 @@ export const toggleSuiteSection = (payload) => ({type: actionNames.TOGGLE_SUITE_
188
187
  export const toggleBrowserSection = (payload) => ({type: actionNames.TOGGLE_BROWSER_SECTION, payload});
189
188
  export const toggleMetaInfo = () => ({type: actionNames.TOGGLE_META_INFO});
190
189
  export const togglePageScreenshot = () => ({type: actionNames.TOGGLE_PAGE_SCREENSHOT});
191
- export const toggleErrorGroup = (payload) => ({type: actionNames.TOGGLE_ERROR_GROUP, payload});
192
190
  export const updateBottomProgressBar = (payload) => ({type: actionNames.UPDATE_BOTTOM_PROGRESS_BAR, payload});
191
+ export const toggleTestsGroup = (payload) => ({type: actionNames.TOGGLE_TESTS_GROUP, payload});
192
+ export const groupTestsByKey = (payload) => ({type: actionNames.GROUP_TESTS_BY_KEY, payload});
193
193
 
194
194
  export const runCustomGuiAction = (payload) => {
195
195
  return async (dispatch) => {
@@ -22,7 +22,6 @@ export function getViewQuery(queryString) {
22
22
  'strictMatchFilter',
23
23
  'retryIndex',
24
24
  'viewMode',
25
- 'expand',
26
- 'groupByError'
25
+ 'expand'
27
26
  ]);
28
27
  }
@@ -4,6 +4,7 @@ const defaults = require('../../constants/defaults');
4
4
  const viewModes = require('../../constants/view-modes');
5
5
  const diffModes = require('../../constants/diff-modes');
6
6
  const {EXPAND_ERRORS} = require('../../constants/expand-modes');
7
+ const {RESULT_KEYS} = require('../../constants/group-tests');
7
8
 
8
9
  export default Object.assign(defaults, {
9
10
  gui: true,
@@ -13,7 +14,16 @@ export default Object.assign(defaults, {
13
14
  autoRun: false,
14
15
  skips: [],
15
16
  browsers: [],
16
- groupedErrors: [],
17
+ groupedTests: {
18
+ result: {
19
+ byKey: RESULT_KEYS.reduce((acc, v) => ({...acc, [v]: []}), {}),
20
+ allKeys: RESULT_KEYS
21
+ },
22
+ meta: {
23
+ byKey: {},
24
+ allKeys: []
25
+ }
26
+ },
17
27
  tree: {
18
28
  suites: {
19
29
  byId: {},
@@ -64,7 +74,7 @@ export default Object.assign(defaults, {
64
74
  testNameFilter: '',
65
75
  strictMatchFilter: false,
66
76
  filteredBrowsers: [],
67
- groupByError: false
77
+ keyToGroupTestsBy: ''
68
78
  },
69
79
  db: undefined,
70
80
  fetchDbDetails: [],
@@ -14,7 +14,6 @@ export default store => next => action => {
14
14
  viewMode: view.viewMode,
15
15
  diffMode: view.diffMode,
16
16
  showSkipped: view.showSkipped,
17
- groupByError: view.groupByError,
18
17
  strictMatchFilter: view.strictMatchFilter
19
18
  });
20
19
  }
@@ -68,7 +68,6 @@ export default metrikaClass => store => next => action => {
68
68
  case actionNames.VIEW_EXPAND_ERRORS:
69
69
  case actionNames.VIEW_EXPAND_RETRIES:
70
70
  case actionNames.VIEW_TOGGLE_SKIPPED:
71
- case actionNames.VIEW_TOGGLE_GROUP_BY_ERROR:
72
71
  case actionNames.VIEW_UPDATE_BASE_HOST:
73
72
  case actionNames.VIEW_THREE_UP_DIFF:
74
73
  case actionNames.VIEW_THREE_UP_SCALED_DIFF:
@@ -84,7 +83,10 @@ export default metrikaClass => store => next => action => {
84
83
  case actionNames.VIEW_IN_BROWSER:
85
84
  case actionNames.COPY_TEST_LINK:
86
85
  case actionNames.TOGGLE_SUITE_SECTION:
87
- case actionNames.TOGGLE_BROWSER_SECTION: {
86
+ case actionNames.TOGGLE_BROWSER_SECTION:
87
+ case actionNames.TOGGLE_STATE_RESULT:
88
+ case actionNames.CHANGE_TEST_RETRY:
89
+ case actionNames.GROUP_TESTS_BY_KEY: {
88
90
  execOnMetrikaEnabled(() => {
89
91
  sendCounterId(action.type);
90
92
  });
@@ -102,15 +104,6 @@ export default metrikaClass => store => next => action => {
102
104
  return next(action);
103
105
  }
104
106
 
105
- case actionNames.TOGGLE_STATE_RESULT:
106
- case actionNames.CHANGE_TEST_RETRY: {
107
- execOnMetrikaEnabled(() => {
108
- sendCounterId(action.type);
109
- });
110
-
111
- return next(action);
112
- }
113
-
114
107
  default:
115
108
  return next(action);
116
109
  }
@@ -0,0 +1,31 @@
1
+ import {handleActiveResults, addGroupItem, sortGroupValues} from '../helpers';
2
+
3
+ export function groupMeta({group, groupKey, ...restArgs}) {
4
+ const metaKeys = new Set();
5
+ if (groupKey) {
6
+ group.byKey[groupKey] = {};
7
+ }
8
+
9
+ const resultCb = (result) => {
10
+ if (!result.metaInfo) {
11
+ return;
12
+ }
13
+
14
+ for (let [key, value] of Object.entries(result.metaInfo)) {
15
+ metaKeys.add(key);
16
+
17
+ if (!groupKey || groupKey !== key) {
18
+ continue;
19
+ }
20
+
21
+ addGroupItem({group: group.byKey[groupKey], result, value});
22
+ }
23
+ };
24
+
25
+ handleActiveResults({...restArgs, resultCb});
26
+
27
+ group.allKeys = [...metaKeys].sort();
28
+ if (groupKey) {
29
+ group.byKey[groupKey] = sortGroupValues(group.byKey[groupKey]);
30
+ }
31
+ }
@@ -0,0 +1,57 @@
1
+ import {get} from 'lodash';
2
+ import {handleActiveResults, addGroupItem, sortGroupValues} from '../helpers';
3
+ import {isAssertViewError} from '../../../utils';
4
+ import {ERROR_KEY, RESULT_KEYS} from '../../../../../constants/group-tests';
5
+
6
+ const imageComparisonErrorMessage = 'image comparison failed';
7
+
8
+ export function groupResult(args) {
9
+ if (args.groupKey === ERROR_KEY) {
10
+ return groupErrors(args);
11
+ }
12
+
13
+ throw new Error(`Group key must be one of ${RESULT_KEYS.join(', ')}, but got ${args.groupKey}`);
14
+ }
15
+
16
+ function groupErrors({tree, group, groupKey, errorPatterns = [], ...viewArgs}) {
17
+ group.byKey[groupKey] = {};
18
+
19
+ const resultCb = (result) => {
20
+ const images = result.imageIds.map((imageId) => tree.images.byId[imageId]);
21
+ const errors = extractErrors(result, images);
22
+
23
+ for (const errorText of errors) {
24
+ addGroupItem({group: group.byKey[groupKey], result, value: errorText, patterns: errorPatterns});
25
+ }
26
+ };
27
+
28
+ handleActiveResults({tree, ...viewArgs, resultCb});
29
+
30
+ group.byKey[groupKey] = sortGroupValues(group.byKey[groupKey]);
31
+ }
32
+
33
+ function extractErrors(result, images) {
34
+ const errors = new Set();
35
+
36
+ images.forEach(({error, diffImg}) => {
37
+ if (get(error, 'message')) {
38
+ errors.add(error.message);
39
+ }
40
+
41
+ if (diffImg) {
42
+ errors.add(imageComparisonErrorMessage);
43
+ }
44
+ });
45
+
46
+ const {error} = result;
47
+
48
+ if (errors.size > 0 && isAssertViewError(error)) {
49
+ return [...errors];
50
+ }
51
+
52
+ if (get(error, 'message')) {
53
+ errors.add(error.message);
54
+ }
55
+
56
+ return [...errors];
57
+ }
@@ -0,0 +1,91 @@
1
+ import {isFunction, isString, isObject, isNull, isUndefined, toString} from 'lodash';
2
+ import {getFailedSuiteResults} from '../../selectors/tree';
3
+ import {isTestNameMatchFilters, shouldShowBrowser} from '../../utils';
4
+ import viewModes from '../../../../constants/view-modes';
5
+
6
+ export function handleActiveResults({tree = {}, viewMode = viewModes.ALL, filteredBrowsers = [], testNameFilter = '', strictMatchFilter = false, resultCb}) {
7
+ if (!isFunction(resultCb)) {
8
+ throw new Error(`"resultCb" argument must be a function, but got ${typeof resultCb}`);
9
+ }
10
+
11
+ const results = viewMode === viewModes.FAILED ? getFailedSuiteResults(tree) : Object.values(tree.results.byId);
12
+
13
+ for (const result of results) {
14
+ const browser = tree.browsers.byId[result.parentId];
15
+ const testName = browser.parentId;
16
+
17
+ if (!isTestNameMatchFilters(testName, testNameFilter, strictMatchFilter)) {
18
+ continue;
19
+ }
20
+
21
+ if (!shouldShowBrowser(browser, filteredBrowsers)) {
22
+ continue;
23
+ }
24
+
25
+ resultCb(result);
26
+ }
27
+ }
28
+
29
+ export function addGroupItem({group, result, value, patterns = []}) {
30
+ const stringifiedValue = stringify(value);
31
+ const {pattern, name} = matchGroupWithPatterns(stringifiedValue, patterns);
32
+
33
+ if (!group.hasOwnProperty(name)) {
34
+ group[name] = {
35
+ pattern,
36
+ name,
37
+ browserIds: [result.parentId],
38
+ resultIds: [result.id],
39
+ testCount: 1,
40
+ resultCount: 1
41
+ };
42
+
43
+ return;
44
+ }
45
+
46
+ const groupItem = group[name];
47
+
48
+ if (!groupItem.browserIds.includes(result.parentId)) {
49
+ groupItem.browserIds.push(result.parentId);
50
+ groupItem.testCount++;
51
+ }
52
+
53
+ if (!groupItem.resultIds.includes(result.id)) {
54
+ groupItem.resultIds.push(result.id);
55
+ groupItem.resultCount++;
56
+ }
57
+ }
58
+
59
+ export function sortGroupValues(values) {
60
+ return Object.values(values).sort((g1, g2) => g1.testCount > g2.testCount ? -1 : 1);
61
+ }
62
+
63
+ function matchGroupWithPatterns(value, patterns = []) {
64
+ for (const group of patterns) {
65
+ if (value.match(group.regexp)) {
66
+ return group;
67
+ }
68
+ }
69
+
70
+ return {name: value, pattern: value};
71
+ }
72
+
73
+ function stringify(value) {
74
+ if (isString(value)) {
75
+ return value;
76
+ }
77
+
78
+ if (isObject(value)) {
79
+ return JSON.stringify(value);
80
+ }
81
+
82
+ if (isNull(value)) {
83
+ return 'null';
84
+ }
85
+
86
+ if (isUndefined(value)) {
87
+ return 'undefined';
88
+ }
89
+
90
+ return toString(value);
91
+ }
@@ -0,0 +1,52 @@
1
+ import {produce} from 'immer';
2
+ import actionNames from '../../action-names';
3
+ import {groupMeta} from './by/meta';
4
+ import {groupResult} from './by/result';
5
+ import {SECTIONS} from '../../../../constants/group-tests';
6
+ import {parseKeyToGroupTestsBy} from '../../utils';
7
+
8
+ export default produce((state, action) => {
9
+ switch (action.type) {
10
+ case actionNames.INIT_GUI_REPORT:
11
+ case actionNames.INIT_STATIC_REPORT:
12
+ case actionNames.GROUP_TESTS_BY_KEY:
13
+ case actionNames.TESTS_END:
14
+ case actionNames.BROWSERS_SELECTED:
15
+ case actionNames.VIEW_UPDATE_FILTER_BY_NAME:
16
+ case actionNames.VIEW_SET_STRICT_MATCH_FILTER:
17
+ case actionNames.VIEW_SHOW_ALL:
18
+ case actionNames.VIEW_SHOW_FAILED:
19
+ case actionNames.ACCEPT_SCREENSHOT:
20
+ case actionNames.ACCEPT_OPENED_SCREENSHOTS: {
21
+ const {
22
+ tree, groupedTests,
23
+ view: {keyToGroupTestsBy, viewMode, filteredBrowsers, testNameFilter, strictMatchFilter}
24
+ } = state;
25
+ const viewArgs = {viewMode, filteredBrowsers, testNameFilter, strictMatchFilter};
26
+
27
+ if (!keyToGroupTestsBy) {
28
+ groupMeta({tree, group: groupedTests.meta, ...viewArgs});
29
+
30
+ return;
31
+ }
32
+
33
+ const [groupSection, groupKey] = parseKeyToGroupTestsBy(keyToGroupTestsBy);
34
+ const group = groupedTests[groupSection];
35
+
36
+ if (groupSection === SECTIONS.RESULT) {
37
+ const {config: {errorPatterns}} = state;
38
+
39
+ return groupResult({tree, group, groupKey, errorPatterns, ...viewArgs});
40
+ }
41
+
42
+ if (groupSection === SECTIONS.META) {
43
+ return groupMeta({tree, group, groupKey, ...viewArgs});
44
+ }
45
+
46
+ break;
47
+ }
48
+
49
+ default:
50
+ return state;
51
+ }
52
+ });
@@ -21,7 +21,7 @@ import stats from './stats';
21
21
  import skips from './skips';
22
22
  import view from './view';
23
23
  import plugins from './plugins';
24
- import groupedErrors from './grouped-errors';
24
+ import groupedTests from './grouped-tests';
25
25
  import stopping from './stopping';
26
26
  import progressBar from './bottom-progress-bar';
27
27
 
@@ -50,7 +50,7 @@ export default reduceReducers(
50
50
  // important to specify `view` higher than `tree`
51
51
  view,
52
52
  tree,
53
- groupedErrors,
53
+ groupedTests,
54
54
  plugins,
55
55
  progressBar
56
56
  );
@@ -8,7 +8,7 @@ import {
8
8
  initBrowsersState, changeAllBrowsersState, changeBrowserState,
9
9
  calcBrowsersShowness, calcBrowsersOpenness, setBrowsersLastRetry
10
10
  } from './nodes/browsers';
11
- import {addResult} from './nodes/results';
11
+ import {initResultsState, changeAllResultsState, changeResultState, addResult} from './nodes/results';
12
12
  import {
13
13
  initImagesState, changeAllImagesState, changeImageState, addImages, calcImagesOpenness
14
14
  } from './nodes/images';
@@ -27,6 +27,7 @@ export default produce((state, action) => {
27
27
 
28
28
  state.tree.suites.stateById = {};
29
29
  state.tree.browsers.stateById = {};
30
+ state.tree.results.stateById = {};
30
31
  state.tree.images.stateById = {};
31
32
 
32
33
  updateAllSuitesStatus(state.tree, filteredBrowsers);
@@ -90,8 +91,13 @@ export default produce((state, action) => {
90
91
 
91
92
  case actionNames.CHANGE_TEST_RETRY: {
92
93
  const {browserId, retryIndex} = action.payload;
94
+ const browserState = {retryIndex};
93
95
 
94
- changeBrowserState(state.tree, browserId, {retryIndex});
96
+ if (state.view.keyToGroupTestsBy) {
97
+ browserState.lastMatchedRetryIndex = null;
98
+ }
99
+
100
+ changeBrowserState(state.tree, browserId, browserState);
95
101
 
96
102
  break;
97
103
  }
@@ -138,8 +144,6 @@ export default produce((state, action) => {
138
144
  calcBrowsersOpenness(tree, view.expand);
139
145
  calcImagesOpenness(tree, view.expand);
140
146
 
141
- setBrowsersLastRetry(tree);
142
-
143
147
  break;
144
148
  }
145
149
 
@@ -153,13 +157,14 @@ export default produce((state, action) => {
153
157
  break;
154
158
  }
155
159
 
156
- case actionNames.TOGGLE_ERROR_GROUP: {
157
- const {browserIds, isActive} = action.payload;
160
+ case actionNames.TOGGLE_TESTS_GROUP: {
161
+ const {browserIds, resultIds, isActive} = action.payload;
158
162
  const {tree, view} = state;
159
163
 
160
164
  if (!isActive) {
161
- changeAllBrowsersState(tree, {shouldBeShown: false});
165
+ changeAllBrowsersState(tree, {shouldBeShown: false, lastMatchedRetryIndex: null});
162
166
  changeAllSuitesState(tree, {shouldBeShown: false});
167
+ changeAllResultsState(tree, {matchedSelectedGroup: false});
163
168
 
164
169
  return;
165
170
  }
@@ -169,11 +174,28 @@ export default produce((state, action) => {
169
174
  tree.browsers.allIds.forEach((browserId) => {
170
175
  const {shouldBeShown} = tree.browsers.stateById[browserId];
171
176
 
172
- if (browserIds.includes(browserId) || !shouldBeShown) {
177
+ if (!shouldBeShown) {
173
178
  return;
174
179
  }
175
180
 
176
- changeBrowserState(tree, browserId, {shouldBeShown: false});
181
+ if (!browserIds.includes(browserId)) {
182
+ return changeBrowserState(tree, browserId, {shouldBeShown: false});
183
+ }
184
+
185
+ const broResultIds = tree.browsers.byId[browserId].resultIds;
186
+ let lastMatchedRetryIndex = broResultIds.length - 1;
187
+
188
+ broResultIds.forEach((resultId, ind) => {
189
+ if (!resultIds.includes(resultId)) {
190
+ changeResultState(tree, resultId, {matchedSelectedGroup: false});
191
+ return;
192
+ }
193
+
194
+ lastMatchedRetryIndex = ind;
195
+ changeResultState(tree, resultId, {matchedSelectedGroup: true});
196
+ });
197
+
198
+ changeBrowserState(tree, browserId, {lastMatchedRetryIndex});
177
199
  });
178
200
 
179
201
  calcSuitesShowness(tree);
@@ -181,11 +203,13 @@ export default produce((state, action) => {
181
203
  break;
182
204
  }
183
205
 
184
- case actionNames.VIEW_TOGGLE_GROUP_BY_ERROR: {
206
+ case actionNames.GROUP_TESTS_BY_KEY: {
185
207
  const {tree, view} = state;
186
208
 
187
- if (view.groupByError) {
188
- changeAllBrowsersState(tree, {shouldBeShown: false});
209
+ changeAllResultsState(tree, {matchedSelectedGroup: false});
210
+
211
+ if (view.keyToGroupTestsBy) {
212
+ changeAllBrowsersState(tree, {shouldBeShown: false, lastMatchedRetryIndex: null});
189
213
  changeAllSuitesState(tree, {shouldBeShown: false});
190
214
 
191
215
  return;
@@ -193,6 +217,7 @@ export default produce((state, action) => {
193
217
 
194
218
  calcBrowsersShowness(tree, view);
195
219
  calcSuitesShowness(tree);
220
+ changeAllBrowsersState(tree, {lastMatchedRetryIndex: null});
196
221
 
197
222
  break;
198
223
  }
@@ -205,6 +230,7 @@ function initNodesStates(state) {
205
230
  initBrowsersState(tree, view);
206
231
  initSuitesState(tree, view);
207
232
  initImagesState(tree, view.expand);
233
+ initResultsState(tree);
208
234
  }
209
235
 
210
236
  function addNodesToTree(state, payload) {
@@ -1,4 +1,4 @@
1
- import _ from 'lodash';
1
+ import {isEmpty, last, initial} from 'lodash';
2
2
  import {isStatusMatchViewMode, isTestNameMatchFilters, shouldShowBrowser} from '../../../utils';
3
3
  import {isNodeFailed} from '../../../utils';
4
4
  import {changeNodeState, shouldNodeBeOpened} from '../helpers';
@@ -7,7 +7,7 @@ export function initBrowsersState(tree, view) {
7
7
  tree.browsers.allIds.forEach((browserId) => {
8
8
  setBrowsersLastRetry(tree, browserId);
9
9
 
10
- if (view.groupByError) {
10
+ if (view.keyToGroupTestsBy) {
11
11
  changeBrowserState(tree, browserId, {shouldBeShown: false});
12
12
  } else {
13
13
  calcBrowsersShowness(tree, view, browserId);
@@ -19,8 +19,7 @@ export function initBrowsersState(tree, view) {
19
19
 
20
20
  export function changeAllBrowsersState(tree, state) {
21
21
  tree.browsers.allIds.forEach((browserId) => {
22
- const retryIndex = getLastRetryIndex(tree, browserId);
23
- changeBrowserState(tree, browserId, {retryIndex, ...state});
22
+ changeBrowserState(tree, browserId, state);
24
23
  });
25
24
  }
26
25
 
@@ -29,7 +28,7 @@ export function changeBrowserState(tree, browserId, state) {
29
28
  }
30
29
 
31
30
  export function setBrowsersLastRetry(tree, browserIds) {
32
- if (_.isEmpty(browserIds)) {
31
+ if (isEmpty(browserIds)) {
33
32
  browserIds = tree.browsers.allIds;
34
33
  }
35
34
 
@@ -40,13 +39,13 @@ export function setBrowsersLastRetry(tree, browserIds) {
40
39
  }
41
40
 
42
41
  export function calcBrowsersShowness(tree, view, browserIds) {
43
- if (_.isEmpty(browserIds)) {
42
+ if (isEmpty(browserIds)) {
44
43
  browserIds = tree.browsers.allIds;
45
44
  }
46
45
 
47
46
  [].concat(browserIds).forEach((browserId) => {
48
47
  const browser = tree.browsers.byId[browserId];
49
- const lastResult = tree.results.byId[_.last(browser.resultIds)];
48
+ const lastResult = tree.results.byId[last(browser.resultIds)];
50
49
  const shouldBeShown = calcBrowserShowness(browser, lastResult, view);
51
50
 
52
51
  changeBrowserState(tree, browserId, {shouldBeShown});
@@ -54,13 +53,13 @@ export function calcBrowsersShowness(tree, view, browserIds) {
54
53
  }
55
54
 
56
55
  export function calcBrowsersOpenness(tree, expand, browserIds) {
57
- if (_.isEmpty(browserIds)) {
56
+ if (isEmpty(browserIds)) {
58
57
  browserIds = tree.browsers.allIds;
59
58
  }
60
59
 
61
60
  [].concat(browserIds).forEach((browserId) => {
62
61
  const browser = tree.browsers.byId[browserId];
63
- const lastResult = tree.results.byId[_.last(browser.resultIds)];
62
+ const lastResult = tree.results.byId[last(browser.resultIds)];
64
63
  const shouldBeOpened = calcBrowserOpenness(browser, lastResult, expand, tree);
65
64
 
66
65
  changeBrowserState(tree, browserId, {shouldBeOpened});
@@ -74,7 +73,7 @@ function getLastRetryIndex(tree, browserId) {
74
73
  function calcBrowserOpenness(browser, lastResult, expand, tree) {
75
74
  const errorsCb = () => isNodeFailed(lastResult);
76
75
  const retriesCb = () => {
77
- const retries = [].concat(_.initial(browser.resultIds)).map((resultId) => tree.results.byId[resultId]);
76
+ const retries = [].concat(initial(browser.resultIds)).map((resultId) => tree.results.byId[resultId]);
78
77
 
79
78
  return retries.some((retry) => isNodeFailed(retry));
80
79
  };
@@ -1,3 +1,19 @@
1
+ import {changeNodeState} from '../helpers';
2
+
3
+ export function initResultsState(tree) {
4
+ changeAllResultsState(tree, {matchedSelectedGroup: false});
5
+ }
6
+
7
+ export function changeAllResultsState(tree, state) {
8
+ tree.results.allIds.forEach((resultId) => {
9
+ changeResultState(tree, resultId, state);
10
+ });
11
+ }
12
+
13
+ export function changeResultState(tree, resultId, state) {
14
+ changeNodeState(tree.results.stateById, resultId, state);
15
+ }
16
+
1
17
  export function addResult(tree, result) {
2
18
  tree.results.byId[result.id] = result;
3
19
 
@@ -6,7 +6,7 @@ import {changeNodeState, shouldNodeBeOpened} from '../helpers';
6
6
  import {EXPAND_RETRIES} from '../../../../../constants/expand-modes';
7
7
 
8
8
  export function initSuitesState(tree, view) {
9
- if (view.groupByError) {
9
+ if (view.keyToGroupTestsBy) {
10
10
  changeAllSuitesState(tree, {shouldBeShown: false});
11
11
  } else {
12
12
  calcSuitesShowness(tree);
@@ -25,14 +25,6 @@ export default produce((state, action) => {
25
25
  break;
26
26
  }
27
27
 
28
- case actionNames.RUN_ALL_TESTS:
29
- case actionNames.RUN_FAILED_TESTS:
30
- case actionNames.RETRY_SUITE:
31
- case actionNames.RETRY_TEST: {
32
- state.view.groupByError = false;
33
- break;
34
- }
35
-
36
28
  case actionNames.VIEW_EXPAND_ALL: {
37
29
  state.view.expand = EXPAND_ALL;
38
30
  break;
@@ -88,8 +80,8 @@ export default produce((state, action) => {
88
80
  break;
89
81
  }
90
82
 
91
- case actionNames.VIEW_TOGGLE_GROUP_BY_ERROR: {
92
- state.view.groupByError = !state.view.groupByError;
83
+ case actionNames.GROUP_TESTS_BY_KEY: {
84
+ state.view.keyToGroupTestsBy = action.payload;
93
85
  break;
94
86
  }
95
87
 
@@ -0,0 +1,8 @@
1
+ import {createSelector} from 'reselect';
2
+ import {getKeyToGroupTestsBy} from './view';
3
+ import {parseKeyToGroupTestsBy} from '../utils';
4
+
5
+ export const getParsedKeyToGroupTestsBy = createSelector(
6
+ getKeyToGroupTestsBy,
7
+ (keyToGroupTestsBy) => keyToGroupTestsBy ? parseKeyToGroupTestsBy(keyToGroupTestsBy) : []
8
+ );
@@ -2,3 +2,4 @@ export const getFilteredBrowsers = (state) => state.view.filteredBrowsers;
2
2
  export const getTestNameFilter = (state) => state.view.testNameFilter;
3
3
  export const getStrictMatchFilter = (state) => state.view.strictMatchFilter;
4
4
  export const getViewMode = (state) => state.view.viewMode;
5
+ export const getKeyToGroupTestsBy = (state) => state.view.keyToGroupTestsBy;