Files
WoW-Hybrid-gateway/tests/octo_guild_bank_observer_test.lua
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

45 lines
2.6 KiB
Lua

local root=arg[1]
local sent={};local messages={}
local rawSend=function(a,b,c,d) table.insert(sent,{a,b,c,d});return "preserved",42 end
SendAddonMessage=rawSend
local rawChat=function(a,b,c,d) table.insert(sent,{a,b,c,d});return 7 end
SendChatMessage=rawChat
GetTime=function()return 1.25 end
local frames={}
CreateFrame=function()
local f={};table.insert(frames,f)
function f:RegisterEvent(e)self.registered=e end
function f:SetScript(e,h)self.handler=h end
function f:UnregisterAllEvents()self.registered=nil end
return f
end
SlashCmdList={};DEFAULT_CHAT_FRAME={AddMessage=function(_,v)table.insert(messages,v)end}
if not table.getn then table.getn=function(t)return #t end end
dofile(root..'/client_addons/OctoGuildBankCapture/Observer.lua')
assert(WoWHybridBankObserver==nil)
-- Simulate SavedVariables restoration after addon Lua, then PLAYER_LOGIN.
pfUI_cache={existing='preserved'};event='PLAYER_LOGIN';frames[1].handler()
assert(pfUI_cache.existing=='preserved')
local frame=frames[2]
local O=WoWHybridBankObserver;local C=O.capture
assert(#sent==0 and #C.rows==0 and frame.registered=='CHAT_MSG_ADDON')
local a,b=SendAddonMessage('TW_GUILDBANK','GetBankInfo:','GUILD','target')
assert(a=='preserved'and b==42 and #sent==1 and sent[1][4]=='target')
SendAddonMessage('OTHER','private non-bank message','GUILD')
assert(#C.rows==1)
event='CHAT_MSG_ADDON';arg1='TW_GUILDBANK';arg2='BankInfo:money:100';arg3='WHISPER';arg4='not-recorded'
frame.handler();assert(#C.rows==2 and C.rows[2].payload==arg2 and C.rows[2].sender==nil)
arg1='OTHER';frame.handler();assert(#C.rows==2)
assert(SendChatMessage('TW_GUILDBANK\tGetTabItems:1','GUILD','Addon')==7)
assert(#C.rows==3)
SendChatMessage('TW_GUILDBANK ordinary chat','GUILD','Common');assert(#C.rows==3)
SlashCmdList.WOWHYBRIDBANKCAPTURE('mark tab1');assert(#C.rows==4 and C.rows[4].direction=='marker')
SendAddonMessage('TW_GUILDBANK',string.rep('x',8193),'GUILD');assert(C.dropped==1 and #C.rows==4)
O.maxRows=4;SendAddonMessage('TW_GUILDBANK','bounded','GUILD');assert(C.dropped==2)
O.maxRows=8192;O.maxBytes=C.bytes;SendAddonMessage('TW_GUILDBANK','bounded','GUILD');assert(C.dropped==3)
local hook=SendAddonMessage;dofile(root..'/client_addons/OctoGuildBankCapture/Observer.lua');assert(SendAddonMessage==hook)
SlashCmdList.WOWHYBRIDBANKCAPTURE('stop')
assert(SendAddonMessage==rawSend and SendChatMessage==rawChat and frame.registered==nil)
SendAddonMessage('TW_GUILDBANK','after detach','GUILD');assert(#C.rows==4)
print('Bank-only observer preserves sends/returns, excludes normal chat and sender, bounds capture, and detaches; no wire or server acceptance claim.')