@@ -22,18 +22,37 @@ describe("reconcileSelectedRuns", () => {
2222 expect ( reconcileSelectedRuns ( [ ] , [ "a" , "b" , "c" ] ) ) . toEqual ( [ "a" , "b" , "c" ] ) ;
2323 } ) ;
2424
25- test ( "keeps the previously selected run and appends new runs as selected " , ( ) => {
26- expect ( reconcileSelectedRuns ( [ "a" ] , [ "a" , "b" , "c" ] ) ) . toEqual ( [ "a" , "b" , "c "] ) ;
25+ test ( "keeps a partial selection without auto-selecting new runs" , ( ) => {
26+ expect ( reconcileSelectedRuns ( [ "a" ] , [ "a" , "b" , "c" ] , [ "a" , "b" ] ) ) . toEqual ( [ "a "] ) ;
2727 } ) ;
2828
29- test ( "preserves the chosen run when the run list is unchanged on refresh" , ( ) => {
29+ test ( "auto-selects new runs when all previous runs were selected" , ( ) => {
30+ expect (
31+ reconcileSelectedRuns ( [ "a" , "b" ] , [ "a" , "b" , "c" ] , [ "a" , "b" ] ) ,
32+ ) . toEqual ( [ "a" , "b" , "c" ] ) ;
33+ } ) ;
34+
35+ test ( "preserves the chosen runs when the run list is unchanged on refresh" , ( ) => {
3036 const prev = [ "b" ] ;
3137 const next = [ "a" , "b" , "c" ] ;
32- expect ( reconcileSelectedRuns ( prev , next ) ) . toEqual ( [ "b" , "a" , "c" ] ) ;
33- expect ( reconcileSelectedRuns ( [ "b" , "a" , "c" ] , next ) ) . toEqual ( [ "b" , "a" , "c" ] ) ;
38+ expect ( reconcileSelectedRuns ( prev , next , next ) ) . toEqual ( [ "b" ] ) ;
39+ expect ( reconcileSelectedRuns ( [ "b" , "a" , "c" ] , next , next ) ) . toEqual ( [
40+ "b" ,
41+ "a" ,
42+ "c" ,
43+ ] ) ;
3444 } ) ;
3545
3646 test ( "drops runs that no longer exist on the server" , ( ) => {
37- expect ( reconcileSelectedRuns ( [ "a" , "b" , "c" ] , [ "a" , "c" ] ) ) . toEqual ( [ "a" , "c" ] ) ;
47+ expect (
48+ reconcileSelectedRuns ( [ "a" , "b" , "c" ] , [ "a" , "c" ] , [ "a" , "b" , "c" ] ) ,
49+ ) . toEqual ( [ "a" , "c" ] ) ;
50+ } ) ;
51+
52+ test ( "falls back to all runs when none of the previously selected runs exist anymore" , ( ) => {
53+ expect ( reconcileSelectedRuns ( [ "a" ] , [ "b" ] , [ "a" ] ) ) . toEqual ( [ "b" ] ) ;
54+ expect (
55+ reconcileSelectedRuns ( [ "x" , "y" ] , [ "a" , "b" , "c" ] , [ "x" , "y" ] ) ,
56+ ) . toEqual ( [ "a" , "b" , "c" ] ) ;
3857 } ) ;
3958} ) ;
0 commit comments