@@ -348,3 +348,94 @@ def test_sorted_by_grid_id(self):
348348 assert result [0 ].grid_id == 0
349349 assert result [1 ].grid_id == 1
350350 assert result [2 ].grid_id == 2
351+
352+
353+ class TestGridInfoModalFields :
354+ """Tests for GridInfo z-index and modal detection fields"""
355+
356+ def test_grid_info_default_values (self ):
357+ """Test that GridInfo has correct default values for new fields"""
358+ grid_info = GridInfo (
359+ grid_id = 0 ,
360+ bbox = BBox (x = 0 , y = 0 , width = 100 , height = 100 ),
361+ row_count = 1 ,
362+ col_count = 1 ,
363+ item_count = 1 ,
364+ )
365+ # New optional fields should have defaults
366+ assert grid_info .z_index == 0
367+ assert grid_info .z_index_max == 0
368+ assert grid_info .blocks_interaction is False
369+ assert grid_info .viewport_coverage == 0.0
370+
371+ def test_grid_info_with_modal_fields (self ):
372+ """Test creating GridInfo with modal detection fields"""
373+ grid_info = GridInfo (
374+ grid_id = 1 ,
375+ bbox = BBox (x = 100 , y = 100 , width = 500 , height = 400 ),
376+ row_count = 2 ,
377+ col_count = 3 ,
378+ item_count = 6 ,
379+ confidence = 0.95 ,
380+ z_index = 1000 ,
381+ z_index_max = 1000 ,
382+ blocks_interaction = True ,
383+ viewport_coverage = 0.25 ,
384+ )
385+ assert grid_info .z_index == 1000
386+ assert grid_info .z_index_max == 1000
387+ assert grid_info .blocks_interaction is True
388+ assert grid_info .viewport_coverage == 0.25
389+
390+
391+ class TestSnapshotModalFields :
392+ """Tests for Snapshot modal detection fields"""
393+
394+ def test_snapshot_without_modal (self ):
395+ """Test snapshot with no modal detected"""
396+ snapshot = Snapshot (
397+ status = "success" ,
398+ url = "https://example.com" ,
399+ elements = [],
400+ )
401+ # modal_detected and modal_grids should be None by default
402+ assert snapshot .modal_detected is None
403+ assert snapshot .modal_grids is None
404+
405+ def test_snapshot_with_modal_detected (self ):
406+ """Test snapshot with modal detected"""
407+ modal_grid = GridInfo (
408+ grid_id = 1 ,
409+ bbox = BBox (x = 200 , y = 150 , width = 600 , height = 400 ),
410+ row_count = 1 ,
411+ col_count = 2 ,
412+ item_count = 5 ,
413+ z_index = 1000 ,
414+ z_index_max = 1000 ,
415+ blocks_interaction = True ,
416+ viewport_coverage = 0.20 ,
417+ )
418+ snapshot = Snapshot (
419+ status = "success" ,
420+ url = "https://example.com" ,
421+ elements = [],
422+ modal_detected = True ,
423+ modal_grids = [modal_grid ],
424+ )
425+ assert snapshot .modal_detected is True
426+ assert snapshot .modal_grids is not None
427+ assert len (snapshot .modal_grids ) == 1
428+ assert snapshot .modal_grids [0 ].z_index == 1000
429+ assert snapshot .modal_grids [0 ].blocks_interaction is True
430+
431+ def test_snapshot_modal_false (self ):
432+ """Test snapshot with modal_detected explicitly False"""
433+ snapshot = Snapshot (
434+ status = "success" ,
435+ url = "https://example.com" ,
436+ elements = [],
437+ modal_detected = False ,
438+ modal_grids = None ,
439+ )
440+ assert snapshot .modal_detected is False
441+ assert snapshot .modal_grids is None
0 commit comments