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

92 lines
5.0 KiB
Lua

-- Original70334 tooltipPreCall mutates the same lines table ProcessLines reads.
local pre, post, linePre
Enum = {TooltipDataType = {Item = 0}, TooltipDataLineType = {None = 0}}
TooltipDataProcessor = {
AddTooltipPreCall = function(_, callback) pre = callback end,
AddTooltipPostCall = function(_, callback) post = callback end,
AddLinePreCall = function(_, callback) linePre = callback end,
}
local hidden = {}
issecretvalue = function(value) return value == hidden end
GetLocale = function() return "enUS" end
C_Item = {
GetItemInfoInstant = function(id) return id, "Weapon", "Wand", "INVTYPE_RANGEDRIGHT", 1, 2, 19 end,
GetItemInfo = function(id) return "Item"..id, nil, 2, 60, 1, "Weapon", "Wand", 1, "INVTYPE_RANGEDRIGHT", 1, 1, 2 end,
}
hooksecurefunc = function() end
GatewaySourceWeaponDamageData = {
schemaVersion = 5, locale = "enUS",
schools = {[2] = "Fire", [3] = "Nature", [4] = "Frost", [6] = "Arcane"},
items = {
[1001] = {{index = 1, school = 2, minimum = 16, maximum = 30}},
[1002] = {{index = 1, school = 3, minimum = 5, maximum = 7}},
[1003] = {{index = 1, school = 6, minimum = 1, maximum = 2},
{index = 3, school = 4, minimum = 3, maximum = 4}},
},
}
dofile(arg[1] or "client_addons/GatewayDiagnostics/SourceWeaponDamage.lua")
assert(pre and post and linePre)
local color = {r = 1, g = 1, b = 1}
local function fixture(id, damage, speed, dps)
local name = {type = 0, leftText = "Weapon name"}
local main = {type = 0, leftText = damage, rightText = speed, leftColor = color}
local rate = {type = 0, leftText = dps}
local enchant = {type = 0, leftText = "Enchant: owner-specific fire effect", leftColor = {r = 0, g = 1, b = 0}}
local proc = {type = 0, leftText = "Chance on hit: existing effect"}
local set = {type = 0, leftText = "Set: existing owner bonus"}
local footer = {type = 0, leftText = "Press F6 to submit an issue for this item"}
local data = {type = 0, id = id, lines = {name, main, rate, enchant, proc, set, footer}}
return data, {name, main, rate, enchant, proc, set, footer}
end
local function tooltip()
return {rendered = {}, ClearLines = function(self) self.rendered = {} end,
AddLine = function(self, left) self.rendered[#self.rendered + 1] = left end,
AddDoubleLine = function(self, left, right) self.rendered[#self.rendered + 1] = left.."|"..right end}
end
local function check(id, damage, speed, dps, bands)
local data, native = fixture(id, damage, speed, dps)
local t = tooltip()
pre(t, data)
assert(data.lines[1] == native[1] and data.lines[2] == native[2])
for index, text in ipairs(bands) do
local line = data.lines[2 + index]
assert(line.leftText == text and line.type == 0 and line.leftColor == color and line.wrapText == false)
end
for index = 3, #native do assert(data.lines[index + #bands] == native[index]) end
assert(native[2].leftText == damage and native[2].rightText == speed)
assert(native[3].leftText == dps) -- Total DPS and all owner effect objects unchanged.
local count = #data.lines
pre(t, data) -- Same original data may be reused on refresh: replace only owned rows.
assert(#data.lines == count)
for index, line in ipairs(data.lines) do
if not linePre(t, line) then
if line.rightText then t:AddDoubleLine(line.leftText, line.rightText) else t:AddLine(line.leftText) end
end
end
local before = #t.rendered
post(t, data)
assert(#t.rendered == before and t.rendered[#t.rendered] == native[7].leftText)
assert(t.rendered[3] == bands[1] and t.rendered[3 + #bands] == dps)
return data, t
end
-- Reported Blackflame wand values: both components precede the unchanged35.4DPS.
check(1001, "16 - 30 Shadow Damage", "Speed 1.30", "(35.4 damage per second)", {"+16 - 30 Fire Damage"})
check(1002, "100 - 200 Damage", "Speed 2.60", "(60.0 damage per second)", {"+5 - 7 Nature Damage"})
check(1003, "50 - 75 Damage", "Speed 2.80", "(23.9 damage per second)", {"+1 - 2 Arcane Damage", "+3 - 4 Frost Damage"})
-- Instance-modified native main/DPS/enchantment content remains untouched.
check(1001, "19 - 33 Shadow Damage", "Speed 1.30", "(38.0 damage per second)", {"+16 - 30 Fire Damage"})
local data = fixture(1001, "16 - 30 Shadow Damage", "Speed 1.30", "(35.4 damage per second)")
local t = tooltip()
pre(t, data)
data.id = 9999 -- Only our inserted rows disappear when the same data object changes context.
pre(t, data)
assert(#data.lines == 7)
local unknown, native = fixture(1001, "Unclassified native damage", "Speed 1.30", "(35.4 damage per second)")
pre(t, unknown);post(t, unknown)
assert(#unknown.lines == #native and #t.rendered == 0)
local secret, original = fixture(1001, "16 - 30 Shadow Damage", "Speed 1.30", "(35.4 damage per second)")
secret.lines[2].leftText = hidden
pre(t, secret);post(t, secret)
assert(#secret.lines == #original and #t.rendered == 0) -- No secret bypass/fallback footer append.
print("PASS: wand/melee/ranged source bands follow main damage; DPS/owner/footer preserved; refresh and unknown contexts safe")