-- test_nav_theme.lua
-- Verifies:
--   1. NavRow + NavRegion skinners are registered in HDG.Theme.Skinners.
--   2. Each executes without error against a minimal mock frame, across the
--      nav tier / active / spine states.
--
-- The sidebar nav is a TreeList (navNode cell) painted by NavRow; NavRegion
-- paints the nav panel background. (The retired navItem-widget NavItem/NavHome
-- skinners were removed 2026-05-30.)
--
-- Skinner signature: Skinner(frame, scheme, state).

local _realPrint = print
local function out(s) _realPrint(s) end

dofile("wow_mock.lua")
dofile("../Core/HDGR_SchemeConstants.lua")
dofile("../Core/HDGR_Constants.lua")
dofile("../Core/HDGR_Format.lua")
dofile("../Core/HDGR_Paths.lua")
dofile("../Core/HDGR_Log.lua")

-- Minimal Store stub: Theme:Initialize subscribes to scheme-change dispatches.
HDG.Store = HDG.Store or {
    Subscribe  = function() end,
    GetState   = function() return { account = { config = { scheme = "" } } } end,
}

dofile("../UI/HDGR_Theme.lua")

local function assertTrue(v, label)
    if not v then error("ASSERT FAILED: " .. tostring(label), 2) end
end

-- Confirm the live nav skinners are registered.
assertTrue(HDG.Theme.Skinners.NavRow,    "NavRow skinner registered")
assertTrue(HDG.Theme.Skinners.NavRegion, "NavRegion skinner registered")

-- Mock texture: the subset NavRow calls on the chrome textures + icon/guide.
local function mockTex()
    return {
        SetVertexColor  = function() end,
        SetColorTexture = function() end,
        Show            = function() end,
        Hide            = function() end,
    }
end

-- Mock nav row: EnsureRowChrome's textures (NavRow paints these) + the
-- category icon + indent guide (tinted by NavRow).
local function navRowFrame()
    return {
        _hdgrChrome = {
            accentBar  = mockTex(),
            selectedBg = mockTex(),
            hover      = mockTex(),
            zebra      = mockTex(),
        },
        _navIcon  = mockTex(),
        _navGuide = mockTex(),
    }
end

-- NavRow across the tier / active / spine matrix (no errors expected).
local NavRow = HDG.Theme.Skinners.NavRow
NavRow(navRowFrame(), "default", { tier = "home",   active = false, spine = false })
NavRow(navRowFrame(), "default", { tier = "hub",    active = true,  spine = true  })  -- active group parent
NavRow(navRowFrame(), "default", { tier = "leaf",   active = true,  spine = true  })  -- active leaf
NavRow(navRowFrame(), "default", { tier = "leaf",   active = false, spine = true  })  -- spine sibling
NavRow(navRowFrame(), "default", { tier = "parent", active = false, spine = false })
NavRow(navRowFrame(), "default", { tier = "config", active = true,  spine = false })
NavRow(navRowFrame(), "default", { tier = "header", active = false, spine = false })
NavRow(navRowFrame(), "default", nil)                       -- nil state: no fill/bar
NavRow({}, "default", { tier = "leaf" })                    -- no _hdgrChrome: early return, no error

-- NavRegion: the nav panel background (panel_soft bg, default border).
local function regionFrame()
    return {
        SetBackdrop            = function() end,
        SetBackdropColor       = function() end,
        SetBackdropBorderColor = function() end,
    }
end
HDG.Theme.Skinners.NavRegion(regionFrame(), "default", nil)

out("test_nav_theme.lua passed")
