Replace the flat per-spec key list with SPEC_STAT_PROFILES: an ordered
{ stat, weight } table for every class/spec. The panel now shows what
matters to the selected spec instead of falling back to spell stats for
physical specs: casters get spell damage/hit/crit/haste, melee get
strength/AP/hit/expertise/armor pen, tanks get stamina/armor/defense/
dodge/parry/block, healers get healing/spirit/MP5.
The same weights drive upgrade ranking, the completion ratio, and which
two gains are shown in the top-upgrades line, so e.g. spell damage
outweighs spirit for Shadow while stamina outweighs expertise for a
Protection tank.
Add GetItemStats mappings for physical stats (attack power, ranged/feral
AP, strength, agility, hit, expertise, armor pen, defense, dodge, parry,
block, block value, armor). TBC per-school hit/crit/haste keys fold into
one stat. Drop the unused spellPower row from TBC profiles.
Tests: weighted scoring expectations, physical/tank mappings, profile
coverage and 8-row panel limit, weighted ratios. 104 passing.
352 lines
13 KiB
Lua
352 lines
13 KiB
Lua
-- Integration tests for Amibis:CompareGear, upgrade scoring, and stat keys.
|
|
-- Mirrors the inventory slot map in Amibis.lua (name -> inventory slotID).
|
|
local _, ns = ...
|
|
|
|
local SLOT_TO_INVENTORY = {
|
|
Head = 1, Neck = 2, Shoulder = 3, Back = 15, Chest = 5,
|
|
Wrist = 9, Hands = 10, Waist = 6, Legs = 7, Feet = 8,
|
|
Finger0 = 11, Finger1 = 12, Trinket0 = 13, Trinket1 = 14,
|
|
MainHand = 16, SecondaryHand = 17, Ranged = 18,
|
|
}
|
|
|
|
local function equip(slot, itemID)
|
|
MockEquipped[SLOT_TO_INVENTORY[slot]] = itemID
|
|
end
|
|
|
|
local function find_upgrade(data, slot)
|
|
for _, upgrade in ipairs(data.topUpgrades) do
|
|
if upgrade.slot == slot then return upgrade end
|
|
end
|
|
return nil
|
|
end
|
|
|
|
describe("CompareGear: upgrade scoring", function()
|
|
before_each(function()
|
|
MockItems = {
|
|
[21869] = {
|
|
name = "Old Weapon",
|
|
stats = { ["ITEM_MOD_SPELL_DAMAGE_DONE_SHORT"] = 35 },
|
|
},
|
|
[31064] = {
|
|
name = "Hood of Absolution",
|
|
stats = {
|
|
["ITEM_MOD_INTELLECT_SHORT"] = 20,
|
|
["ITEM_MOD_SPIRIT_SHORT"] = 25,
|
|
},
|
|
},
|
|
[31070] = {
|
|
name = "Shoulderpads of Absolution",
|
|
stats = {
|
|
["ITEM_MOD_SPELL_DAMAGE_DONE_SHORT"] = 45,
|
|
["ITEM_MOD_INTELLECT_SHORT"] = 20,
|
|
},
|
|
},
|
|
[30666] = {
|
|
name = "Ritssyn's Lost Pendant",
|
|
stats = { ["ITEM_MOD_INTELLECT_SHORT"] = 15 },
|
|
},
|
|
[32374] = {
|
|
name = "Zhar'doom, Greatstaff of the Devourer",
|
|
stats = { ["ITEM_MOD_SPELL_DAMAGE_DONE_SHORT"] = 60 },
|
|
},
|
|
}
|
|
MockEquipped = {}
|
|
AmibisDB.selectedPhase = "T6"
|
|
AmibisCharDB.overrideSpec = "Shadow"
|
|
end)
|
|
|
|
it("counts BIS slots and total slots", function()
|
|
equip("Head", 31064)
|
|
equip("MainHand", 21869)
|
|
local data = ns.Amibis:CompareGear()
|
|
expect(data.hasBISList).toBeTruthy()
|
|
expect(data.bisCount).toEqual(1)
|
|
expect(data.totalSlots).toEqual(16)
|
|
end)
|
|
|
|
it("ranks upgrades by weighted spec stats", function()
|
|
equip("MainHand", 21869)
|
|
local data = ns.Amibis:CompareGear()
|
|
expect(#data.topUpgrades).toEqual(3)
|
|
-- Shoulder: 45 spell damage (x3) + 20 intellect (x1) = 155
|
|
expect(data.topUpgrades[1].slot).toEqual("Shoulder")
|
|
expect(data.topUpgrades[1].score).toEqual(155)
|
|
expect(data.topUpgrades[1].statDiffs).toEqual({ spellDamage = 45, intellect = 20 })
|
|
-- MainHand: (60 - 35) spell damage (x3) = 75
|
|
expect(data.topUpgrades[2].slot).toEqual("MainHand")
|
|
expect(data.topUpgrades[2].score).toEqual(75)
|
|
-- Head: 20 intellect (x1) + 25 spirit (x1) = 45
|
|
expect(data.topUpgrades[3].slot).toEqual("Head")
|
|
expect(data.topUpgrades[3].score).toEqual(45)
|
|
end)
|
|
|
|
it("includes a partial stat gain when only one stat improves", function()
|
|
MockItems[21891] = {
|
|
name = "Old Hood",
|
|
stats = {
|
|
["ITEM_MOD_INTELLECT_SHORT"] = 15,
|
|
["ITEM_MOD_SPIRIT_SHORT"] = 10,
|
|
["ITEM_MOD_SPELL_DAMAGE_DONE_SHORT"] = 8,
|
|
},
|
|
}
|
|
equip("Head", 21891)
|
|
equip("MainHand", 21869)
|
|
local data = ns.Amibis:CompareGear()
|
|
local head = find_upgrade(data, "Head")
|
|
expect(head.score).toEqual(20)
|
|
expect(head.statDiffs.intellect).toEqual(5)
|
|
expect(head.statDiffs.spirit).toEqual(15)
|
|
end)
|
|
|
|
it("scores only positive stat diffs", function()
|
|
equip("Head", 31064)
|
|
equip("MainHand", 21869)
|
|
local data = ns.Amibis:CompareGear()
|
|
expect(find_upgrade(data, "Head")).toBeNil()
|
|
for _, upgrade in ipairs(data.topUpgrades) do
|
|
for _statKey, diff in pairs(upgrade.statDiffs) do
|
|
expect(diff > 0).toBeTruthy()
|
|
end
|
|
end
|
|
end)
|
|
|
|
it("returns empty upgrades when everything is BIS", function()
|
|
equip("Head", 31064)
|
|
AmibisDB.selectedPhase = nil
|
|
AmibisCharDB.overrideSpec = nil
|
|
local data = ns.Amibis:CompareGear()
|
|
expect(#data.topUpgrades).toBeAtMost(3)
|
|
end)
|
|
|
|
it("reports no BIS list for unsupported spec", function()
|
|
AmibisCharDB.overrideSpec = "Nonexistent"
|
|
local data = ns.Amibis:CompareGear()
|
|
expect(data.hasBISList).toBeFalsy()
|
|
expect(#data.topUpgrades).toEqual(0)
|
|
end)
|
|
|
|
it("resolves the phase saved in AmibisDB", function()
|
|
AmibisDB.selectedPhase = "T5"
|
|
local data = ns.Amibis:CompareGear()
|
|
expect(data.phase).toEqual("T5")
|
|
end)
|
|
end)
|
|
|
|
describe("CompareGear: spec-specific stat keys", function()
|
|
before_each(function()
|
|
MockItems = {
|
|
[21869] = {
|
|
name = "Old Weapon",
|
|
stats = { ["ITEM_MOD_INTELLECT_SHORT"] = 20 },
|
|
},
|
|
[32374] = {
|
|
name = "Zhar'doom, Greatstaff of the Devourer",
|
|
stats = {},
|
|
},
|
|
[32500] = {
|
|
name = "Crystal Spire of Karabor",
|
|
stats = {},
|
|
},
|
|
}
|
|
MockEquipped = {}
|
|
equip("MainHand", 21869)
|
|
AmibisDB.selectedPhase = "T6"
|
|
end)
|
|
|
|
it("counts spell damage for Shadow", function()
|
|
AmibisCharDB.overrideSpec = "Shadow"
|
|
MockItems[32374].stats = {
|
|
["ITEM_MOD_SPELL_DAMAGE_DONE_SHORT"] = 40,
|
|
["ITEM_MOD_DAMAGE_DONE_SHORT"] = 40,
|
|
}
|
|
local data = ns.Amibis:CompareGear()
|
|
local mh = find_upgrade(data, "MainHand")
|
|
expect(mh).toBeTruthy()
|
|
expect(mh.statDiffs.spellDamage).toEqual(40)
|
|
expect(mh.score).toEqual(120)
|
|
end)
|
|
|
|
it("ignores spell damage for Holy", function()
|
|
AmibisCharDB.overrideSpec = "Holy"
|
|
MockItems[32500].stats = {
|
|
["ITEM_MOD_SPELL_DAMAGE_DONE_SHORT"] = 40,
|
|
["ITEM_MOD_DAMAGE_DONE_SHORT"] = 40,
|
|
["ITEM_MOD_HEALING_SHORT"] = 81,
|
|
}
|
|
local data = ns.Amibis:CompareGear()
|
|
local mh = find_upgrade(data, "MainHand")
|
|
expect(mh).toBeTruthy()
|
|
expect(mh.statDiffs.spellDamage).toBeNil()
|
|
expect(mh.statDiffs.healing).toEqual(81)
|
|
end)
|
|
end)
|
|
|
|
describe("GetStatKeysForSpec", function()
|
|
it("includes spell damage for damage specs", function()
|
|
local shadowKeys = ns.Amibis:GetStatKeysForSpec("PRIEST", "Shadow")
|
|
local found = false
|
|
for _, key in ipairs(shadowKeys) do
|
|
if key == "spellDamage" then found = true end
|
|
end
|
|
expect(found).toBeTruthy()
|
|
expect(#shadowKeys).toEqual(7)
|
|
end)
|
|
|
|
it("includes healing for healing specs", function()
|
|
local holyKeys = ns.Amibis:GetStatKeysForSpec("PRIEST", "Holy")
|
|
local found = false
|
|
for _, key in ipairs(holyKeys) do
|
|
if key == "healing" then found = true end
|
|
end
|
|
expect(found).toBeTruthy()
|
|
end)
|
|
|
|
it("uses physical stats for melee specs", function()
|
|
local keys = ns.Amibis:GetStatKeysForSpec("WARRIOR", "Arms")
|
|
local seen = {}
|
|
for _, key in ipairs(keys) do seen[key] = true end
|
|
expect(seen.strength).toBeTruthy()
|
|
expect(seen.attackPower).toBeTruthy()
|
|
expect(seen.hit).toBeTruthy()
|
|
expect(seen.crit).toBeTruthy()
|
|
expect(seen.healing).toBeFalsy()
|
|
expect(seen.spellDamage).toBeFalsy()
|
|
expect(seen.spirit).toBeFalsy()
|
|
expect(seen.mp5).toBeFalsy()
|
|
end)
|
|
|
|
it("uses mitigation stats for tanks", function()
|
|
local keys = ns.Amibis:GetStatKeysForSpec("PALADIN", "Protection")
|
|
local seen = {}
|
|
for _, key in ipairs(keys) do seen[key] = true end
|
|
expect(seen.stamina).toBeTruthy()
|
|
expect(seen.defense).toBeTruthy()
|
|
expect(seen.dodge).toBeTruthy()
|
|
expect(seen.parry).toBeTruthy()
|
|
end)
|
|
|
|
it("differs between specs of the same class", function()
|
|
local shadow = table.concat(ns.Amibis:GetStatKeysForSpec("PRIEST", "Shadow"), ",")
|
|
local holy = table.concat(ns.Amibis:GetStatKeysForSpec("PRIEST", "Holy"), ",")
|
|
expect(shadow ~= holy).toBeTruthy()
|
|
end)
|
|
|
|
it("falls back to a default profile for unsupported specs", function()
|
|
local keys = ns.Amibis:GetStatKeysForSpec("DEATHKNIGHT", "Frost")
|
|
expect(#keys > 0).toBeTruthy()
|
|
end)
|
|
|
|
it("keeps every spec profile within the 8-row panel limit", function()
|
|
for _, class in ipairs(ns.Data.BISLists:GetAvailableClasses()) do
|
|
for _, spec in ipairs(ns.Data.BISLists:GetAvailableSpecs(class)) do
|
|
local keys = ns.Amibis:GetStatKeysForSpec(class, spec)
|
|
expect(#keys > 0).toBeTruthy()
|
|
expect(#keys <= 8).toBeTruthy()
|
|
end
|
|
end
|
|
end)
|
|
end)
|
|
|
|
describe("StatRatio weighting", function()
|
|
it("weights primary stats above secondary ones", function()
|
|
local ratios = ns.Amibis
|
|
local bis = { spellDamage = 100, spirit = 100 }
|
|
local primary = ratios:StatRatio({ spellDamage = 100, spirit = 0 }, bis, "PRIEST", "Shadow")
|
|
local secondary = ratios:StatRatio({ spellDamage = 0, spirit = 100 }, bis, "PRIEST", "Shadow")
|
|
expect(primary > secondary).toBeTruthy()
|
|
expect(primary).toBeCloseTo(0.75)
|
|
expect(secondary).toBeCloseTo(0.25)
|
|
end)
|
|
end)
|
|
|
|
describe("GetCompletionRatio", function()
|
|
before_each(function()
|
|
MockItems = {}
|
|
MockEquipped = {}
|
|
AmibisDB.selectedPhase = "T6"
|
|
AmibisCharDB.overrideSpec = "Shadow"
|
|
end)
|
|
|
|
it("falls back to slot completion while stats load", function()
|
|
equip("Head", 31064)
|
|
local data = ns.Amibis:CompareGear()
|
|
expect(data.statsComplete).toBeFalsy()
|
|
local ratio = ns.Amibis:GetCompletionRatio(data)
|
|
expect(ratio).toBeCloseTo(1 / 16)
|
|
end)
|
|
|
|
it("is 1.0 when fully geared to BIS", function()
|
|
local list = ns.Data.BISLists:GetBISList("PRIEST", "Shadow", "T6")
|
|
for slot, entry in pairs(list) do
|
|
MockItems[entry.itemID] = {
|
|
name = entry.name,
|
|
stats = {
|
|
["ITEM_MOD_INTELLECT_SHORT"] = 100,
|
|
["ITEM_MOD_SPELL_DAMAGE_DONE_SHORT"] = 50,
|
|
},
|
|
}
|
|
equip(slot, entry.itemID)
|
|
end
|
|
local data = ns.Amibis:CompareGear()
|
|
expect(data.statsComplete).toBeTruthy()
|
|
expect(data.bisCount).toEqual(16)
|
|
expect(#data.topUpgrades).toEqual(0)
|
|
expect(ns.Amibis:GetCompletionRatio(data)).toBeCloseTo(1.0)
|
|
end)
|
|
end)
|
|
|
|
describe("latest phase progress", function()
|
|
before_each(function()
|
|
MockItems = {}
|
|
MockEquipped = {}
|
|
AmibisDB.selectedPhase = "T6"
|
|
AmibisCharDB.overrideSpec = "Shadow"
|
|
end)
|
|
|
|
it("exposes the latest phase and nil ratio while stats load", function()
|
|
local data = ns.Amibis:CompareGear()
|
|
expect(data.latestPhase).toEqual("ZA")
|
|
expect(data.latestCompletionRatio).toBeNil()
|
|
end)
|
|
|
|
it("measures progress against the latest phase, not the selected one", function()
|
|
local latestList = ns.Data.BISLists:GetBISList("PRIEST", "Shadow", "ZA")
|
|
local oldList = ns.Data.BISLists:GetBISList("PRIEST", "Shadow", "T4")
|
|
for slot, entry in pairs(oldList) do
|
|
MockItems[entry.itemID] = {
|
|
name = entry.name,
|
|
stats = {
|
|
["ITEM_MOD_INTELLECT_SHORT"] = 100,
|
|
["ITEM_MOD_SPELL_DAMAGE_DONE_SHORT"] = 50,
|
|
},
|
|
}
|
|
equip(slot, entry.itemID)
|
|
end
|
|
for slot, entry in pairs(latestList) do
|
|
MockItems[entry.itemID] = {
|
|
name = entry.name,
|
|
stats = {
|
|
["ITEM_MOD_INTELLECT_SHORT"] = 200,
|
|
["ITEM_MOD_SPELL_DAMAGE_DONE_SHORT"] = 90,
|
|
},
|
|
}
|
|
end
|
|
AmibisDB.selectedPhase = "T4"
|
|
local data = ns.Amibis:CompareGear()
|
|
expect(data.phase).toEqual("T4")
|
|
expect(data.latestPhase).toEqual("ZA")
|
|
expect(ns.Amibis:GetCompletionRatio(data)).toBeCloseTo(1.0)
|
|
expect(data.latestCompletionRatio < 1.0).toBeTruthy()
|
|
expect(data.latestCompletionRatio > 0.3).toBeTruthy()
|
|
end)
|
|
|
|
it("ratio matches when the latest phase is also selected", function()
|
|
local list = ns.Data.BISLists:GetBISList("PRIEST", "Shadow", "ZA")
|
|
expect(list).toBeTruthy()
|
|
AmibisDB.selectedPhase = "ZA"
|
|
local data = ns.Amibis:CompareGear()
|
|
expect(data.phase).toEqual("ZA")
|
|
expect(data.latestPhase).toEqual("ZA")
|
|
end)
|
|
end)
|