test_that("gui_datatable returns a DT htmlwidget", { df <- data.frame(x = 1:3, y = c("a", "b", "c")) widget <- gui_datatable(df) expect_s3_class(widget, "datatables") }) test_that("gui_snapshot_png writes a real PNG file", { path <- gui_snapshot_png(plot(1:10, 1:10)) expect_true(file.exists(path)) expect_gt(file.size(path), 0) expect_match(path, "\\.png$") unlink(path) }) test_that("gui_render_report renders a real HTML file from a populated store", { Ce <- c(2, 5, 10, 20, 35, 50, 70) qe <- c(0.8, 1.6, 2.3, 3.0, 3.6, 4.0, 4.4) fit <- biocharkit::fit_langmuir(Ce, qe) set.seed(1) Temp <- seq(25, 800, by = 10) Weight <- 100 - 5 * (Temp > 110) - 40 / (1 + exp(-(Temp - 340) / 20)) + rnorm(length(Temp), 0, 0.15) tga_curve <- data.frame(temperature_C = Temp, weight_pct = pmax(Weight, 20)) tga_stages <- biocharkit::tga_stages(tga_curve) tga_peaks <- biocharkit::find_dtg_peaks(biocharkit::tga_dtg(tga_curve), min_prominence = 0.05) kis <- biocharkit::tga_kinetics_kissinger(c(5, 10, 15, 20), c(320, 335, 344, 351)) store <- list( sample_ids = biocharkit::parse_sbc_id(c("SBC300-15")), adsorption = NULL, isotherm = list(model = "langmuir", batch = FALSE, params = data.frame(model = "Langmuir", Qmax_mgg = fit$Qmax, KL_Lmg = fit$KL, R2 = fit$R2), plot_path = NULL), kinetics = NULL, thermo = NULL, ftir_functional_groups = NULL, ftir_peak_assignment = NULL, xrd = NULL, bet = NULL, tga = list(batch = FALSE, stages = tga_stages, peaks = tga_peaks, plot_path = NULL), tga_kissinger = data.frame(Ea_kJmol = kis$Ea_kJmol, A_min1 = kis$A_min1, R2 = kis$R2), proximate = NULL, ultimate = NULL, correlation = NULL ) out <- tempfile(fileext = ".html") gui_render_report(store, out) expect_true(file.exists(out)) expect_gt(file.size(out), 0) html <- readLines(out, warn = FALSE) expect_true(any(grepl("Isotherm", html))) expect_true(any(grepl("TGA Analysis", html))) expect_true(any(grepl("Kissinger", html))) unlink(out) }) test_that("gui_render_report handles an entirely empty store gracefully", { empty_store <- list(sample_ids = NULL, adsorption = NULL, isotherm = NULL, kinetics = NULL, thermo = NULL, ftir_functional_groups = NULL, ftir_peak_assignment = NULL, xrd = NULL, bet = NULL, tga = NULL, tga_kissinger = NULL, proximate = NULL, ultimate = NULL, correlation = NULL) out <- tempfile(fileext = ".html") gui_render_report(empty_store, out) expect_true(file.exists(out)) unlink(out) })