# #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 = '
' + "A" * 200 + "
" assert _estimate_markdown_height(content) == 24 # #endregion test_content_with_padding # #region test_very_long_content [C:2] [TYPE Function] # @BRIEF Very long content (3000 chars) capped at max height 200. def test_very_long_content(self): text = "A" * 3000 assert _estimate_markdown_height(text) == 200 # #endregion test_very_long_content # #region test_html_only_content [C:2] [TYPE Function] # @BRIEF HTML-only content (no visible text) returns minimum height 19. def test_html_only_content(self): content = "

" assert _estimate_markdown_height(content) == 19 # #endregion test_html_only_content # #endregion TestLayoutUtils