/** * tests/fixtures/socket-payloads.js * * Socket payload fixtures — frozen; include valid and invalid variants. * Used by socket-message contract tests and SocketHandler tests. * * All exports are Object.freeze'd — never mutate fixture data in tests. */ export const SOCKET_PAYLOADS = Object.freeze({ // ── Valid intent (GM → all clients) ────────────────────────────────────── validIntent: Object.freeze({ event: "scrying-pool.visibility.set", payload: Object.freeze({ opId: "op-001", userId: "user-abc", targetState: "hidden", baseRevision: 0, }), }), // ── Valid echo (broadcast ← GM) ─────────────────────────────────────────── validEcho: Object.freeze({ event: "scrying-pool.visibility.updated", payload: Object.freeze({ opId: "op-001", userId: "user-abc", state: "hidden", revision: 1, }), }), // ── Malformed: missing opId ─────────────────────────────────────────────── missingOpId: Object.freeze({ event: "scrying-pool.visibility.set", payload: Object.freeze({ userId: "user-abc", targetState: "hidden", baseRevision: 0, // opId intentionally omitted }), }), // ── Malformed: wrong enum value for targetState ─────────────────────────── invalidState: Object.freeze({ event: "scrying-pool.visibility.set", payload: Object.freeze({ opId: "op-002", userId: "user-abc", targetState: "invisible", // not a valid VisibilityState baseRevision: 0, }), }), // ── Malformed: extra unknown keys in payload ────────────────────────────── extraKeys: Object.freeze({ event: "scrying-pool.visibility.set", payload: Object.freeze({ opId: "op-003", userId: "user-abc", targetState: "hidden", baseRevision: 0, extraField: "should-not-be-here", }), }), // ── Malformed: unknown event name ───────────────────────────────────────── unknownEvent: Object.freeze({ event: "sp:stateChange", // violates naming convention payload: Object.freeze({ opId: "op-004", userId: "user-abc" }), }), // ── Malformed: echo message missing revision field ─────────────────────── missingRevision: Object.freeze({ event: "scrying-pool.visibility.updated", payload: Object.freeze({ opId: "op-005", userId: "user-abc", state: "hidden", // revision intentionally omitted }), }), // ── Stale ACK — opId not in pendingOps ─────────────────────────────────── staleEcho: Object.freeze({ event: "scrying-pool.visibility.updated", payload: Object.freeze({ opId: "op-stale-999", // not registered in any pendingOps map userId: "user-abc", state: "hidden", revision: 5, }), }), // ── Timeout/retry sequence: intent that will time out ──────────────────── timeoutIntent: Object.freeze({ event: "scrying-pool.visibility.set", payload: Object.freeze({ opId: "op-timeout-001", userId: "user-abc", targetState: "hidden", baseRevision: 0, }), }), // ── Hydration payload (persisted world setting shape) ──────────────────── hydrationPayload: Object.freeze({ _version: 1, matrix: Object.freeze({ "user-001": "active", "user-002": "hidden", }), }), // ── Malformed: missing baseRevision in intent ───────────────────────────── missingBaseRevision: Object.freeze({ event: "scrying-pool.visibility.set", payload: Object.freeze({ opId: "op-006", userId: "user-abc", targetState: "hidden", // baseRevision intentionally omitted }), }), });