mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-11-17 14:25:27 +09:00
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>
This commit is contained in:
1 parent
e47f41d440
commit
9ddb7b362b
20 files changed
+95
-155
No files matched your search
@@ -1,9 +1,9 @@
|
||||
local Suite = ... --- @type Suite<ExpReports.TestEnv>
|
||||
|
||||
Suite.test("receive_created() tells everyone and raises on_player_reported", function(env)
|
||||
env.add_player("alice", true, true)
|
||||
local bob = env.add_player("bob")
|
||||
env.add_player("carol")
|
||||
env.add_player{ name = "alice", admin = true }
|
||||
local bob = env.add_player{ name = "bob" }
|
||||
env.add_player{ name = "carol" }
|
||||
local report = env.report("bob", "alice")
|
||||
env.Reports.receive_created{ report = report, reports = { report, env.report("bob", "carol") } }
|
||||
|
||||
@@ -26,8 +26,8 @@ Suite.test("receive_created() tells everyone and raises on_player_reported", fun
|
||||
end)
|
||||
|
||||
Suite.test("receive_created() raises nothing when the reported player has left", function(env)
|
||||
env.add_player("alice")
|
||||
env.add_player("bob", false)
|
||||
env.add_player{ name = "alice" }
|
||||
env.add_player{ name = "bob", connected = false }
|
||||
local report = env.report("bob", "alice")
|
||||
env.Reports.receive_created{ report = report, reports = { report } }
|
||||
Suite.eq(env.printed, { { to = "alice", { "exp-reports.created", "bob", "griefing" } } }, "the report is still announced")
|
||||
@@ -35,7 +35,7 @@ Suite.test("receive_created() raises nothing when the reported player has left",
|
||||
end)
|
||||
|
||||
Suite.test("receive_list() prints the reports against a player to the caller", function(env)
|
||||
env.add_player("alice")
|
||||
env.add_player{ name = "alice" }
|
||||
env.Reports.receive_list{
|
||||
caller = "alice",
|
||||
player_name = "bob",
|
||||
@@ -49,7 +49,7 @@ Suite.test("receive_list() prints the reports against a player to the caller", f
|
||||
end)
|
||||
|
||||
Suite.test("receive_list() prints how many reports each player has", function(env)
|
||||
env.add_player("alice")
|
||||
env.add_player{ name = "alice" }
|
||||
env.Reports.receive_list{
|
||||
caller = "alice",
|
||||
reports = { env.report("dave", "alice"), env.report("bob", "carol"), env.report("dave", "carol") },
|
||||
@@ -62,20 +62,20 @@ Suite.test("receive_list() prints how many reports each player has", function(en
|
||||
end)
|
||||
|
||||
Suite.test("receive_list() says when nobody is reported", function(env)
|
||||
env.add_player("alice")
|
||||
env.add_player{ name = "alice" }
|
||||
env.Reports.receive_list{ caller = "alice", reports = {} }
|
||||
Suite.eq(env.printed, { { to = "alice", { "exp-reports.list-all-none" } } }, "the caller is told there are none")
|
||||
end)
|
||||
|
||||
Suite.test("receive_list() prints nothing once the caller has left", function(env)
|
||||
env.add_player("alice", false)
|
||||
env.add_player{ name = "alice", connected = false }
|
||||
env.Reports.receive_list{ caller = "alice", reports = { env.report("bob", "carol") } }
|
||||
Suite.empty(env.printed, "nothing is printed")
|
||||
end)
|
||||
|
||||
Suite.test("receive_deleted() announces the deletion and raises on_reports_deleted", function(env)
|
||||
env.add_player("alice")
|
||||
local bob = env.add_player("bob")
|
||||
env.add_player{ name = "alice" }
|
||||
local bob = env.add_player{ name = "bob" }
|
||||
env.Reports.receive_deleted{ caller = "alice", player_name = "bob", count = 2 }
|
||||
Suite.eq(env.printed, { { "exp-reports.deleted", "bob", 2, "alice" } }, "everyone is told")
|
||||
Suite.eq(env.events, {
|
||||
@@ -84,16 +84,16 @@ Suite.test("receive_deleted() announces the deletion and raises on_reports_delet
|
||||
end)
|
||||
|
||||
Suite.test("receive_deleted() tells the caller when there was nothing to delete", function(env)
|
||||
env.add_player("alice")
|
||||
env.add_player("bob")
|
||||
env.add_player{ name = "alice" }
|
||||
env.add_player{ name = "bob" }
|
||||
env.Reports.receive_deleted{ caller = "alice", player_name = "bob", count = 0 }
|
||||
Suite.eq(env.printed, { { to = "alice", { "exp-reports.deleted-none", "bob" } } }, "only the caller is told")
|
||||
Suite.empty(env.events, "nothing was deleted")
|
||||
end)
|
||||
|
||||
Suite.test("receive_error() prints the refusal to the caller while they are online", function(env)
|
||||
env.add_player("alice")
|
||||
env.add_player("bob", false)
|
||||
env.add_player{ name = "alice" }
|
||||
env.add_player{ name = "bob", connected = false }
|
||||
env.Reports.receive_error{ caller = "alice", message = "alice has already reported bob" }
|
||||
env.Reports.receive_error{ caller = "bob", message = "gone" }
|
||||
Suite.eq(env.printed, { { to = "alice", "alice has already reported bob" } }, "the offline player is skipped")
|
||||
|
||||
Reference in new issue
Block a user