html-reporter 8.4.4 → 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 (73) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +35 -3
  3. package/lib/config/index.js +17 -6
  4. package/lib/constants/defaults.js +2 -1
  5. package/lib/constants/diff-modes.js +32 -0
  6. package/lib/constants/group-tests.js +7 -0
  7. package/lib/constants/plugin-events.js +2 -1
  8. package/lib/server-utils.js +1 -1
  9. package/lib/static/components/bottom-progress-bar/index.js +5 -1
  10. package/lib/static/components/controls/common-controls.js +19 -20
  11. package/lib/static/components/controls/controls.less +0 -31
  12. package/lib/static/components/controls/selects/control.js +51 -0
  13. package/lib/static/components/controls/selects/group-tests.js +94 -0
  14. package/lib/static/components/controls/selects/index.styl +58 -0
  15. package/lib/static/components/{error-groups → group-tests}/item.js +8 -8
  16. package/lib/static/components/group-tests/list.js +71 -0
  17. package/lib/static/components/group-tests/prop-types.js +12 -0
  18. package/lib/static/components/icons/arrows-move.js +24 -0
  19. package/lib/static/components/main-tree.js +5 -5
  20. package/lib/static/components/modals/screenshot-accepter/body.js +4 -12
  21. package/lib/static/components/modals/screenshot-accepter/header.js +3 -32
  22. package/lib/static/components/retry-switcher/item.js +15 -7
  23. package/lib/static/components/section/body/index.js +9 -4
  24. package/lib/static/components/section/title/browser.js +1 -2
  25. package/lib/static/components/state/index.js +2 -9
  26. package/lib/static/components/state/{diff-circle.js → screenshot/diff-circle.js} +1 -1
  27. package/lib/static/components/state/screenshot/full.js +28 -0
  28. package/lib/static/components/state/{screenshot.js → screenshot/resized.js} +28 -30
  29. package/lib/static/components/state/screenshot/with-encode-uri.js +44 -0
  30. package/lib/static/components/state/screenshot/with-synced-scale.js +116 -0
  31. package/lib/static/components/state/state-error.js +3 -3
  32. package/lib/static/components/state/state-fail/index.js +142 -0
  33. package/lib/static/components/state/state-fail/index.styl +31 -0
  34. package/lib/static/components/state/state-fail/onion-skin-diff/index.js +43 -0
  35. package/lib/static/components/state/state-fail/onion-skin-diff/index.styl +19 -0
  36. package/lib/static/components/state/state-fail/prop-types.js +16 -0
  37. package/lib/static/components/state/state-fail/swipe-diff/index.js +138 -0
  38. package/lib/static/components/state/state-fail/swipe-diff/index.styl +82 -0
  39. package/lib/static/components/state/state-fail/switch-diff/index.js +36 -0
  40. package/lib/static/components/state/state-fail/switch-diff/index.styl +12 -0
  41. package/lib/static/components/state/state-success.js +2 -2
  42. package/lib/static/gui.min.css +205 -27
  43. package/lib/static/gui.min.js +16 -16
  44. package/lib/static/modules/action-names.js +9 -5
  45. package/lib/static/modules/actions.js +29 -5
  46. package/lib/static/modules/custom-queries.js +1 -2
  47. package/lib/static/modules/default-state.js +14 -4
  48. package/lib/static/modules/middlewares/local-storage.js +1 -3
  49. package/lib/static/modules/middlewares/metrika.js +10 -13
  50. package/lib/static/modules/reducers/grouped-tests/by/meta.js +31 -0
  51. package/lib/static/modules/reducers/grouped-tests/by/result.js +57 -0
  52. package/lib/static/modules/reducers/grouped-tests/helpers.js +91 -0
  53. package/lib/static/modules/reducers/grouped-tests/index.js +52 -0
  54. package/lib/static/modules/reducers/index.js +2 -2
  55. package/lib/static/modules/reducers/tree/index.js +38 -12
  56. package/lib/static/modules/reducers/tree/nodes/browsers.js +9 -10
  57. package/lib/static/modules/reducers/tree/nodes/results.js +16 -0
  58. package/lib/static/modules/reducers/tree/nodes/suites.js +1 -1
  59. package/lib/static/modules/reducers/view.js +29 -22
  60. package/lib/static/modules/selectors/grouped-tests.js +8 -0
  61. package/lib/static/modules/selectors/view.js +1 -0
  62. package/lib/static/modules/utils.js +19 -1
  63. package/lib/static/report.min.css +205 -27
  64. package/lib/static/report.min.js +16 -16
  65. package/lib/static/styles.css +71 -42
  66. package/lib/test-adapter.js +11 -2
  67. package/package.json +4 -2
  68. package/webpack.common.js +7 -0
  69. package/lib/static/components/controls/view-select.js +0 -50
  70. package/lib/static/components/error-groups/list.js +0 -56
  71. package/lib/static/components/state/state-fail.js +0 -56
  72. package/lib/static/modules/group-errors.js +0 -101
  73. package/lib/static/modules/reducers/grouped-errors.js +0 -43
