Close the window when Escape is pressed

Register the main frame ("AmibisMainFrame") in UISpecialFrames so Escape
hides it and suppresses the game menu while it is open, matching the
default UI panels.

Move the stats-retry timer cleanup into the frame's OnHide script so the
close button, Escape, and /amibis all stop the timer.

Tests: the mock now registers named frames in _G and runs OnHide scripts.
The UI suite simulates FrameXML's CloseSpecialWindows() and asserts the
frame hides and the retry timer is cleared. 108 passing.
This commit is contained in:
dfj committed 2026-10-24 13:57:09 +02:00
1 parent cc3971fe93
commit d8fefc947e
6 files changed
+77 -9

No files matched your search

+26
View File
@@ -53,4 +53,30 @@ describe("UI stat panel", function()
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)