883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
58 lines
3.2 KiB
Lua
58 lines
3.2 KiB
Lua
-- Exercises the real event callback; no client/API execution is performed.
|
|
local source=arg[1] or "client_addons/GatewayDiagnostics/SessionObserver.lua"
|
|
local function run(options)
|
|
local frame,calls={},{}
|
|
local failGuard=false
|
|
local secret={};local saved={schema=1,active=options.active~=false,rows={},bytes=0,dropped=0,session="fixture"}
|
|
local env={GatewayDiagnosticsSaved={sessionObservation=saved},SlashCmdList={},DEFAULT_CHAT_FRAME={AddMessage=function()end},
|
|
GetTime=function()return 10 end,date=function()return "fixture"end,hooksecurefunc=function()end}
|
|
setmetatable(env,{__index=_G});env._G=env
|
|
env.CreateFrame=function()return frame end
|
|
function frame:RegisterEvent()end
|
|
function frame:SetScript(_,callback)self.callback=callback end
|
|
env.issecretvalue=function(value)
|
|
if options.badGuard and failGuard then error("private error")end
|
|
return value==secret
|
|
end
|
|
if options.noGuard then env.issecretvalue=false end
|
|
env.GetNumTitles=function()calls[#calls+1]="count";return 222,nil,true end
|
|
env.GetCurrentTitle=function()calls[#calls+1]="current";return secret end
|
|
env.GetTitleName=function(index)
|
|
calls[#calls+1]=index
|
|
if index==18 then error("private error")end
|
|
if index==111 then return secret,true end
|
|
if index==112 then return {},false end
|
|
return "Title "..index,index==0
|
|
end
|
|
if options.unavailable then env.GetTitleName=false end
|
|
assert(loadfile(source,"t",env))()
|
|
frame.callback(frame,"PLAYER_LOGIN")
|
|
assert(not saved.originalTitleMetadata and #calls==0)
|
|
failGuard=true
|
|
frame.callback(frame,"PLAYER_ENTERING_WORLD")
|
|
local observation=saved.originalTitleMetadata
|
|
frame.callback(frame,"PLAYER_ENTERING_WORLD")
|
|
return observation,calls,secret
|
|
end
|
|
local observed,calls,secret=run({})
|
|
assert(observed.status=="complete"and #calls==9)
|
|
local indices={0,1,18,111,112,144,1225}
|
|
for i,index in ipairs(indices)do assert(calls[i+2]==index and observed.calls[i+2].index==index)end
|
|
assert(observed.calls[1].values[2].kind=="nil"and observed.calls[1].values[3].value==true)
|
|
assert(observed.calls[2].values[1].status=="secret")
|
|
assert(observed.calls[5].status=="error"and not observed.calls[5].values)
|
|
assert(observed.calls[6].values[1].status=="secret"and observed.calls[6].values[2].value==true)
|
|
assert(observed.calls[7].values[1].status=="unsupported"and not observed.calls[7].values[1].value)
|
|
local function contains(value,needle)
|
|
if value==needle then return true end
|
|
if type(value)=="table"then for _,child in pairs(value)do if contains(child,needle)then return true end end end
|
|
return false
|
|
end
|
|
assert(not contains(observed,secret)and not contains(observed,"private error"))
|
|
local unavailable,availableCalls=run({unavailable=true})
|
|
assert(#availableCalls==2 and unavailable.calls[3].status=="unavailable")
|
|
local guarded=run({badGuard=true});assert(guarded.calls[1].values[1].status=="secret-guard-failed")
|
|
local held,heldCalls=run({noGuard=true});assert(held.status=="secret-guard-unavailable"and #heldCalls==0)
|
|
local inactive,inactiveCalls=run({active=false});assert(inactive.status=="recorder-inactive"and #inactiveCalls==0)
|
|
print("PASS title observation: fixed calls, event-only/once, availability and secret refusal")
|