Skip to content

Commit 0217508

Browse files
author
oldskytree
committed
feat(static): expand test statuses filter
1 parent d1a0003 commit 0217508

File tree

14 files changed

+113
-67
lines changed

14 files changed

+113
-67
lines changed

lib/constants/view-modes.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,8 @@
22

33
module.exports = {
44
ALL: 'all',
5-
FAILED: 'failed'
5+
PASSED: 'passed',
6+
FAILED: 'failed',
7+
RETRIED: 'retried',
8+
SKIPPED: 'skipped'
69
};

lib/static/components/suites.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ class Suites extends Component {
8989
msgs.push(`test name should match to "${testNameFilter}" ${strictMatchFilter ? '' : 'not '}strictly;`);
9090
}
9191

92-
if (viewMode === viewModes.FAILED) {
93-
msgs.push(`test should be failed due to selected view mode: "Show only ${viewMode}";`);
92+
if (viewMode !== viewModes.ALL) {
93+
msgs.push(`test should be ${viewMode} due to selected view mode;`);
9494
}
9595

9696
if (filteredBrowsers) {

lib/static/modules/action-names.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ export default {
2626
VIEW_EXPAND_ERRORS: 'VIEW_EXPAND_ERRORS',
2727
VIEW_EXPAND_RETRIES: 'VIEW_EXPAND_RETRIES',
2828
VIEW_COLLAPSE_ALL: 'VIEW_COLLAPSE_ALL',
29-
VIEW_SHOW_ALL: 'VIEW_SHOW_ALL',
30-
VIEW_SHOW_FAILED: 'VIEW_SHOW_FAILED',
29+
CHANGE_VIEW_MODE: 'CHANGE_VIEW_MODE',
3130
VIEW_TOGGLE_SKIPPED: 'VIEW_TOGGLE_SKIPPED',
3231
VIEW_UPDATE_BASE_HOST: 'VIEW_UPDATE_BASE_HOST',
3332
VIEW_UPDATE_FILTER_BY_NAME: 'VIEW_UPDATE_FILTER_BY_NAME',

lib/static/modules/actions.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import StaticTestsTreeBuilder from '../../tests-tree-builder/static';
55
import actionNames from './action-names';
66
import {types as modalTypes} from '../components/modals';
77
import {QUEUED} from '../../constants/test-statuses';
8-
import viewModes from '../../constants/view-modes';
98
import diffModes from '../../constants/diff-modes';
109
import {getHttpErrorMessage} from './utils';
1110
import {fetchDataFromDatabases, mergeDatabases, connectToDatabase, getMainDatabaseUrl, getSuitesTableRows} from '../../db-utils/client';
@@ -202,6 +201,7 @@ export const togglePageScreenshot = () => ({type: actionNames.TOGGLE_PAGE_SCREEN
202201
export const updateBottomProgressBar = (payload) => ({type: actionNames.UPDATE_BOTTOM_PROGRESS_BAR, payload});
203202
export const toggleTestsGroup = (payload) => ({type: actionNames.TOGGLE_TESTS_GROUP, payload});
204203
export const groupTestsByKey = (payload) => ({type: actionNames.GROUP_TESTS_BY_KEY, payload});
204+
export const changeViewMode = (payload) => ({type: actionNames.CHANGE_VIEW_MODE, payload});
205205

206206
export const runCustomGuiAction = (payload) => {
207207
return async (dispatch) => {
@@ -225,16 +225,6 @@ export const setStrictMatchFilter = (strictMatchFilter) => {
225225
return {type: actionNames.VIEW_SET_STRICT_MATCH_FILTER, strictMatchFilter};
226226
};
227227

228-
export function changeViewMode(mode) {
229-
switch (mode) {
230-
case viewModes.FAILED:
231-
return {type: actionNames.VIEW_SHOW_FAILED};
232-
case viewModes.ALL:
233-
default:
234-
return {type: actionNames.VIEW_SHOW_ALL};
235-
}
236-
}
237-
238228
export function changeDiffMode(mode) {
239229
switch (mode) {
240230
case diffModes.ONLY_DIFF.id:

lib/static/modules/middlewares/metrika.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ export default metrikaClass => store => next => action => {
6161
case actionNames.RUN_FAILED_TESTS:
6262
case actionNames.RETRY_SUITE:
6363
case actionNames.RETRY_TEST:
64-
case actionNames.VIEW_SHOW_ALL:
65-
case actionNames.VIEW_SHOW_FAILED:
64+
case actionNames.CHANGE_VIEW_MODE:
6665
case actionNames.VIEW_EXPAND_ALL:
6766
case actionNames.VIEW_COLLAPSE_ALL:
6867
case actionNames.VIEW_EXPAND_ERRORS:

lib/static/modules/reducers/grouped-tests/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ export default produce((state, action) => {
1414
case actionNames.BROWSERS_SELECTED:
1515
case actionNames.VIEW_UPDATE_FILTER_BY_NAME:
1616
case actionNames.VIEW_SET_STRICT_MATCH_FILTER:
17-
case actionNames.VIEW_SHOW_ALL:
18-
case actionNames.VIEW_SHOW_FAILED:
17+
case actionNames.CHANGE_VIEW_MODE:
1918
case actionNames.ACCEPT_SCREENSHOT:
2019
case actionNames.ACCEPT_OPENED_SCREENSHOTS: {
2120
const {

lib/static/modules/reducers/tree/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,7 @@ export default produce((state, action) => {
112112
break;
113113
}
114114

115-
case actionNames.VIEW_SHOW_ALL:
116-
case actionNames.VIEW_SHOW_FAILED:
115+
case actionNames.CHANGE_VIEW_MODE:
117116
case actionNames.VIEW_UPDATE_FILTER_BY_NAME:
118117
case actionNames.VIEW_SET_STRICT_MATCH_FILTER: {
119118
const {tree, view} = state;

lib/static/modules/reducers/tree/nodes/browsers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {isEmpty, last, initial} from 'lodash';
2-
import {isStatusMatchViewMode, isTestNameMatchFilters, shouldShowBrowser} from '../../../utils';
2+
import {isBrowserMatchViewMode, isTestNameMatchFilters, shouldShowBrowser} from '../../../utils';
33
import {isNodeFailed} from '../../../utils';
44
import {changeNodeState, shouldNodeBeOpened} from '../helpers';
55

@@ -84,7 +84,7 @@ function calcBrowserOpenness(browser, lastResult, expand, tree) {
8484
function calcBrowserShowness(browser, lastResult, view) {
8585
const {viewMode, filteredBrowsers, testNameFilter, strictMatchFilter} = view;
8686

87-
if (!isStatusMatchViewMode(lastResult.status, viewMode)) {
87+
if (!isBrowserMatchViewMode(browser, lastResult, viewMode)) {
8888
return false;
8989
}
9090

lib/static/modules/reducers/view.js

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {isEmpty} from 'lodash';
44
import {getViewQuery} from '../custom-queries';
55
import * as localStorageWrapper from '../local-storage-wrapper';
66
import actionNames from '../action-names';
7-
import viewModes from '../../../constants/view-modes';
87
import diffModes from '../../../constants/diff-modes';
98
import {EXPAND_ALL, COLLAPSE_ALL, EXPAND_ERRORS, EXPAND_RETRIES} from '../../../constants/expand-modes';
109

@@ -45,18 +44,8 @@ export default produce((state, action) => {
4544
break;
4645
}
4746

48-
case actionNames.VIEW_SHOW_ALL: {
49-
state.view.viewMode = viewModes.ALL;
50-
break;
51-
}
52-
53-
case actionNames.VIEW_SHOW_FAILED: {
54-
state.view.viewMode = viewModes.FAILED;
55-
break;
56-
}
57-
58-
case actionNames.VIEW_TOGGLE_SKIPPED: {
59-
state.view.showSkipped = !state.view.showSkipped;
47+
case actionNames.CHANGE_VIEW_MODE: {
48+
state.view.viewMode = action.payload;
6049
break;
6150
}
6251

lib/static/modules/utils.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,26 @@ function isTestNameMatchFilters(testName, testNameFilter, strictMatchFilter) {
7777
: testName.includes(testNameFilter);
7878
}
7979

80-
function isStatusMatchViewMode(status, viewMode) {
80+
function isBrowserMatchViewMode(browser, lastResult, viewMode) {
81+
const {status} = lastResult;
82+
8183
if (viewMode === viewModes.ALL) {
8284
return true;
8385
}
8486

87+
if (viewMode === viewModes.PASSED && isSuccessStatus(status)) {
88+
return true;
89+
}
90+
8591
if (viewMode === viewModes.FAILED && (isFailStatus(status) || isErroredStatus(status))) {
8692
return true;
8793
}
8894

89-
return false;
95+
if (viewMode === viewModes.RETRIED) {
96+
return browser.resultIds.length > 1;
97+
}
98+
99+
return status === viewMode;
90100
}
91101

92102
function shouldShowBrowser(browser, filteredBrowsers) {
@@ -154,7 +164,7 @@ module.exports = {
154164
dateToLocaleString,
155165
getHttpErrorMessage,
156166
isTestNameMatchFilters,
157-
isStatusMatchViewMode,
167+
isBrowserMatchViewMode,
158168
shouldShowBrowser,
159169
iterateSuites,
160170
parseKeyToGroupTestsBy

0 commit comments

Comments
 (0)