Skip to content

Commit

Permalink
Merge pull request #494 from gemini-testing/HERMIONE-1145.fix_suites_…
Browse files Browse the repository at this point in the history
…state

fix: suites state with empty picked browsers
  • Loading branch information
KuznetsovRoman authored Sep 5, 2023
2 parents 469387f + 2fc0aff commit 854c9f0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/static/modules/reducers/tree/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {findLast} from 'lodash';
import {findLast, isEmpty} from 'lodash';
import {produce} from 'immer';
import actionNames from '../../action-names';
import {
Expand Down Expand Up @@ -108,8 +108,11 @@ export default produce((state, action) => {

case actionNames.BROWSERS_SELECTED: {
const {tree, view} = state;
const filteredBrowsers = isEmpty(view.filteredBrowsers)
? state.browsers.map(({id}) => ({id, versions: []}))
: view.filteredBrowsers;

updateAllSuitesStatus(tree, view.filteredBrowsers);
updateAllSuitesStatus(tree, filteredBrowsers);
calcBrowsersShowness(tree, view);
calcSuitesShowness(tree);

Expand Down
16 changes: 16 additions & 0 deletions test/unit/lib/static/modules/reducers/tree/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,22 @@ describe('lib/static/modules/reducers/tree', () => {
assert.equal(newState.tree.suites.byId.s1.status, FAIL);
assert.equal(newState.tree.suites.byId.s2.status, SUCCESS);
});

it('should correctly set suite status when filteredBrowsers is empty', () => {
const suitesById = mkSuite({id: 's1', status: FAIL, browserIds: ['b1']});
const browsersById = mkBrowser({id: 'b1', name: 'yabro-1', parentId: 's1', resultIds: ['r1']});
const resultsById = mkResult({id: 'r1', parentId: 'b1', status: FAIL});
const browsersStateById = {'b1': {checkStatus: UNCHECKED}};
const tree = mkStateTree({suitesById, browsersById, resultsById, browsersStateById});
const view = mkStateView({filteredBrowsers: [{id: 'yabro-1', versions: []}]});

const newState = reducer({tree, view}, {
type: actionNames.BROWSERS_SELECTED,
payload: {browsers: []}
});

assert.equal(newState.tree.suites.byId.s1.status, FAIL);
});
});

describe(`${actionNames.CHANGE_TEST_RETRY} action`, () => {
Expand Down

0 comments on commit 854c9f0

Please sign in to comment.