//! `CreateFrame`'s fourth argument against the **real** `assets/ui` templates — the corpus idiom,
//! end to end.
//!
//! The unit tests for the runtime template path live in
//! `benilla-ui/src/script/tests/create_frame_template.rs` and drive synthetic templates. This one
//! exists because the thing an addon actually types is
//!
//! ```lua
//! local tab = CreateFrame("Button", "MyTab", UIParent, "TabButtonTemplate")
//! getglobal("MyTab".."Text"):SetText("Hi")
//! ```
//!
//! against a template *we* wrote, loaded the way the client loads it — six hundred lines of real
//! FrameXML above it, a font registry, an anchor graph — not a four-line fixture. Every assertion
//! below is a global an addon would reach for.
mod common;
use benilla_ui::script::UiScript;
/// The prefix of `benilla.toc`'s load order these templates need: the font registry, the panel kit,
/// UIParent (the parent every addon passes), and the faux-scroll kit.
///
/// **Two of the templates under test are the REFERENCE's since 1860** — `FauxScrollFrameTemplate`
/// and `TabButtonTemplate` were ours until the dead-copy sweep, and both now come off the player's
/// chain from `Interface\FrameXML\UIPanelTemplates.xml`, seated below `UiPanels.xml` exactly as
/// the manifest seats it. So this list carries the chain pair and the loader below has to be able
/// to READ a chain entry, which a disk-only provider under `assets/ui` cannot.
const FILES: &[&str] = &[
"Interface\\FrameXML\\Fonts.xml",
// A REGRESSION GUARD, not a dependency (1923). FadingFrame.xml's entire body is a single
// ``, so it loads correctly ONLY if that relative reference
// resolves against the document's own directory. Load it through the path-less `loader::load`
// and the base is "", the ref stays bare, the provider misses, and the assert below fires —
// which is exactly what it did before this file passed the path.
//
// It is self-contained on BOTH axes, and both had to be checked: zero `inherits=`, AND its Lua
// has no file-scope statements at all — only function definitions. The first guard tried here
// was CombatFeedback.xml, which also has zero `inherits=` but whose Lua calls `TEXT()` at file
// scope (l.7); that global is BasicControls.xml's, so it needed a dependency after all.
// `UnitFrame.lua` fails the same way (`TEXT(MANA)`). Structural dependencies are not the only
// kind.
"Interface\\FrameXML\\FadingFrame.xml",
r"Interface\FrameXML\MoneyFrame.lua",
r"Interface\FrameXML\MoneyFrame.xml",
r"Interface\FrameXML\UIParent.xml",
r"Interface\FrameXML\UIPanelTemplates.lua",
r"Interface\FrameXML\UIPanelTemplates.xml",
"Interface\\FrameXML\\GlobalStrings.lua",
"Interface\\FrameXML\\BasicControls.xml", // `TEXT`, which StaticPopup.lua reads at file scope
"Interface\\FrameXML\\LocaleProperties.lua",
"Interface\\FrameXML\\StaticPopup.xml", // the dialog engine (1960)
"ScrollTemplates.xml",
];
fn load_ui(script: &UiScript) {
for file in FILES {
common::load_ui(script, file);
}
}
/// The line an addon writes, and the globals it reads on the next one.
///
/// `TabButtonTemplate` (UiPanels.xml) is a `