Files
factorio-expcluster/exp_reports/test/module/requests.lua
T
bbassieandClaude Opus 5.5 9ddb7b362b Move the report commands into exp_reports
The create-report, get-reports and clear-reports commands now live in the
plugin's own module next to the functions they call, with their locale.
The permissions keep their exp_scenario.command names because the command
authority derives them from the command name.

The Discord report alert in exp_scenario is gone since exp_reports posts to
its own webhook. The shared add_player stub takes an options table with
connected and admin defaulting to true and false, replacing the copy in
the exp_reports test environment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 23:22:18 +00:00

35 lines
1.6 KiB
Lua

local Suite = ... --- @type Suite<ExpReports.TestEnv>
Suite.test("create_report() sends the report to the controller", function(env)
local alice = env.add_player{ name = "alice" }
local bob = env.add_player{ name = "bob" }
env.Reports.create_report(alice, bob, "griefing")
Suite.eq(env.sent, {
{ channel = "exp_reports:create", data = { player_name = "bob", by_player_name = "alice", reason = "griefing" } },
}, "the report names both players")
end)
Suite.test("list_reports() sends the caller and the player", function(env)
local alice = env.add_player{ name = "alice" }
local bob = env.add_player{ name = "bob" }
env.Reports.list_reports(alice, bob)
env.Reports.list_reports(alice)
Suite.eq(env.sent, {
{ channel = "exp_reports:list", data = { caller = "alice", player_name = "bob" } },
{ channel = "exp_reports:list", data = { caller = "alice" } },
}, "the player is left out when listing everyone")
end)
Suite.test("delete_reports() sends the caller, the player and the reporter", function(env)
local alice = env.add_player{ name = "alice" }
local bob = env.add_player{ name = "bob" }
env.Reports.delete_reports(alice, bob, "carol")
env.Reports.delete_reports(alice, bob)
Suite.eq(env.sent, {
{ channel = "exp_reports:delete", data = { caller = "alice", player_name = "bob", by_player_name = "carol" } },
{ channel = "exp_reports:delete", data = { caller = "alice", player_name = "bob" } },
}, "the reporter is left out when deleting every report")
end)
return Suite.run()