# #region TestLayoutUtils [C:3] [TYPE TestModule] [SEMANTICS test, layout, superset, height, estimation] # @BRIEF Contract tests for layout utility functions — _estimate_markdown_height. # Verifies the height estimation formula: empty → 19, short text → computed, # padding accounted for, and long text capped at 200. # @LAYER Test # @RELATION BINDS_TO -> [LayoutUtils] # @TEST_CONTRACT: _estimate_markdown_height(str) -> int in [19, 200] # @TEST_EDGE: empty_content -> returns minimum height (19) # @TEST_EDGE: html_only_content -> returns minimum height (19) # @TEST_EDGE: content_with_padding -> padding:12 correctly increases height # @TEST_EDGE: very_long_content -> capped at maximum height (200) import pytest from src.core.superset_client._layout_utils import _estimate_markdown_height class TestEstimateMarkdownHeight: """Tests for _estimate_markdown_height pure function.""" # #region test_empty_content [C:2] [TYPE Function] # @BRIEF Empty string returns minimum height 19. def test_empty_content(self): assert _estimate_markdown_height("") == 19 # #endregion test_empty_content # #region test_single_line_text [C:2] [TYPE Function] # @BRIEF Short text without padding returns expected computed height. # 200 chars → 200//40+1 = 6 lines → 6*22 = 132px → 40+132 = 172px → 172//8 = 21 def test_single_line_text(self): text = "A" * 200 assert _estimate_markdown_height(text) == 21 # #endregion test_single_line_text # #region test_content_with_padding [C:2] [TYPE Function] # @BRIEF Content with padding:12 — 24px added to content height. # 200 chars + padding:12 → 6*22 + 24 = 156 → 40+156 = 196 → 196//8 = 24 def test_content_with_padding(self): content = '