Files
amibis/Amibis/Tests/test_ui.lua
T
dfj cc3971fe93 Fix stat panel not rebuilding when switching specs
RebuildStatRows hid the previous rows through vals.label, but StatValues
never stored the label font string. The first spec change that altered
the stat keys raised "attempt to index a nil value (field 'label')",
aborting RefreshUI before the new rows were created. The previous spec's
panel stayed on screen, so a Holy priest kept seeing Shadow's
"+Spell Damage" row instead of "+Healing".

Store the label in StatValues so old rows hide correctly and the panel
rebuilds with the new spec's profile.

Add a UI smoke test using mocked frames (font strings now record
text/shown; frames track Show/Hide/IsShown). It switches Shadow -> Holy
and asserts the visible rows change; with the bug reverted it fails with
the same nil-label error.

Also print usage for a bare "/amibis spec" instead of toggling the
window, which was a surprising side effect and made tests order-dependent.

107 passing.
2026-10-24 13:42:08 +02:00

57 lines
1.7 KiB
Lua

-- UI smoke tests: the stats panel must rebuild when the selected spec changes.
local _, ns = ...
local function cacheList(list)
for _, entry in pairs(list) do
MockItems[entry.itemID] = {
name = entry.name,
stats = {
["ITEM_MOD_INTELLECT_SHORT"] = 50,
["ITEM_MOD_SPIRIT_SHORT"] = 30,
["ITEM_MOD_SPELL_DAMAGE_DONE_SHORT"] = 40,
["ITEM_MOD_SPELL_HEALING_DONE_SHORT"] = 60,
},
}
end
end
local function visibleTexts()
local texts = {}
for _, frame in ipairs(MockFrames) do
for _, fontString in ipairs(frame.fonts or {}) do
if fontString.shown and fontString.text and fontString.text ~= "" then
texts[fontString.text] = true
end
end
end
return texts
end
describe("UI stat panel", function()
it("shows healing after switching from Shadow to Holy", function()
MockItems = {}
MockEquipped = {}
AmibisDB.selectedPhase = "ZA"
AmibisCharDB.overrideSpec = "Shadow"
cacheList(ns.Data.BISLists:GetBISList("PRIEST", "Shadow", "ZA"))
cacheList(ns.Data.BISLists:GetBISList("PRIEST", "Holy", "ZA"))
ns.UI.Initialize()
if not ns.UI.IsShown() then
ns.UI.ToggleFrame()
end
local shadowTexts = visibleTexts()
expect(shadowTexts["+Spell Damage"]).toBeTruthy()
expect(shadowTexts["+Healing"]).toBeFalsy()
AmibisCharDB.overrideSpec = "Holy"
ns.UI.RefreshUI()
local holyTexts = visibleTexts()
expect(holyTexts["+Healing"]).toBeTruthy()
expect(holyTexts["+Spell Damage"]).toBeFalsy()
end)
end)