Add private chat to multiplayer rooms

This commit is contained in:
2026-10-08 10:22:19 +05:00
parent 1307436e65
commit 36e8d11eb4
14 changed files with 810 additions and 4 deletions

View File

@@ -4,9 +4,45 @@ import {
createRoomSchema,
joinRoomSchema,
roomGuessSchema,
chatMessageSchema,
} from "../shared/multiplayer";
const map = "00000000-0000-4000-8000-000000000000";
test("chat accepts plain multilingual text and rejects blank, oversized or hidden-control messages", () => {
assert.equal(
chatMessageSchema.parse({ clientId: map, text: " Привет (: " }).text,
"Привет (:",
);
assert.equal(
chatMessageSchema.safeParse({ clientId: map, text: "x".repeat(500) })
.success,
true,
);
for (const text of [
"",
" ",
"x".repeat(501),
"hidden\u202e",
"hidden\u0085",
"x\nname",
"x\u0000name",
])
assert.equal(
chatMessageSchema.safeParse({ clientId: map, text }).success,
false,
);
assert.equal(
chatMessageSchema.safeParse({ clientId: "wrong", text: "hi" }).success,
false,
);
assert.equal(
chatMessageSchema.parse({
clientId: map,
text: "<script>alert(1)</script>",
}).text,
"<script>alert(1)</script>",
);
});
test("room limits include the owner and stay between 2 and 16", () => {
for (const playerLimit of [2, 16])
assert.equal(