Files
WoW-Hybrid-gateway/tests/native_nameplate_binding_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

23 lines
1.9 KiB
Python

"""Run the actual UI module with original setter/hook and delayed-load contracts."""
from pathlib import Path
import subprocess
ROOT=Path(__file__).resolve().parents[1];source=ROOT/'client_addons/WoWHybridUI/NativeNameplates.lua'
lua=r'''
local path=arg[1];local cvar={};local callbacks={};local original=0;local hooks=0
function SetCVar(k,v)cvar[k]=v end
function hooksecurefunc(t,k,callback)local f=t[k];t[k]=function(...)local result=f(...);callback(...);return result end;hooks=hooks+1 end
function CreateFrame()local f={};function f:RegisterEvent(e)self.event=e end;function f:UnregisterEvent(e)assert(self.event==e);self.event=nil end;function f:SetScript(_,cb)callbacks[#callbacks+1]={self,cb}end;return f end
Settings=nil;dofile(path);assert(not WoWHybridUI.nameplatesInstalled and #callbacks==1)
Settings={SetValue=function(k,v)original=original+1;return 'original-result' end}
callbacks[1][2](callbacks[1][1]);assert(WoWHybridUI.nameplatesInstalled and hooks==1 and callbacks[1][1].event==nil)
assert(Settings.SetValue('nameplateShowFriendlyPlayers',false)=='original-result');assert(cvar.nameplateShowFriendlyNpcs=='0')
Settings.SetValue('nameplateShowFriendlyPlayers',true);assert(cvar.nameplateShowFriendlyNpcs=='1')
Settings.SetValue('nameplateShowEnemies',false);assert(cvar.nameplateShowFriendlyNpcs=='1')
Settings.SetValue('nameplateShowFriendlyPlayers',0);assert(cvar.nameplateShowFriendlyNpcs=='1') -- no truthiness error
SetCVar('nameplateShowFriendlyNpcs','0');assert(cvar.nameplateShowFriendlyNpcs=='0') -- individual NPC setting still works
Settings.SetValue('unrelated',true);assert(cvar.nameplateShowFriendlyNpcs=='0')
dofile(path);assert(hooks==1 and original==5) -- no duplicate callbacks
'''
subprocess.run(['lua','-',str(source)],input=lua.encode(),check=True)
print('Actual UI module preserves original setter/results, filters boolean friendly toggles, handles delayed initialization and avoids duplicate hooks. Real keypress/reload still required.')