@@ -206,7 +206,7 @@ describe('handleLoadSession', () => {
206206 } ) ;
207207 } ) ;
208208
209- test ( 'should handle partially defined bounds (gracefully fail to fallback )' , async ( ) => {
209+ test ( 'should handle partially defined bounds (falls back to display area )' , async ( ) => {
210210 mockSession . windowBounds = {
211211 left : 100 ,
212212 top : 50
@@ -215,13 +215,63 @@ describe('handleLoadSession', () => {
215215
216216 await handleLoadSession ( mockSession . id ) ;
217217
218- // Should use stored bounds even if incomplete
218+ // Should fallback to display area bounds
219219 expect ( global . chrome . windows . create ) . toHaveBeenCalledWith ( {
220220 url : [ 'https://example.com' , 'https://test.com' ] ,
221- height : undefined ,
222- width : undefined ,
223- top : 50 ,
224- left : 100
221+ height : 980 ,
222+ width : 1820 ,
223+ top : 0 ,
224+ left : 0
225+ } ) ;
226+ } ) ;
227+ } ) ;
228+
229+ describe ( 'bounds edge cases with display area' , ( ) => {
230+ test ( 'should fallback if session bounds are negative' , async ( ) => {
231+ mockSession . windowBounds = { left : - 10 , top : - 10 , width : 800 , height : 600 } ;
232+ await handleLoadSession ( mockSession . id ) ;
233+ expect ( global . chrome . windows . create ) . toHaveBeenCalledWith ( {
234+ url : [ 'https://example.com' , 'https://test.com' ] ,
235+ height : EXPECTED_FALLBACK_BOUNDS . height ,
236+ width : EXPECTED_FALLBACK_BOUNDS . width ,
237+ top : EXPECTED_FALLBACK_BOUNDS . top ,
238+ left : EXPECTED_FALLBACK_BOUNDS . left
239+ } ) ;
240+ } ) ;
241+
242+ test ( 'should fallback if session bounds extend beyond display' , async ( ) => {
243+ mockSession . windowBounds = { left : 100 , top : 100 , width : 2000 , height : 1200 } ;
244+ await handleLoadSession ( mockSession . id ) ;
245+ expect ( global . chrome . windows . create ) . toHaveBeenCalledWith ( {
246+ url : [ 'https://example.com' , 'https://test.com' ] ,
247+ height : EXPECTED_FALLBACK_BOUNDS . height ,
248+ width : EXPECTED_FALLBACK_BOUNDS . width ,
249+ top : EXPECTED_FALLBACK_BOUNDS . top ,
250+ left : EXPECTED_FALLBACK_BOUNDS . left
251+ } ) ;
252+ } ) ;
253+
254+ test ( 'should use bounds if they fit exactly within display' , async ( ) => {
255+ mockSession . windowBounds = { left : 0 , top : 0 , width : 1920 , height : 1080 } ;
256+ await handleLoadSession ( mockSession . id ) ;
257+ expect ( global . chrome . windows . create ) . toHaveBeenCalledWith ( {
258+ url : [ 'https://example.com' , 'https://test.com' ] ,
259+ height : 1080 ,
260+ width : 1920 ,
261+ top : 0 ,
262+ left : 0
263+ } ) ;
264+ } ) ;
265+
266+ test ( 'should fallback if bounds are just barely outside display' , async ( ) => {
267+ mockSession . windowBounds = { left : 0 , top : 0 , width : 1921 , height : 1081 } ;
268+ await handleLoadSession ( mockSession . id ) ;
269+ expect ( global . chrome . windows . create ) . toHaveBeenCalledWith ( {
270+ url : [ 'https://example.com' , 'https://test.com' ] ,
271+ height : EXPECTED_FALLBACK_BOUNDS . height ,
272+ width : EXPECTED_FALLBACK_BOUNDS . width ,
273+ top : EXPECTED_FALLBACK_BOUNDS . top ,
274+ left : EXPECTED_FALLBACK_BOUNDS . left
225275 } ) ;
226276 } ) ;
227277 } ) ;
0 commit comments