-- 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) it("closes the window when Escape is pressed", function() ns.UI.Initialize() if not ns.UI.IsShown() then ns.UI.ToggleFrame() end expect(ns.UI.IsShown()).toBeTruthy() local registered = false for _, name in ipairs(UISpecialFrames) do if name == "AmibisMainFrame" then registered = true end end expect(registered).toBeTruthy() -- Simulate an in-flight stats retry so the OnHide cleanup is exercised. ns.Amibis._statsRetryTimer = CreateFrame("Frame") -- Mirrors FrameXML's CloseSpecialWindows(): hide every shown special frame. for _, name in ipairs(UISpecialFrames) do local frame = _G[name] if frame and frame:IsShown() then frame:Hide() end end expect(ns.UI.IsShown()).toBeFalsy() expect(ns.Amibis._statsRetryTimer).toBeNil() end) end)