883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
125 lines
10 KiB
Lua
125 lines
10 KiB
Lua
-- Focused view-boundary regression. This does not supply inspected talent data.
|
|
local function check(v,m) if not v then error(m or 'check failed',2) end end
|
|
local function eq(a,b,m)check(a==b,(m or 'different')..': '..tostring(a)..' / '..tostring(b))end
|
|
local noop=function()end
|
|
local function widget()
|
|
local w={shown=true}
|
|
function w:Hide()self.shown=false end
|
|
function w:Show()self.shown=true end
|
|
function w:SetShown(v)self.shown=v end
|
|
function w:SetOnClickHandler(fn)self.click=fn end
|
|
function w:SetupMenu(fn)self.menu=fn end
|
|
function w:SetPoint(...)self.point={...}end
|
|
function w:SetWidth(v)self.width=v end
|
|
function w:SetText(v)self.text=v end
|
|
return w
|
|
end
|
|
local driver,controls={},{}
|
|
function CreateFrame()driver={events={},scripts={}};function driver:RegisterEvent(e)self.events[e]=true end;function driver:SetScript(k,v)self.scripts[k]=v end;return driver end
|
|
C_ChatInfo={SendAddonMessage=function(...)controls[#controls+1]={...};return true end}
|
|
local guid='Player-70-A'
|
|
function UnitGUID()return guid end
|
|
function UnitName()return 'Praxis'end
|
|
function InCombatLockdown()return false end
|
|
function GetTime()return 0 end
|
|
function ShowUIPanel(f)f.shown=true end
|
|
local popupVisible=true
|
|
function StaticPopup_Hide(name)eq(name,'GATEWAY_TURTLE_TALENT_RESET');popupVisible=false end
|
|
function StaticPopup_Show()error('unexpected popup')end
|
|
function hooksecurefunc()end
|
|
function print()end
|
|
StaticPopupDialogs={};SlashCmdList={};ACCEPT='Accept';CANCEL='Cancel'
|
|
GameTooltip={lines={},Hide=function(s)s.hidden=true;s.lines={}end,AddLine=function(s,t)s.lines[#s.lines+1]=t end,SetOwner=function(s,o)s.owner=o;s.hidden=false end,IsOwned=function(s,o)return s.owner==o end,Show=noop}
|
|
local function enum()return setmetatable({},{__index=function()return 1 end})end
|
|
Enum={TraitNodeEntryType=enum(),TraitNodeType=enum(),TraitEdgeType=enum(),TraitEdgeVisualStyle=enum()}
|
|
TalentFrameBaseMixin={OnLoad=noop,Event={TalentButtonAcquired='acquired'}};ClassTalentsFrameMixin={RefreshConfigID=noop}
|
|
GatewayTurtleData={tabs={{id=1,classMask=1,order=1,name='Own tree',icon='Own icon'}},talents={{id=1,tab=1,row=0,column=0,prerequisite=0,prerequisiteRank=0,requiredSpell=0,ranks={{id=101,name='Own rank one',description='Own description'},{id=102,name='Own rank two',description='Own description'}}}},rankSuccessors={}}
|
|
local frame={shown=true,releaseCount=0,clearCount=0,scripts={},BackgroundBorder={}}
|
|
PlayerSpellsFrame={TalentsFrame=frame,talentTabID=1,shown=true}
|
|
function PlayerSpellsFrame:SetTab()end
|
|
function PlayerSpellsFrame:SetInspectUnit(unit)self.inspectUnit=unit;self.inspectString=nil;frame:UpdateInspecting()end
|
|
function frame:IsInspecting()return PlayerSpellsFrame.inspectUnit~=nil or PlayerSpellsFrame.inspectString~=nil end
|
|
function frame:GetInspectUnit()return PlayerSpellsFrame.inspectUnit end
|
|
function frame:GetInspectString()return PlayerSpellsFrame.inspectString end
|
|
function frame:SetDisabledOverlayShown(v)self.DisabledOverlay.shown=v end
|
|
function frame:ReleaseAllTalentButtons()self.releaseCount=self.releaseCount+1;self.loadedNodes={}end
|
|
function frame:ClearInfoCaches()self.clearCount=self.clearCount+1;self.nodeInfoCache={};self.entryInfoCache={};self.definitionInfoCache={};self.condInfoCache={};self.subTreeInfoCache={}end
|
|
function frame:MarkTreeDirty()self.dirty=true end
|
|
function frame:MarkTreeClean()self.dirty=false end
|
|
function frame:IsShown()return self.shown end
|
|
function frame:HookScript(k,f)self.scripts[k]=f end
|
|
function frame:RegisterCallback(_,f)self.acquired=f end
|
|
function frame:TriggerEvent()end
|
|
function frame:UpdateConfigButtonsState()end
|
|
function frame:RefreshClassCurrencyDisplay()end
|
|
function frame:UpdateAllButtons()end
|
|
function frame:GetTalentButtonByNodeID()return nil end
|
|
function frame:EnumerateAllTalentButtons()return function()end end
|
|
function frame:LoadTalentTreeInternal()self.loadedNodes=self:GetTreeNodes();for _,id in ipairs(self.loadedNodes)do check(self:GetAndCacheNodeInfo(id));end end
|
|
function frame:UpdateInspecting()self:RefreshConfigID();self:UpdateTreeInfo(true);self:UpdateTreeCurrencyInfo(true);self:RefreshTreeHeaders()end
|
|
frame.DisabledOverlay=widget();function frame.DisabledOverlay:CreateFontString()return widget()end
|
|
frame.treeHeaderPool={headers={}};function frame.treeHeaderPool:ReleaseAll()self.headers={}end;function frame.treeHeaderPool:Acquire()local h=widget();function h:Setup(info)self.info=info end;self.headers[#self.headers+1]=h;return h end
|
|
for _,k in ipairs({'TabSystem','ActiveSpec','LoadSystem','GamepadPrimaryTabIcon','GamepadSecondaryTabIcon','InspectCopyButton','SearchBox','SearchOptionsDropdown','ApplyButton','UndoButton','ResetButton','ClassCurrencyDisplay'})do frame[k]=widget()end
|
|
local component=GW_TALENT_COMPONENT_DIRECTORY or 'client_addons/GatewayDiagnostics'
|
|
dofile(component..'/TurtleTalentProvider.lua')
|
|
if GW_TALENT_ADDON_BOUNDARY_ONLY then
|
|
assert(loadfile(component..'/TurtleTalents.lua'))(GW_TALENT_ADDON_NAME)
|
|
else dofile(component..'/TurtleTalents.lua')end
|
|
local provider=GatewayTurtleTalents
|
|
local own={seq=1,guid=123,class=1,level=60,points=1,count=1,known={[101]=true}}
|
|
provider.state=own;provider:Changed();check(provider:Stage(1));eq(provider.staged[1],2)
|
|
if GW_TALENT_ADDON_BOUNDARY_ONLY then
|
|
frame.ApplyButton.click();check(provider.pending,'expected an in-flight purchase')
|
|
local pending=provider.pending
|
|
driver.scripts.OnEvent(driver,GW_TALENT_BLOCKED_EVENT or 'ADDON_ACTION_BLOCKED','UnrelatedAddon','ProtectedCall')
|
|
eq(provider.pending,pending,'another addon rejection must not stop this purchase')
|
|
driver.scripts.OnEvent(driver,GW_TALENT_BLOCKED_EVENT or 'ADDON_ACTION_BLOCKED',GW_TALENT_ADDON_NAME or 'GatewayDiagnostics','ProtectedCall')
|
|
eq(provider.pending,nil,'own addon rejection must stop the in-flight purchase')
|
|
eq(provider.state,own);eq(provider.staged[1],2,'unaccepted selection must remain reviewable')
|
|
eq(GatewayDiagnosticsSaved.turtleApply.status,'stopped')
|
|
eq(GatewayDiagnosticsSaved.turtleApply.reason,'client-protected-action-rejected')
|
|
eq(GatewayDiagnosticsSaved.turtleBlockedActions[1].addon,GW_TALENT_ADDON_NAME or 'GatewayDiagnostics')
|
|
io.write('PASS: canonical/legacy addon rejection preserves state and stops pending apply\n');return
|
|
end
|
|
eq(frame.turtleActiveContext,own);check(frame:HasValidConfig());eq(#frame:GetTreeNodes(),1);check(frame:GetAndCacheNodeInfo(1));eq(frame:GetAndCacheDefinitionInfo(1).spellID,102)
|
|
local button={GetNodeID=function()return 1 end};frame.acquired(nil,button)
|
|
local before=#controls
|
|
button:SetTooltipInternal();check(#GameTooltip.lines>0 and not GameTooltip.hidden)
|
|
PlayerSpellsFrame:SetInspectUnit('target')
|
|
check(GameTooltip.hidden and #GameTooltip.lines==0,'old own-rank tooltip survived inspect transition');check(not popupVisible,'old own reset popup survived inspect transition');check(not frame.ClassCurrencyDisplay.shown,'unavailable points widget must not display zero')
|
|
if GW_TALENT_CACHE_BOUNDARY_ONLY then
|
|
PlayerSpellsFrame:SetInspectUnit(nil);check(frame.ClassCurrencyDisplay.shown,'own point widget did not restore');eq(frame.turtleActiveContext,own);eq(provider.staged[1],2)
|
|
io.write('PASS: inspected tooltip/popup/points unavailable; own point widget and state restored; no control sent\n');eq(#controls,before);return
|
|
end
|
|
local function assertUnavailable()
|
|
eq(provider:ActiveContext(true),nil,'inspection cannot read self snapshot');eq(provider:ActiveContext(false),provider.state)
|
|
eq(frame.turtleActiveContext,nil);check(frame.turtleInspectUnavailable);check(frame.DisabledOverlay.shown and frame.GatewayTurtleInspectNotice.shown)
|
|
check(frame.GatewayTurtleInspectNotice.text:find('unavailable',1,true));eq(#frame:GetTreeNodes(),0)
|
|
eq(frame:GetAndCacheNodeInfo(1),nil);eq(frame:GetAndCacheEntryInfo(1),nil);eq(frame:GetAndCacheDefinitionInfo(1),nil)
|
|
eq(frame.talentTreeInfo,nil);eq(next(frame.treeCurrencyInfo),nil);eq(next(frame.treeCurrencyInfoMap),nil);eq(#frame.treeHeaders,0)
|
|
eq(#frame:GetNodeCost(1),0);check(frame:IsLocked());check(not frame:HasValidConfig());check(not frame:HasAnyPurchasedRanks());check(not frame:HasAnyConfigChanges());check(not frame:HasAnyPendingChanges())
|
|
local changed,canApply=frame:GetConfigApplicationState();check(not changed and not canApply)
|
|
eq(frame:PurchaseRank(1),false);frame:RollbackConfig();frame:ApplyConfig();frame:CommitConfigInternal();frame.ApplyButton.click();frame.UndoButton.click()
|
|
local menu={titles={},buttons={}};function menu:CreateTitle(t)self.titles[#self.titles+1]=t end;function menu:CreateButton(t,f)self.buttons[#self.buttons+1]={t,f}end
|
|
frame.ResetButton.menu(nil,menu);eq(#menu.buttons,0);eq(provider.staged[1],2)
|
|
provider.resetOffer={guid='1234',cost=1};StaticPopupDialogs.GATEWAY_TURTLE_TALENT_RESET.OnAccept(nil,provider.resetOffer)
|
|
button:SetTooltipInternal();check(GameTooltip.hidden);eq(#GameTooltip.lines,0);frame.scripts.OnShow()
|
|
eq(#controls,before,'inspected context cannot send self control commands')
|
|
end
|
|
assertUnavailable()
|
|
local clear=frame.clearCount;frame.nodeInfoCache[1]={old=true};guid='Player-70-B';driver.scripts.OnEvent(driver,'PLAYER_TARGET_CHANGED')
|
|
check(frame.clearCount>clear);eq(next(frame.nodeInfoCache),nil);assertUnavailable()
|
|
-- Own server snapshot may advance while inspecting; it remains model/audit data.
|
|
local newer={seq=2,guid=123,class=1,level=60,points=2,count=1,known={[101]=true}}
|
|
provider.state=newer;provider:Changed();assertUnavailable();eq(provider.state,newer)
|
|
-- A different imported-inspect context also invalidates cached target state.
|
|
PlayerSpellsFrame.inspectUnit=nil;PlayerSpellsFrame.inspectString='opaque-A';frame:UpdateInspecting();clear=frame.clearCount
|
|
PlayerSpellsFrame.inspectString='opaque-B';frame:UpdateInspecting();check(frame.clearCount>clear);assertUnavailable()
|
|
PlayerSpellsFrame:SetInspectUnit(nil)
|
|
eq(provider.state,newer);eq(provider.staged[1],2);eq(frame.turtleActiveContext,newer);check(frame:HasValidConfig());check(frame.ClassCurrencyDisplay.shown);check(not frame.turtleInspectUnavailable);check(not frame.GatewayTurtleInspectNotice.shown)
|
|
eq(#frame:GetTreeNodes(),1);check(frame:GetAndCacheNodeInfo(1));eq(frame:GetAndCacheDefinitionInfo(1).spellID,102);check(frame:HasAnyConfigChanges());eq(#controls,before)
|
|
-- Explicit own-pane command uses the original UI clear-inspect lifecycle.
|
|
PlayerSpellsFrame:SetInspectUnit('target');SlashCmdList.GATEWAYTURTLETALENTS();check(not frame:IsInspecting());eq(frame.turtleActiveContext,newer);eq(provider.state,newer)
|
|
check(driver.events.PLAYER_TARGET_CHANGED and driver.events.INSPECT_READY)
|
|
io.write('PASS: self→inspect A/B/string→self; no own nodes/ranks/currency/actions in inspect; own snapshot/staging preserved\n')
|