Fix Story 1.3: StateStore spec compliance and minor cleanup
Critical Fix: - StateStore now uses global Hooks.callAll directly (per spec) - Removed hooks parameter from StateStore constructor - Updated module.js to pass only adapter.settings - Updated tests to stub globalThis.Hooks Minor Cleanup: - Fixed misleading warning in SocketHandler.registerPendingOp - Added clarifying comment for setMatrix _revision behavior Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
@@ -11,12 +11,13 @@ import { SOCKET_PAYLOADS } from "../../fixtures/socket-payloads.js";
|
||||
describe("socket-message contract", () => {
|
||||
describe("createSocketIntentMessage()", () => {
|
||||
it("creates a valid intent message", () => {
|
||||
const msg = createSocketIntentMessage("op-1", "user-1", "hidden");
|
||||
const msg = createSocketIntentMessage("op-1", "user-1", "hidden", 0);
|
||||
expect(msg.event).toBe(SOCKET_EVENTS.VISIBILITY_SET);
|
||||
const p = /** @type {any} */ (msg.payload);
|
||||
expect(p.opId).toBe("op-1");
|
||||
expect(p.userId).toBe("user-1");
|
||||
expect(p.targetState).toBe("hidden");
|
||||
expect(p.baseRevision).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -59,10 +60,14 @@ describe("socket-message contract", () => {
|
||||
|
||||
it("throws on unknown top-level keys", () => {
|
||||
expect(() =>
|
||||
isValidSocketMessage({ event: SOCKET_EVENTS.VISIBILITY_SET, payload: { opId: "x", userId: "y", targetState: "active" }, extra: true })
|
||||
isValidSocketMessage({ event: SOCKET_EVENTS.VISIBILITY_SET, payload: { opId: "x", userId: "y", targetState: "active", baseRevision: 0 }, extra: true })
|
||||
).toThrow(TypeError);
|
||||
});
|
||||
|
||||
it("throws on missing baseRevision in intent", () => {
|
||||
expect(() => isValidSocketMessage(SOCKET_PAYLOADS.missingBaseRevision)).toThrow(TypeError);
|
||||
});
|
||||
|
||||
it("throws on empty event string", () => {
|
||||
expect(() =>
|
||||
isValidSocketMessage({ event: "", payload: {} })
|
||||
|
||||
Reference in New Issue
Block a user