@@ -102,10 +102,10 @@ describe('session list search helpers', () => {
102102} )
103103
104104describe ( 'getVisibleSessionPreview' , ( ) => {
105- it ( 'keeps selected and active sessions inside the collapsed preview without promoting them' , ( ) => {
105+ it ( 'keeps selected and pending sessions inside the collapsed preview without promoting them' , ( ) => {
106106 const sessions = Array . from ( { length : 6 } , ( _ , index ) => makeSession ( {
107107 id : `s-${ index + 1 } ` ,
108- active : index === 4 ,
108+ pendingRequestsCount : index === 4 ? 1 : 0 ,
109109 metadata : { path : '/work/hapi' } ,
110110 updatedAt : 100 - index
111111 } ) )
@@ -118,6 +118,19 @@ describe('getVisibleSessionPreview', () => {
118118 expect ( preview . map ( session => session . id ) ) . toEqual ( [ 's-1' , 's-5' , 's-6' ] )
119119 } )
120120
121+ it ( 'does not exceed the limit just because many sessions are active' , ( ) => {
122+ const sessions = Array . from ( { length : 6 } , ( _ , index ) => makeSession ( {
123+ id : `s-${ index + 1 } ` ,
124+ active : true ,
125+ metadata : { path : '/work/hapi' } ,
126+ updatedAt : 100 - index
127+ } ) )
128+
129+ const preview = getVisibleSessionPreview ( sessions , { limit : 4 } )
130+
131+ expect ( preview . map ( session => session . id ) ) . toEqual ( [ 's-1' , 's-2' , 's-3' , 's-4' ] )
132+ } )
133+
121134 it ( 'does not move an already-visible selected session to the top' , ( ) => {
122135 const sessions = Array . from ( { length : 6 } , ( _ , index ) => makeSession ( {
123136 id : `s-${ index + 1 } ` ,
@@ -145,7 +158,7 @@ describe('getVisibleSessionPreview', () => {
145158
146159
147160describe ( 'expandSelectedSessionCollapseOverrides' , ( ) => {
148- it ( 'expands collapsed project, machine, and session preview overrides for selected sessions ' , ( ) => {
161+ it ( 'expands collapsed project and machine, but preserves session preview folding ' , ( ) => {
149162 const overrides = new Map < string , boolean > ( [
150163 [ 'machine-1::/work/hapi' , true ] ,
151164 [ 'sessions::machine-1::/work/hapi' , true ] ,
@@ -158,18 +171,18 @@ describe('expandSelectedSessionCollapseOverrides', () => {
158171 } )
159172
160173 expect ( result . has ( 'machine-1::/work/hapi' ) ) . toBe ( false )
161- expect ( result . get ( 'sessions::machine-1::/work/hapi' ) ) . toBe ( false )
174+ expect ( result . get ( 'sessions::machine-1::/work/hapi' ) ) . toBe ( true )
162175 expect ( result . has ( 'machine::machine-1' ) ) . toBe ( false )
163176 } )
164177
165- it ( 'sets missing session preview override to expanded ' , ( ) => {
178+ it ( 'leaves missing session preview override unset ' , ( ) => {
166179 const overrides = new Map < string , boolean > ( )
167180
168181 const result = expandSelectedSessionCollapseOverrides ( overrides , {
169182 key : 'machine-1::/work/hapi' ,
170183 machineId : 'machine-1'
171184 } )
172185
173- expect ( result . get ( 'sessions::machine-1::/work/hapi' ) ) . toBe ( false )
186+ expect ( result . has ( 'sessions::machine-1::/work/hapi' ) ) . toBe ( false )
174187 } )
175188} )
0 commit comments