Skip to content

Commit

Permalink
Merge branch 'release/3.14.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
evil-morfar committed Sep 25, 2024
2 parents 29d2110 + a1f6c78 commit 74082e9
Show file tree
Hide file tree
Showing 32 changed files with 648 additions and 253 deletions.
4 changes: 2 additions & 2 deletions .busted
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
return {
_all = {
["pattern"] = ".spec",
["coverage"] = true,
["lpath"] = "./__tests/?.lua"
},
default = {
["ROOT"] = { ".specs"},
["output"] = "utfTerminal"
["output"] = "utfTerminal",
Xoutput = "--color",
},

Classes = {
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/busted.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ jobs:

- name: Setup dependencies
run: |
luarocks install luacov
luarocks install rxlua
luarocks install luabitop
luarocks install busted
- name: Run Busted
run: busted -f .busted --lpath="__tests/?.lua" -Xoutput --color
run: busted -f .busted --lpath="__tests/?.lua" -Xoutput --color --no-coverage
9 changes: 9 additions & 0 deletions .specs/Classes/Utils/GroupLoot.spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,15 @@ describe("#GroupLoot", function()
addon.isInGuildGroup = false
addon.db.profile.autoGroupLootGuildGroupOnly = true
end)
it("statusToDescription should return a table", function()
assert.has_no.errors(function() GroupLoot:StatusToDescription(1,1) end)
assert.is_table(GroupLoot:StatusToDescription(1,1))
assert.equal(4, #GroupLoot:StatusToDescription(1, 1)) -- 1 -> 0001 after conversion
local status, target = "101100000", "011011011"
assert.has_no.errors(function() GroupLoot:StatusToDescription(status, target) end)
assert.is_table(GroupLoot:StatusToDescription(status, target))
assert.equal(9, #GroupLoot:StatusToDescription(status, target))
end)
it("should return '101100000' by default", function()
local status = GroupLoot:GetInvertedStatusTable()
-- By default only GetNumGroupMembers, autoGroupLootGuildGroupOnly, and enabled are set
Expand Down
4 changes: 2 additions & 2 deletions .specs/EmulatePlayerLogin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

function _G.IsLoggedIn() return true end
WoWAPI_FireEvent("ADDON_LOADED", "RCLootCouncil")
WoWAPI_FireEvent("PLAYER_LOGIN", "RCLootCouncil")
WoWAPI_FireEvent("PLAYER_ENTERING_WORLD", "RCLootCouncil")
WoWAPI_FireEvent("PLAYER_LOGIN")
WoWAPI_FireEvent("PLAYER_ENTERING_WORLD", true)
local origWowApi = WoWAPI_FireEvent
-- Override msg events to add the player name
function _G.WoWAPI_FireEvent(event, ...)
Expand Down
79 changes: 79 additions & 0 deletions .specs/Integration/MLLogic.spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
require "busted.runner"()
-- Just load everything
local addon = dofile(".specs/AddonLoader.lua").LoadToc("RCLootCouncil.toc")
dofile ".specs/EmulatePlayerLogin.lua"
addon.Print = function() end --noop
function _G.GetNumGroupMembers() return 3 end
function _G.GetRaidRosterInfo(raidIndex)
local info = {
{"Player1-Realm1", 2}, -- us leader
{"Player2-Realm1", 1},
{"Player3-Realm2", 1},
}
return unpack(info[raidIndex] or info[1])
end

-- function _G.IsLoggedIn() return true end
function _G.UnitIsGroupLeader() return true end
local function ResetMLStuff()
addon.masterLooter = nil
addon.isMasterLooter = nil
addon.isCouncil = false
addon.handleLoot = false
end

describe("#Integration #MLLogic", function ()

it("call NewMLCheck", function()
RCLootCouncil:NewMLCheck()
end)

it("should reenable ML stuff on reload", function()
_G.IsInRaidVal = true
addon.db.profile.usage = {
ask_gl = false,
gl = true,
state = "gl"
}
WoWAPI_FireUpdate(1)
WoWAPI_FireEvent("PLAYER_ENTERING_WORLD", false, false)
WoWAPI_FireEvent("RAID_INSTANCE_WELCOME")
_ADVANCE_TIME(4)
assert.True(addon.handleLoot)
assert.True(addon.isMasterLooter)
assert.are.equal(addon.player, addon.masterLooter)
assert.is_not.Nil(next(addon.mldb))
addon:OnEvent("PLAYER_LOGOUT")
ResetMLStuff()
WoWAPI_FireUpdate(10)
WoWAPI_FireEvent("PLAYER_ENTERING_WORLD", false, true)
_ADVANCE_TIME(3)
assert.True(addon.handleLoot)
assert.True(addon.isMasterLooter)
assert.are.equal(addon.player, addon.masterLooter)
assert.is_not.Nil(next(addon.mldb))

-- print ("ML:", addon.masterLooter, addon.player)
-- printtable(addon.db.global.log)
end)

it("should fire ML usage on party leader changed", function()
_G.IsInRaidVal = true
addon.db.profile.usage = {
ask_gl = false,
gl = true,
state = "gl"
}

-- Player2 is ML initially
addon.masterLooter = addon.Require "Data.Player":Get("Player2")
addon.handleLoot = true
spy.on(addon, "OnStartHandleLoot")
WoWAPI_FireEvent("PARTY_LEADER_CHANGED")
_ADVANCE_TIME(1)
assert.are.equal(addon.player, addon.masterLooter)
assert.True(addon.isMasterLooter)
assert.True(addon.handleLoot)
assert.spy(addon.OnStartHandleLoot).was.called(1)
end)
end)
26 changes: 15 additions & 11 deletions .specs/Integration/VotingFrame/randomRolls.spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ describe("#VotingFrame #RandomRolls", function()
addon.Require "Utils.Log":Clear()
snapshot = assert:snapshot()
addon.db.global.verTestCandidates = {}
addon.Require "Data.Council":Set{}
end)

after_each(function()
snapshot:revert()
-- Occasionally items were left by previouss tests
_ADVANCE_TIME(5)
RCLootCouncilML:EndSession()
end)

Expand Down Expand Up @@ -89,11 +92,13 @@ describe("#VotingFrame #RandomRolls", function()
it("should use 'srolls' when version is above 3.13.0", function()
dofile(".specs/Helpers/SetupRaid.lua")(20)
addon.player = addon.Require "Data.Player":Get("player")

addon:Test(2, true)
WoWAPI_FireUpdate(GetTime() + 1)
-- Test might pick the same item twice which screws with our intended result
addon:Test(0, true)
_ADVANCE_TIME(1)
RCLootCouncilML:AddItem(159668)
RCLootCouncilML:AddItem(155860)
RCLootCouncilML:StartSession()
WoWAPI_FireUpdate(GetTime() + 10)
_ADVANCE_TIME(2)

-- Setup spies before doing rolls
local generateNoRepeatRollTable = spy.on(VotingFrame, "GenerateNoRepeatRollTable")
Expand All @@ -109,13 +114,12 @@ describe("#VotingFrame #RandomRolls", function()
if sessionRolls == "" then break end
local _, e, session = string.find(sessionRolls, "(%d+),")
sessionRolls = string.sub(sessionRolls, e + 1)
receivedRolls[tonumber(session)] = { string.split(",", sessionRolls), }
end
receivedRolls[tonumber(session)] = { string.split(",", sessionRolls), } end
end
local sub = Comms:Subscribe(addon.PREFIXES.MAIN, "srolls", recieverFunc)

VotingFrame:DoAllRandomRolls()
WoWAPI_FireUpdate(GetTime() + 20)
_ADVANCE_TIME(2)

assert.spy(generateNoRepeatRollTable).was.called_with(match.is_ref(VotingFrame), 20)
assert.spy(doAllRandomRolls).was.called(1)
Expand Down Expand Up @@ -201,15 +205,15 @@ describe("#VotingFrame #RandomRolls", function()
addon:CallModule("masterlooter")
addon:GetActiveModule("masterlooter"):NewML(addon.player)
addon:GetActiveModule("masterlooter"):Test { 159366, 165584, 159366, }
WoWAPI_FireUpdate(GetTime() + 10)
_ADVANCE_TIME(1)
RCLootCouncilML:StartSession()
WoWAPI_FireUpdate(GetTime() + 10)
_ADVANCE_TIME(1)

local generateNoRepeatRollTable = spy.on(VotingFrame, "GenerateNoRepeatRollTable")
local OnSessionRollsReceivedSpy = spy.on(VotingFrame, "OnSessionRollsReceived")
WoWAPI_FireUpdate(GetTime() + 20)
_ADVANCE_TIME(.1)
VotingFrame:DoRandomRolls(1)
WoWAPI_FireUpdate(GetTime() + 30)
_ADVANCE_TIME(1)
assert.spy(generateNoRepeatRollTable).was.called(1)
assert.spy(OnSessionRollsReceivedSpy).was.called(1)
-- All rolls in session 1 & 3 should be the same
Expand Down
14 changes: 9 additions & 5 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,17 @@
"kind": "test",
"isDefault": true
},
"windows": {
"args": [
"--lpath=${workspaceFolder}\\__tests\\?.lua",
]
},
{
"label": "Busted All w/coverage",
"type": "shell",
"command": "busted",
"group": {
"kind": "test",
"isDefault": true
},
"args": [
"--lpath=${workspaceFolder}/__tests/?.lua",
"-c"
]
},
{
Expand Down
6 changes: 6 additions & 0 deletions Classes/Data/Player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ local private = {
---@field name string
---@field class string
---@field realm string
---@field role "DAMAGER"|"TANK"|"HEALER"|"NONE"?
---@field rank string? Guild rank
---@field enchanter boolean? Is the player an enchanter
---@field ilvl number?
---@field specID integer?
---@field classColoredName string? Name colored by class
local playerClass = {}
function playerClass:GetName() return self.name end
function playerClass:GetRealm() return self.realm end
Expand Down
Loading

0 comments on commit 74082e9

Please sign in to comment.