Skip to content

Commit 255a767

Browse files
committed
fix: update ServerLobbyChatSchema to use username and isHost fields
- Replace sender (clientID) with username and isHost in schema - Update tests to match new schema structure - Fixes TypeScript compilation errors
1 parent 7a28c49 commit 255a767

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/core/Schemas.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,8 @@ export const ServerErrorSchema = z.object({
491491

492492
export const ServerLobbyChatSchema = z.object({
493493
type: z.literal("lobby_chat"),
494-
sender: ID,
494+
username: z.string(),
495+
isHost: z.boolean(),
495496
text: SafeString.max(300),
496497
});
497498

tests/LobbyChatSchemas.test.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,17 @@ describe("Lobby Chat Schemas", () => {
4646
test("ServerLobbyChatSchema valid message", () => {
4747
const msg = ServerLobbyChatSchema.parse({
4848
type: "lobby_chat",
49-
sender: "ABCDEFGH",
49+
username: "TestUser",
50+
isHost: true,
5051
text: "Hi host",
5152
});
52-
expect(msg.sender).toBe("ABCDEFGH");
53+
expect(msg.username).toBe("TestUser");
54+
expect(msg.isHost).toBe(true);
5355
});
5456

55-
test("ServerLobbyChatSchema rejects invalid sender id", () => {
57+
test("ServerLobbyChatSchema rejects missing fields", () => {
5658
const result = ServerLobbyChatSchema.safeParse({
5759
type: "lobby_chat",
58-
sender: "BAD-ID", // hyphen invalid for ID regex
5960
text: "Hi host",
6061
});
6162
expect(result.success).toBe(false);

0 commit comments

Comments
 (0)