from genesis.writer.renderer import render_chapter_blocks from genesis.writer.models import ChapterContent, ContentBlock def _content(): blocks = [ ContentBlock(block_id="1", type="heading", level=2, text="小節"), ContentBlock(block_id="2", type="paragraph", text="正文"), ContentBlock(block_id="3", type="table", caption="表1", headers=["見出しA", "見出しB"], rows=[["a", "b"], ["1", "2"]]), ContentBlock(block_id="4", type="list", items=["項目一", "項目二"], style="bullet"), ContentBlock(block_id="5", type="note", text="注意"), ] return ChapterContent(chapter_id="db_design", version=1, title="DB 設計", blocks=blocks) def test_render_maps_all_block_types(): out = render_chapter_blocks(_content()) kinds = [b.kind for b in out] assert kinds == ["heading", "paragraph", "table", "list", "note"] def test_render_preserves_table_headers_and_caption(): # 外视 #6 反转:表头/标题不再塌缩,须透传至注入器 out = render_chapter_blocks(_content()) table = out[2] assert table.kind == "table" assert table.headers == ["見出しA", "見出しB"] assert table.text == "表1" # caption assert table.rows == [["a", "b"], ["1", "2"]] def test_render_preserves_list_items_and_style(): out = render_chapter_blocks(_content()) lst = out[3] assert lst.kind == "list" assert lst.items == ["項目一", "項目二"] assert lst.style == "bullet"