Add private chat to multiplayer rooms
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user