# -- integration tests: real-world patterns -------------------------------- test_that("full HTML document structure renders correctly", { doc <- tags$html( tags$head( tags$title("My Page"), tags$meta(charset = "utf-8"), tags$link(rel = "stylesheet", href = "style.css") ), tags$body( tags$h1("Hello"), tags$p("Welcome") ) ) html <- render(doc) expect_match(html, "^") expect_match(html, "$") expect_match(html, "My Page") expect_match(html, '') expect_match(html, '') expect_match(html, "

Hello

") }) test_that("form with mixed void and non-void elements", { form <- tags$form( action = "/submit", method = "post", tags$label(`for` = "name", "Name:"), tags$input(type = "text", id = "name", name = "name"), tags$button(type = "submit", "Submit") ) html <- render(form) expect_match(html, '
') expect_match(html, '') expect_match(html, '') expect_match(html, "") }) test_that("list generated with lapply is properly flattened", { items <- c("Alpha", "Beta", "Gamma") ul <- tags$ul(lapply(items, function(x) tags$li(x))) html <- render(ul) expect_equal( html, "" ) }) test_that("table with multiple rows and cells", { tbl <- tags$table( class = "data-table", tags$thead( tags$tr(tags$th("Name"), tags$th("Age")) ), tags$tbody( tags$tr(tags$td("Alice"), tags$td("30")), tags$tr(tags$td("Bob"), tags$td("25")) ) ) html <- render(tbl) expect_match(html, '') expect_match(html, "") expect_match(html, "") }) test_that("XSS content is properly escaped in text and attributes", { node <- tags$div( title = '', "" ) html <- render(node) # Attribute value should be escaped expect_false(grepl("
NameAgeAlice30