88 initBrowsersState , changeAllBrowsersState , changeBrowserState ,
99 calcBrowsersShowness , calcBrowsersOpenness , setBrowsersLastRetry
1010} from './nodes/browsers' ;
11- import { addResult } from './nodes/results' ;
11+ import { initResultsState , changeAllResultsState , changeResultState , addResult } from './nodes/results' ;
1212import {
1313 initImagesState , changeAllImagesState , changeImageState , addImages , calcImagesOpenness
1414} from './nodes/images' ;
@@ -27,6 +27,7 @@ export default produce((state, action) => {
2727
2828 state . tree . suites . stateById = { } ;
2929 state . tree . browsers . stateById = { } ;
30+ state . tree . results . stateById = { } ;
3031 state . tree . images . stateById = { } ;
3132
3233 updateAllSuitesStatus ( state . tree , filteredBrowsers ) ;
@@ -90,8 +91,13 @@ export default produce((state, action) => {
9091
9192 case actionNames . CHANGE_TEST_RETRY : {
9293 const { browserId, retryIndex} = action . payload ;
94+ const browserState = { retryIndex} ;
9395
94- changeBrowserState ( state . tree , browserId , { retryIndex} ) ;
96+ if ( state . view . keyToGroupTestsBy ) {
97+ browserState . lastMatchedRetryIndex = null ;
98+ }
99+
100+ changeBrowserState ( state . tree , browserId , browserState ) ;
95101
96102 break ;
97103 }
@@ -138,8 +144,6 @@ export default produce((state, action) => {
138144 calcBrowsersOpenness ( tree , view . expand ) ;
139145 calcImagesOpenness ( tree , view . expand ) ;
140146
141- setBrowsersLastRetry ( tree ) ;
142-
143147 break ;
144148 }
145149
@@ -154,12 +158,13 @@ export default produce((state, action) => {
154158 }
155159
156160 case actionNames . TOGGLE_TESTS_GROUP : {
157- const { browserIds, isActive} = action . payload ;
161+ const { browserIds, resultIds , isActive} = action . payload ;
158162 const { tree, view} = state ;
159163
160164 if ( ! isActive ) {
161- changeAllBrowsersState ( tree , { shouldBeShown : false } ) ;
165+ changeAllBrowsersState ( tree , { shouldBeShown : false , lastMatchedRetryIndex : null } ) ;
162166 changeAllSuitesState ( tree , { shouldBeShown : false } ) ;
167+ changeAllResultsState ( tree , { matchedSelectedGroup : false } ) ;
163168
164169 return ;
165170 }
@@ -169,11 +174,28 @@ export default produce((state, action) => {
169174 tree . browsers . allIds . forEach ( ( browserId ) => {
170175 const { shouldBeShown} = tree . browsers . stateById [ browserId ] ;
171176
172- if ( browserIds . includes ( browserId ) || ! shouldBeShown ) {
177+ if ( ! shouldBeShown ) {
173178 return ;
174179 }
175180
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} ) ;
177199 } ) ;
178200
179201 calcSuitesShowness ( tree ) ;
@@ -184,15 +206,18 @@ export default produce((state, action) => {
184206 case actionNames . GROUP_TESTS_BY_KEY : {
185207 const { tree, view} = state ;
186208
209+ changeAllResultsState ( tree , { matchedSelectedGroup : false } ) ;
210+
187211 if ( view . keyToGroupTestsBy ) {
188- changeAllBrowsersState ( tree , { shouldBeShown : false } ) ;
212+ changeAllBrowsersState ( tree , { shouldBeShown : false , lastMatchedRetryIndex : null } ) ;
189213 changeAllSuitesState ( tree , { shouldBeShown : false } ) ;
190214
191215 return ;
192216 }
193217
194218 calcBrowsersShowness ( tree , view ) ;
195219 calcSuitesShowness ( tree ) ;
220+ changeAllBrowsersState ( tree , { lastMatchedRetryIndex : null } ) ;
196221
197222 break ;
198223 }
@@ -205,6 +230,7 @@ function initNodesStates(state) {
205230 initBrowsersState ( tree , view ) ;
206231 initSuitesState ( tree , view ) ;
207232 initImagesState ( tree , view . expand ) ;
233+ initResultsState ( tree ) ;
208234}
209235
210236function addNodesToTree ( state , payload ) {
0 commit comments