# frozen_string_literal: true require "test_helper" class IntegrationTest < Minitest::Test include EzdocTestHelpers def test_complex_document_with_all_features xml_files = create_doc_and_read_all_xml do |doc| doc.p "Introduction paragraph" doc.p do doc.text "This has " doc.b { doc.text "bold" } doc.text " and " doc.i { doc.text "italic" } doc.text " text." end doc.ul do doc.li "Bullet point 1" doc.li { doc.b { doc.text "Bold bullet" } } end doc.ol do doc.li "Numbered item 1" doc.li "Numbered item 2" end doc.table do doc.tr do doc.td "Header 1" doc.td "Header 2" end doc.tr do doc.td { doc.i { doc.text "Italic cell" } } doc.td "Normal cell" end end doc.p "Conclusion paragraph" end doc_xml = xml_files["word/document.xml"] # Verify all content types are present assert_includes doc_xml, "Introduction paragraph" assert_includes doc_xml, "Conclusion paragraph" assert_includes doc_xml, "" assert_includes doc_xml, "" assert_includes doc_xml, "" assert_includes doc_xml, "") after_pos = xml.index("After table") assert before_pos < table_pos assert table_pos < after_pos end def test_formatting_in_list_items xml = create_doc_and_read_xml do |doc| doc.ul do doc.li do doc.b do doc.i { doc.text "Bold and italic in list" } end end end end assert_includes xml, "" assert_includes xml, "" assert_includes xml, "Bold and italic in list" end def test_formatting_in_table_cells xml = create_doc_and_read_xml do |doc| doc.table do doc.tr do doc.td do doc.b do doc.i { doc.text "Bold and italic in table" } end end end end end assert_includes xml, "" assert_includes xml, "" assert_includes xml, "Bold and italic in table" end def test_multiple_features_interleaved xml = create_doc_and_read_xml do |doc| doc.p "Para 1" doc.ul { doc.li "Bullet" } doc.p "Para 2" doc.table { doc.tr { doc.td "Cell" } } doc.p "Para 3" doc.ol { doc.li "Number" } doc.p "Para 4" end # Verify all elements exist assert_includes xml, "Para 1" assert_includes xml, "Para 4" assert_includes xml, "Bullet" assert_includes xml, "Cell" assert_includes xml, "Number" # Verify correct ordering positions = [ xml.index("Para 1"), xml.index("Bullet"), xml.index("Para 2"), xml.index(""), xml.index("Para 3"), xml.index("Number"), xml.index("Para 4") ] positions.each_cons(2) do |a, b| assert a < b, "Elements should be in correct order" end end end