Files
WoW-Hybrid-gateway/tests/issue_reporter_visibility_test.py
praxisandClaude Fable 5.2 7f2139d8d0 Offline test fixtures
883 files, from working commit b1a079a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 01:32:48 +02:00

57 lines
2.5 KiB
Python

"""Original-frame visibility and release closure; no real UI or client access."""
from pathlib import Path
import json,subprocess,unittest
ROOT=Path(__file__).resolve().parents[1]
LUA=ROOT/'client_addons/WoWHybridIssueReporter/IssueReporter.lua'
STUB=r'''
local frames = {}
function CreateFrame(kind)
assert(kind == "Frame")
local f={scripts={},hooks={},events={},shown=true,originalShows=0}
function f:Hide() self.shown=false end
function f:HookScript(event, callback)
self.hooks[event]=self.hooks[event] or {}
table.insert(self.hooks[event], callback)
end
function f:RegisterEvent(event) self.events[event]=true end
function f:SetScript(event,callback) self.scripts[event]=callback end
function f:Show()
self.shown=true
if self.scripts.OnShow then self.scripts.OnShow(self) end
for _,fn in ipairs(self.hooks.OnShow or {}) do fn(self) end
end
table.insert(frames,f)
return f
end
local function reporter()
local f=CreateFrame("Frame")
f:SetScript("OnShow",function(self) self.originalShows=self.originalShows+1 end)
return f
end
'''
class IssueReporterVisibility(unittest.TestCase):
def lua(self,program):
result=subprocess.run(['lua','-'],input=STUB+program,text=True,capture_output=True,timeout=5)
self.assertEqual(result.returncode,0,result.stderr)
def load(self):return 'dofile('+json.dumps(str(LUA))+')\n'
def test_addon_does_not_hide_or_hook_original_reporter(self):
self.lua('PTR_IssueReporter=reporter()\n'+self.load()+'''local events=frames[#frames]
assert(PTR_IssueReporter.shown and PTR_IssueReporter.hooks.OnShow == nil)
events.scripts.OnEvent(events,"PLAYER_ENTERING_WORLD")
assert(PTR_IssueReporter.shown and PTR_IssueReporter.hooks.OnShow == nil)
''')
def test_reminder_filter_preserves_unrelated_system_messages(self):
self.lua('''local filters = {}
function ChatFrame_AddMessageEventFilter(event, filter)
assert(event == "CHAT_MSG_SYSTEM"); table.insert(filters, filter)
end
'''+self.load()+'''local events=frames[#frames]
events.scripts.OnEvent(events,"PLAYER_ENTERING_WORLD")
assert(#filters == 1)
local reminder = "Remember to act responsibly, protect your personal information, and don't post anything offensive. View our In-Game Code of Conduct on https://support.blizzard.com/article/42673 for more information."
assert(filters[1](nil,"CHAT_MSG_SYSTEM",reminder) == true)
assert(filters[1](nil,"CHAT_MSG_SYSTEM","A different system message") == false)
assert(filters[1](nil,"CHAT_MSG_SAY",reminder) == false)
''')
if __name__=='__main__':unittest.main()