feat: implement real-time leaderboard system with XP and voice channel tracking features
This commit is contained in:
@@ -81,6 +81,19 @@ describe("XP leaderboard", () => {
|
||||
|
||||
expect(result.rows.map((row) => row.userId)).toEqual(["1", "2", "3"]);
|
||||
});
|
||||
|
||||
test("searches identities while preserving overall ranks", () => {
|
||||
const result = buildXpLeaderboard([
|
||||
xpRow("top", "1000", 4, "Alpha"),
|
||||
xpRow("target", "900", 3, "Beta"),
|
||||
xpRow("third", "800", 2, "Gamma"),
|
||||
], 1, "target-user");
|
||||
|
||||
expect(result.totalRows).toBe(1);
|
||||
expect(result.rows.map(({ userId, rank }) => [userId, rank])).toEqual([
|
||||
["target", 2],
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("voice leaderboard", () => {
|
||||
@@ -131,6 +144,20 @@ describe("voice leaderboard", () => {
|
||||
expect(unresolved?.username).toBeNull();
|
||||
expect(shortenDiscordId("123456789012345678")).toBe("12345…5678");
|
||||
});
|
||||
|
||||
test("searches aggregated voice rows", () => {
|
||||
const result = buildVoiceLeaderboard(
|
||||
rows,
|
||||
["voice-1", "voice-2"],
|
||||
1,
|
||||
undefined,
|
||||
"missing",
|
||||
);
|
||||
|
||||
expect(result.rows.map(({ userId, rank }) => [userId, rank])).toEqual([
|
||||
["missing", 3],
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("leaderboard formatting", () => {
|
||||
|
||||
Reference in New Issue
Block a user