@@ -29,12 +29,15 @@ export default {
29
29
  VIEW_SHOW_ALL: 'VIEW_SHOW_ALL',
30
30
  VIEW_SHOW_FAILED: 'VIEW_SHOW_FAILED',
31
31
  VIEW_TOGGLE_SKIPPED: 'VIEW_TOGGLE_SKIPPED',
32
- VIEW_TOGGLE_ONLY_DIFF: 'VIEW_TOGGLE_ONLY_DIFF',
33
32
  VIEW_UPDATE_BASE_HOST: 'VIEW_UPDATE_BASE_HOST',
34
33
  VIEW_UPDATE_FILTER_BY_NAME: 'VIEW_UPDATE_FILTER_BY_NAME',
35
34
  VIEW_SET_STRICT_MATCH_FILTER: 'VIEW_SET_STRICT_MATCH_FILTER',
36
- VIEW_TOGGLE_GROUP_BY_ERROR: 'VIEW_TOGGLE_GROUP_BY_ERROR',
37
- VIEW_TOGGLE_SCALE_IMAGES: 'VIEW_TOGGLE_SCALE_IMAGES',
35
+ VIEW_THREE_UP_DIFF: 'VIEW_THREE_UP_DIFF',
36
+ VIEW_THREE_UP_SCALED_DIFF: 'VIEW_THREE_UP_SCALED_DIFF',
37
+ VIEW_ONLY_DIFF: 'VIEW_ONLY_DIFF',
38
+ VIEW_SWITCH_DIFF: 'VIEW_SWITCH_DIFF',
39
+ VIEW_SWIPE_DIFF: 'VIEW_SWIPE_DIFF',
40
+ VIEW_ONION_SKIN_DIFF: 'VIEW_ONION_SKIN_DIFF',
38
41
  PROCESS_BEGIN: 'PROCESS_BEGIN',
39
42
  PROCESS_END: 'PROCESS_END',
40
43
  RUN_CUSTOM_GUI_ACTION: 'RUN_CUSTOM_GUI_ACTION',
@@ -46,6 +49,7 @@ export default {
46
49
  TOGGLE_BROWSER_SECTION: 'TOGGLE_BROWSER_SECTION',
47
50
  TOGGLE_META_INFO: 'TOGGLE_META_INFO',
48
51
  TOGGLE_PAGE_SCREENSHOT: 'TOGGLE_PAGE_SCREENSHOT',
49
- TOGGLE_ERROR_GROUP: 'TOGGLE_ERROR_GROUP',
50
- 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'
51
55
  };
@@ -5,6 +5,8 @@ import StaticTestsTreeBuilder from '../../tests-tree-builder/static';
5
5
  import actionNames from './action-names';
6
6
  import {types as modalTypes} from '../components/modals';
7
7
  import {QUEUED} from '../../constants/test-statuses';
8
+ import viewModes from '../../constants/view-modes';
9
+ import diffModes from '../../constants/diff-modes';
8
10
  import {getHttpErrorMessage} from './utils';
9
11
  import {fetchDataFromDatabases, mergeDatabases, connectToDatabase, getMainDatabaseUrl, getSuitesTableRows} from '../../db-utils/client';
10
12
  import {setFilteredBrowsers} from './query-params';
@@ -175,9 +177,6 @@ export const expandErrors = () => ({type: actionNames.VIEW_EXPAND_ERRORS});
175
177
  export const expandRetries = () => ({type: actionNames.VIEW_EXPAND_RETRIES});
176
178
  export const collapseAll = () => ({type: actionNames.VIEW_COLLAPSE_ALL});
177
179
  export const toggleSkipped = () => ({type: actionNames.VIEW_TOGGLE_SKIPPED});
178
- export const toggleOnlyDiff = () => ({type: actionNames.VIEW_TOGGLE_ONLY_DIFF});
179
- export const toggleScaleImages = () => ({type: actionNames.VIEW_TOGGLE_SCALE_IMAGES});
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) => {
@@ -215,13 +215,37 @@ export const setStrictMatchFilter = (strictMatchFilter) => {
215
215
 
216
216
  export function changeViewMode(mode) {
217
217
  switch (mode) {
218
- case 'failed':
218
+ case viewModes.FAILED:
219
219
  return {type: actionNames.VIEW_SHOW_FAILED};
220
+ case viewModes.ALL:
220
221
  default:
221
222
  return {type: actionNames.VIEW_SHOW_ALL};
222
223
  }
223
224
  }
224
225
 
226
+ export function changeDiffMode(mode) {
227
+ switch (mode) {
228
+ case diffModes.ONLY_DIFF.id:
229
+ return {type: actionNames.VIEW_ONLY_DIFF};
230
+
231
+ case diffModes.SWITCH.id:
232
+ return {type: actionNames.VIEW_SWITCH_DIFF};
233
+
234
+ case diffModes.SWIPE.id:
235
+ return {type: actionNames.VIEW_SWIPE_DIFF};
236
+
237
+ case diffModes.ONION_SKIN.id:
238
+ return {type: actionNames.VIEW_ONION_SKIN_DIFF};
239
+
240
+ case diffModes.THREE_UP_SCALED.id:
241
+ return {type: actionNames.VIEW_THREE_UP_SCALED_DIFF};
242
+
243
+ case diffModes.THREE_UP.id:
244
+ default:
245
+ return {type: actionNames.VIEW_THREE_UP_DIFF};
246
+ }
247
+ }
248
+
225
249
  export const findSameDiffs = (selectedImageId, openedImageIds, browserName) => {
226
250
  return async (dispatch) => {
227
251
  dispatch(toggleLoading({active: true, content: 'Find same diffs...'}));
@@ -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
  }
@@ -2,7 +2,9 @@
2
2
 
3
3
  const defaults = require('../../constants/defaults');
4
4
  const viewModes = require('../../constants/view-modes');
5
+ const diffModes = require('../../constants/diff-modes');
5
6
  const {EXPAND_ERRORS} = require('../../constants/expand-modes');
7
+ const {RESULT_KEYS} = require('../../constants/group-tests');
6
8
 
7
9
  export default Object.assign(defaults, {
8
10
  gui: true,
@@ -12,7 +14,16 @@ export default Object.assign(defaults, {
12
14
  autoRun: false,
13
15
  skips: [],
14
16
  browsers: [],
15
- 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
+ },
16
27
  tree: {
17
28
  suites: {
18
29
  byId: {},
@@ -56,15 +67,14 @@ export default Object.assign(defaults, {
56
67
  },
57
68
  view: {
58
69
  viewMode: viewModes.ALL,
70
+ diffMode: diffModes.THREE_UP.id,
59
71
  expand: EXPAND_ERRORS,
60
72
  showSkipped: false,
61
- showOnlyDiff: false,
62
- scaleImages: false,
63
73
  baseHost: '',
64
74
  testNameFilter: '',
65
75
  strictMatchFilter: false,
66
76
  filteredBrowsers: [],
67
- groupByError: false
77
+ keyToGroupTestsBy: ''
68
78
  },
69
79
  db: undefined,
70
80
  fetchDbDetails: [],
@@ -12,10 +12,8 @@ export default store => next => action => {
12
12
  localStorageWrapper.setItem('view', {
13
13
  expand: view.expand,
14
14
  viewMode: view.viewMode,
15
+ diffMode: view.diffMode,
15
16
  showSkipped: view.showSkipped,
16
- showOnlyDiff: view.showOnlyDiff,
17
- scaleImages: view.scaleImages,
18
- groupByError: view.groupByError,
19
17
  strictMatchFilter: view.strictMatchFilter
20
18
  });
21
19
  }
@@ -68,10 +68,13 @@ 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_ONLY_DIFF:
72
- case actionNames.VIEW_TOGGLE_SCALE_IMAGES:
73
- case actionNames.VIEW_TOGGLE_GROUP_BY_ERROR:
74
71
  case actionNames.VIEW_UPDATE_BASE_HOST:
72
+ case actionNames.VIEW_THREE_UP_DIFF:
73
+ case actionNames.VIEW_THREE_UP_SCALED_DIFF:
74
+ case actionNames.VIEW_ONLY_DIFF:
75
+ case actionNames.VIEW_SWITCH_DIFF:
76
+ case actionNames.VIEW_SWIPE_DIFF:
77
+ case actionNames.VIEW_ONION_SKIN_DIFF:
75
78
  case actionNames.BROWSERS_SELECTED:
76
79
  case actionNames.VIEW_UPDATE_FILTER_BY_NAME:
77
80
  case actionNames.VIEW_SET_STRICT_MATCH_FILTER:
@@ -80,7 +83,10 @@ export default metrikaClass => store => next => action => {
80
83
  case actionNames.VIEW_IN_BROWSER:
81
84
  case actionNames.COPY_TEST_LINK:
82
85
  case actionNames.TOGGLE_SUITE_SECTION:
83
- 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: {
84
90
  execOnMetrikaEnabled(() => {
85
91
  sendCounterId(action.type);
86
92
  });
@@ -98,15 +104,6 @@ export default metrikaClass => store => next => action => {
98
104
  return next(action);
99
105
  }
100
106
 
101
- case actionNames.TOGGLE_STATE_RESULT:
102
- case actionNames.CHANGE_TEST_RETRY: {
103
- execOnMetrikaEnabled(() => {
104
- sendCounterId(action.type);
105
- });
106
-
107
- return next(action);
108
- }
109
-
110
107
  default:
111
108
  return next(action);
112
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